-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Interceptors: address duplicate interceptions feedback, handle nameof, add test coverage #67971
Conversation
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass (iteration 7)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 12)
if (node is BoundNameOfOperator nameofOperator) | ||
{ | ||
Debug.Assert(!nameofOperator.WasCompilerGenerated); | ||
var nameofIdentiferSyntax = (IdentifierNameSyntax)((InvocationExpressionSyntax)nameofOperator.Syntax).Expression; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, but if this isn't an identifier, I'd like to fail fast here.
var matchingTrees = syntaxTrees.WhereAsArray(static (tree, filePath) => tree.FilePath == filePath, filePath); | ||
if (matchingTrees is []) | ||
SyntaxTree? matchingTree = null; | ||
foreach (var tree in syntaxTrees) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems expensive to iterate through the SyntaxTrees
collection once for each InterceptsLocationAttribute
. Can we avoid this without too much effort?
For instance, it looks like we're already building a HashSet<string>
of file paths in CSharpCompilation.CheckDuplicateFilePaths()
, at least temporarily. Could we create a Dictionary<string, SyntaxTree>
instead, and share between this use and CheckDuplicateFilePaths()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes total sense. We are also gonna have to make a change here to resolve the FilePath before comparing (i.e. handle /pathmap). Do you mind if I leave a comment for it and resolve in future.
Test plan: #67421
nameof()
operator[InterceptsLocation]
file path