dotnet/roslyn

NRE from VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer when working in Roslyn.sln

Open

#77.134 aperta il 10 feb 2025

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-AnalyzersFeature - IDE0004help wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Analyzer 'Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryCast.VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer' 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: Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests
SyntaxTree: C:\R1\src\Compilers\VisualBasic\Test\Emit\ExpressionTrees\Sources\QueryHelper.vb
SyntaxNode: DirectCast(Nothing, QueryHelper ... [DirectCastExpressionSyntax]@[1442..1480) (29,67)-(29,105)

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.VisualBasic.Extensions.CastAnalyzer.CastPassedToParamArrayDefinitelyCantBeRemoved(ITypeSymbol castType)
   at Microsoft.CodeAnalysis.VisualBasic.Extensions.CastAnalyzer.IsUnnecessary()
   at Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryCast.VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer.IsUnnecessaryCast(SemanticModel model, ExpressionSyntax node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.RemoveUnnecessaryCast.AbstractRemoveUnnecessaryCastDiagnosticAnalyzer`2.TryRemoveCastExpression(SemanticModel model, TCastExpression node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.RemoveUnnecessaryCast.AbstractRemoveUnnecessaryCastDiagnosticAnalyzer`2.AnalyzeSyntax(SyntaxNodeAnalysisContext context)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)
-----

Suppress the following diagnostics to disable this analyzer: IDE0004

Guida contributor