ExcludeFromCodeCoverage is inaccessible due to its protection level (version 3.3.37)
See original GitHub issueI tried upgrading from 3.0.28 to 3.3.37, but started getting this error.
error CS0122: ‘ExcludeFromCodeCoverageAttribute’ is inaccessible due to its protection level
The problem appears to be compilation constants on the generated file for this attribute:
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
.NET Core 1.x does not support ExcludeFromCodeCoverage attribute, so the constants should be changed to:
#if NETFRAMEWORK || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0 || NETCOREAPP3_1 || NETSTANDARD2_0 || NETSTANDARD2_1
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
Note that .NET 5.x is also missing from the list.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
.NET Standard 1.x project build break from ThisAssembly's ...
But ExcludeFromCodeCoverage itself available only from NETSTANDARD2_0. ... is inaccessible due to its protection level (version 3.3.37) #552.
Read more >ExcludeFromCodeCoverage is inaccessible due to its protection ...
ExcludeFromCodeCoverage is inaccessible due to its protection level (version 3.3.37) ... I tried upgrading from 3.0.28 to 3.3.37, but started getting this error....
Read more >c# - is inaccessible due to its protection level
It's because you cannot access protected member data through its class instance. You should correct your code as follows:
Read more >How to Fix .Net Error Inaccessible Due To Its Protection Level
Unlock the power of Microsoft .NET Core with my engaging Udemy courses! For all the details and limited-time $9.99 pricing, scroll down to ......
Read more >inaccessible due to protection level
I have a private variable in a script, that I want to access from another script, but it gives and error saying: Code...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It looks like that plan was changed in https://github.com/dotnet/sdk/issues/13377 and https://github.com/dotnet/sdk/pull/14798; they’re going to define
NET5_0_OR_GREATERinstead.That’s great to hear, @KalleOlaviNiemitalo. Thanks for sharing.