question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExcludeFromCodeCoverage is inaccessible due to its protection level (version 3.3.37)

See original GitHub issue

I 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:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
KalleOlaviNiemitalocommented, Apr 16, 2021

starting with NET5_0, they’re going to keep defining that symbol even post-5.0.

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_GREATER instead.

0reactions
AArnottcommented, Apr 17, 2021

That’s great to hear, @KalleOlaviNiemitalo. Thanks for sharing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found