DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.66k stars 507 forks source link

SA1129DoNotUseDefaultValueTypeConstructor throws System.NullReferenceException #1668

Closed vweijsters closed 8 years ago

vweijsters commented 9 years ago

Got this AD0001 message while (heavily) editing source code in VS2015 using beta 14.

The User Diagnostic Analyzer 'StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.

I haven't been able to reproduce it yet.

GregReddick commented 9 years ago

I just recently got this on the release community edition. There is no file associated with the error, so it is hard to isolate what is causing it.

NikolayIT commented 9 years ago

I've just got this exception:

Message AD0001  The User Diagnostic Analyzer 'StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.   TexasHoldem.Logic       1   Analyzer 'StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor' threw the following exception:
'System.NullReferenceException: Object reference not set to an instance of an object.
   at StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor.HandleObjectCreationExpression(SyntaxNodeAnalysisContext context)
   at StyleCop.Analyzers.AnalyzerExtensions.<>c__DisplayClass4_0`1.<RegisterSyntaxNodeActionHonorExclusions>b__0(SyntaxNodeAnalysisContext c)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass35_0`1.<ExecuteSyntaxNodeAction>b__1()
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze)'.
pontusi commented 8 years ago

I've had this error happen twice, but it disappears when I reopen the solution making reproduction hard. Trace matches Nikolay's.

My project contains classes that use the "implicit operator" to convert from integers and strings. That may or may not be relevant.

vweijsters commented 8 years ago

Grabbing this