Fix AD0001: Named Attribute Arguments in S6930
Closed this issue · 1 comments
knopa commented
Description
https://rules.sonarsource.com/csharp/RSPEC-6930/
CSC : warning AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.BackslashShouldBeAvoidedInAspNetRoutes' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains no elements'.
Repro steps
I don't have, because can't find backslash. but it happens on project which don't have startup file and controllers
Known workarounds
Related information
- SonarLint 7.8.0.88494
- Visual Studio 2022 17.9.6
- .net 8.0.204
- SonarAnalyzer.CSharp 9.24.0.89429
- Windows
knopa commented
It stuck on that code
[Display(Name = "Display HR\\Recruitment report", Description = "Display HR\\Recruitment report")]
public const string Marketing = "mark.a";
CSC : warning AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.BackslashShouldBeAvoidedInAspNetRoutes' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains no elements'.
Exception occurred with following context:
Compilation: X.Core
SyntaxTree: X.Core\Security\Permissions.cs
SyntaxNode: Name = "Display HR\\Recruitment report" ... [AttributeArgumentSyntax]@[4842..4881) (116,21)-(116,60)
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
at System.Linq.ImmutableArrayExtensions.Last[T](ImmutableArray`1 immutableArray)
at SonarAnalyzer.Helpers.MethodParameterLookupBase`1.TryGetSymbol(SyntaxNode argument, IMethodSymbol methodSymbol, IParameterSymbol& parameter)
at SonarAnalyzer.Rules.BackslashShouldBeAvoidedInAspNetRoutesBase`1.IsRouteTemplate(SemanticModel model, SyntaxNode node)
at SonarAnalyzer.Rules.BackslashShouldBeAvoidedInAspNetRoutesBase`1.Check(SonarSyntaxNodeReportingContext c)
at SonarAnalyzer.AnalysisContext.SonarCompilationStartAnalysisContext.<>c__DisplayClass11_0`1.<RegisterNodeAction>b__0(SyntaxNodeAnalysisContext x)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__52`1.<ExecuteSyntaxNodeAction>b__52_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)