Large amount of NullReferenceException when running StyleCop.Analyzers from MSBuild
See original GitHub issueWe have recently updated our project from v1.0.0-rc1 to v1 and since then, we have been getting a large amount of NullReferenceException from our build server which is building the solution using MSBuild directly. We do not see those errors when using Quick Fixes or building our app in Visual Studio (even tough Run CA on build is enabled on the project). Here is the log I’m getting from MSBuild.
I think this is related to #1931 for which the fix was needed by our project. We also enabled SA0000 in the move over to the final release.
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.OrderingRules.SA1203ConstantsMustAppearBeforeFields' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.MaintainabilityRules.SA1402FileMayOnlyContainASingleClass' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.OrderingRules.SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.OrderingRules.SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.OrderingRules.SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.LayoutRules.SA1518UseLineEndingsCorrectlyAtEndOfFile' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [d:\Jenkins\workspace\Departments\RB\ScheduAll.Reports\Dev\Build\src\RB.ScheduAll.Reports.Core\RB.ScheduAll.Reports.Core.csproj]
CSC : error AD0001: Analyzer 'StyleCop.Analyzers.NamingRules.SA1305FieldNamesMustNotUseHungarianNotation' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
I am willing to provide a PR as a fix, but I will need further guidance on how to debug this use case.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Number of stylecop warnings more than when "build solution"
When i right-click solution ->click "Run stylecop", I get more warnings than when I build normally. Why doesn't it show when i build...
Read more >The Sonar guide for investigating the performance of .NET ...
This guide is intended to help SonarQube and SonarCloud users investigate .NET analysis performance issues. This effort can lead to:.
Read more >Modern StyleCop alternative? Advice appreciated. : r/dotnet
We are needing to enforce some very basic style rules in a set of DotNet 6 projects. This is not something we have...
Read more >MSBuild Property Functions (2)
It logs a large amount of information about why it resolves references a ... the MSBuild node execute tasks in other projects while...
Read more >Instant StyleCop Code Analysis How-to
In the Explorer solution, right-click on the project file to open the context menu, and then click on Run StyleCop… to launch your...
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 FreeTop 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
Top GitHub Comments
@pvandervelde Thanks for following up so quickly, and especially for going so far as to create a repository to reproduce the issue! With your help, we were finally able to fix this for the next preview.
But we still should not crash in that case 😉