netcodemetrics icon indicating copy to clipboard operation
netcodemetrics copied to clipboard

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

Open michaelm7456 opened this issue 5 years ago • 0 comments

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>d__951.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.<>c__DisplayClass257_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!

michaelm7456 avatar Aug 14 '20 12:08 michaelm7456