Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AD0001: Named Attribute Arguments in S6930 #9193

Closed
knopa opened this issue Apr 23, 2024 · 1 comment · Fixed by #9199
Closed

Fix AD0001: Named Attribute Arguments in S6930 #9193

knopa opened this issue Apr 23, 2024 · 1 comment · Fixed by #9199
Assignees
Labels
Type: Bug Exceptions and blocking issues during analysis.
Projects
Milestone

Comments

@knopa
Copy link

knopa commented Apr 23, 2024

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
Copy link
Author

knopa commented Apr 23, 2024

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)

@github-actions github-actions bot added this to Review in progress in Best Kanban Apr 24, 2024
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource changed the title SonarAnalyzer.Rules.CSharp.BackslashShouldBeAvoidedInAspNetRoutes Sequence contains no elements Fix AD0001: Named Attribute Arguments in S6930 Apr 24, 2024
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Apr 25, 2024
@Tim-Pohlmann Tim-Pohlmann added the Type: Bug Exceptions and blocking issues during analysis. label Apr 26, 2024
Best Kanban automation moved this from Review approved to Validate Peach Apr 26, 2024
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource moved this from Validate Peach to Done in Best Kanban May 2, 2024
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource added this to the 9.25 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Exceptions and blocking issues during analysis.
Projects
Best Kanban
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants