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.

Large amount of NullReferenceException when running StyleCop.Analyzers from MSBuild

See original GitHub issue

We 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:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sharwellcommented, Aug 9, 2016

@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.

0reactions
pdelvocommented, Aug 9, 2016

But we still should not crash in that case 😉

Read more comments on GitHub >

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

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