WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
16 stars 3 forks source link

NullReferenceException in CompletedTaskAnalyzer #172

Closed yaakov-h closed 2 years ago

yaakov-h commented 2 years ago
Analyzer 'WTG.Analyzers.CompletedTaskAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
Exception occurred with following context:
Compilation: VsnetUrl

System.NullReferenceException: Object reference not set to an instance of an object.
   at WTG.Analyzers.CompletedTaskAnalyzer.HasCompletedTask(Compilation compilation)
   at WTG.Analyzers.CompletedTaskAnalyzer.CompilationStart(CompilationStartAnalysisContext context)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)

This project targets .NET Framework 3.5 so it may not even have the Task type.

brian-reichle commented 2 years ago

That sounds about right, GetTypeByMetadataName probably returned null.

https://github.com/WiseTechGlobal/WTG.Analyzers/blob/a125d17712d948af49985bfb74246c0bb0fdad15/src/WTG.Analyzers/Analyzers/CompletedTask/CompletedTaskAnalyzer.cs#L92