Skip to content

Conversation

@andrtmschkw
Copy link

For Program.cs with top-level staments:
System.Console.WriteLine(args.Length); var y = 99; class X {} interface I {}

rename-symbol fails in because ISymbol for args is ImplicitlyDeclared=true and the Locations are empty but it is accesses without a bounds check.

System.IndexOutOfRangeException: Index was outside the bounds of the array. at Roslynator.Rename.SymbolRenameState.<>c__DisplayClass30_0.<AnalyzeProjectAsync>b__0(ISymbol symbol) in \src\Workspaces.Core\Rename\SymbolRenameState.cs:line 173

Also LocalSymbolFinder.FindLocalSymbols does not support nodes of SyntaxKind.CompilationUnit (top-level statement) and the assertion fails.

@andrtmschkw
Copy link
Author

@dotnet-policy-service agree


results.AddRange(methodSymbol.TypeParameters);
results.AddRange(methodSymbol.Parameters);
results.AddRange(methodSymbol.Parameters.Where(ms => !ms.IsImplicitlyDeclared));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: rename lambda parameter to p

@josefpihrt
Copy link
Collaborator

@andrtmschkw Please update changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants