dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.9k stars 4.01k forks source link

Analysis should not run in referencing projects. #37107

Open ItsSmiffy opened 5 years ago

ItsSmiffy commented 5 years ago

I have two projects, A and A.Tests. A.Tests references A. I have added fxcopanalyzers (v2.9.3) via NuGet into project A. The analyzers are being pulled in and ran on the A.Tests project.

I have added <PrivateAssets>all</PrivateAssets> in the PackageReference for FxCopAnalyzers in project A (as mentioned in #24732) but hasn't resolved the issue; The analysis results are still appearing the the Error List for the A.Tests project.

n.b. Project A is a .NET Standard 2.0 project, Project A.Tests is a .NET Core 2.0.

vatsalyaagrawal commented 5 years ago

@mavasani for initial invesitgation.

mavasani commented 5 years ago

This indeed looks like a duplicate of #24732 which has been duped to NuGet/Home#4125. @ItsSmiffy did you try to close/re-open solution? Can you provide a repro project?

ItsSmiffy commented 5 years ago

@mavasani yes, I closed/re-opened the solution which didn't seem to resolve the issue. When creating a sample repo I could not reproduce the issue. So going back to my original solution/projects I found that removing the project reference (which consumes the analyzers) from the Test project then re-adding the project to the Test project seems to ensure the Analyzers do not flow down to the Test project.