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

Improved performance of CA1041 #6671

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

NewellClark
Copy link
Contributor

Fix #6143
I've reimplemented it as a syntax-node analyzer, as suggested.

Reimplemented CA1041 as a syntax node analyzer to improve performance.
@NewellClark NewellClark requested a review from a team as a code owner June 6, 2023 09:30
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #6671 (e1fbcc7) into main (2b6ab8d) will decrease coverage by 0.01%.
The diff coverage is 91.15%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6671      +/-   ##
==========================================
- Coverage   96.40%   96.39%   -0.01%     
==========================================
  Files        1379     1381       +2     
  Lines      322253   322340      +87     
  Branches    10460    10479      +19     
==========================================
+ Hits       310657   310730      +73     
- Misses       9103     9114      +11     
- Partials     2493     2496       +3     

@Youssef1313
Copy link
Member

as suggested

This alone isn't really sufficient. it was mostly a "hypothesis". Profiling is really needed in real-world scenarios.

while (name is QualifiedNameSyntax qualifiedName)
name = qualifiedName.Right;

return (IdentifierNameSyntax)name;
Copy link
Member

Choose a reason for hiding this comment

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

This might crash for AliasQualifiedNameSyntax or GenericNameSyntax

Copy link
Member

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

@NewellClark - thank you for putting the efforts here and creating this PR, it is much appreciated.
However, I believe we need to root cause the performance issue before taking this path. We definitely want analyzer authors to be able to write performant IOperation analyzers when analyzing executable code. I have added a comment in the original issue to help us move forward with the performance investigations.

@sharwell
Copy link
Member

💡 We should now be able to use IAttributeOperation for this.

@Youssef1313
Copy link
Member

💡 We should now be able to use IAttributeOperation for this.

This might not work for local functions I think (assuming the original implementation works for local functions)

@sharwell
Copy link
Member

I would expect it to work for local functions?

@Youssef1313
Copy link
Member

Youssef1313 commented Jun 30, 2023

I would expect it to work for local functions?

@sharwell context.ContainingSymbol will return regular method, IIRC. Unless something has changed since I last looked?

@sharwell
Copy link
Member

@Youssef1313 it seems like that would not be problematic. The handling will differ slightly for different contexts where this can occur, but in all cases it should be workable.

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

Successfully merging this pull request may close these issues.

CA1041 performance
4 participants