netcodemetrics
netcodemetrics copied to clipboard
Object reference not set to an instance of an object. (Roslyn based fork)
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]

[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()
 at System.Linq.Enumerable.<SelectManyIterator>d__172.MoveNext()
at System.Linq.Enumerable.<OfTypeIterator>d__951.MoveNext()
 at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
 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!