elishalom / netcodemetrics

Other
33 stars 13 forks source link

Object reference not set to an instance of an object. (Roslyn based fork) #14

Open michaelm7456 opened 4 years ago

michaelm7456 commented 4 years ago

Hi all,

Reporting an issue I've ran into on the Roslyn based fork of this Repository here created by @vojtechkacmarik.

When creating a new 'Blazor' app then trying to open the Startup.cs file I get a 'NullReferenceException', possibly due to the way the Extension calculates Constructor complexity and hits an issue where a Constructor uses Expression Body syntax.

[Screenshot] Code Metrics 'NullException'  in 'Startup' Class

[Error Log] System.NullReferenceException: Object reference not set to an instance of an object. at CodeMetrics.Parsing.Roslyn.ConstructorExtractor.Convert(ConstructorDeclarationSyntax constructorDeclarationSyntax) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()&#x000D;&#x000A; at System.Linq.Enumerable.&lt;SelectManyIterator&gt;d__172.MoveNext() at System.Linq.Enumerable.<OfTypeIterator>d951.MoveNext()&#x000D;&#x000A; at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)&#x000D;&#x000A; at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector) at CodeMetrics.Adornments.MetricsAdornment.Init(ITextSnapshot textSnapshot) at CodeMetrics.Adornments.MetricsAdornment..ctor(IWpfTextView view, IMethodsExtractor methodsExtractor, ICyclomaticComplexityCalculator cyclomaticComplexityCalculator) at CodeMetrics.Adornments.MeticsAdornmentFactory.TextViewCreated(IWpfTextView textView) at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.<>cDisplayClass257_0.<BindContentTypeSpecificAssets>b__1() at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

The affected area seems to be the 'ConstructorExtractor.Convert' method.

Many thanks!