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

Add Analyzer and CodeFix for duplicate method aliases (ORLEANS0011) #8662

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

ledjon-behluli
Copy link
Contributor

@ledjon-behluli ledjon-behluli commented Oct 13, 2023

cc @ReubenBond
close #8661

Analyzer:
alias-clash-analyzer

Fixer:
alias-clash-codefix

Tests:
alias-clash-tests

Microsoft Reviewers: Open in CodeFlow

@ledjon-behluli
Copy link
Contributor Author

Note, this PR is based on #8643 (which has not yet been merged), thats why it contains the GenerateAliasAttributesAnalyzer code

@ReubenBond
Copy link
Member

ReubenBond commented Oct 20, 2023

1:
image
2:
image
3:
image
Should this be Echo2 instead of Echo11?

@ledjon-behluli
Copy link
Contributor Author

ledjon-behluli commented Oct 20, 2023

@ReubenBond If "Fix for Document" than yes, it changes to 'Echo1' and 'Echo2'

image

But if you change them 1-by-1 its actually quite the problem, let me explain why:
A "duplicate" is defined only if its the same alias (as in the same text), if we analyzed all other "EchoX" in order to determine the 'X' its going to get very ambiguous what really is a "Echo".

image

Thats why if the user applies the code fix for the document, and there are multiple "Echo"s it will go 1, 2, 3. But if the above is true, than we look the only "true" duplicate which would be "Echo" and assign the next number which would be "Echo1"

image

We need to always think that the user's may always name the alias themselves i.e: Echo_, Echo__, Echo_1 ...
I hope I make sense here

@ReubenBond
Copy link
Member

In your example, I would expect the result to be "Echo1". If there was a method with the alias "Echo1" already, then I would expect the result to be "Echo2", and so on until there is no conflict. The method name does not matter (the developer could have aliased a method named GetFoo as "Echo" and the result should be the same), but the resulting alias value does.

@ledjon-behluli
Copy link
Contributor Author

"The method name does not matter" - I see what you mean, i'll address it 👍

@ledjon-behluli
Copy link
Contributor Author

@ReubenBond Maybe it makes sense to hold off on approving the other PRs which are based on this (since some common code is shared), until this is resolved and i'll port the change to the other 2 PRs. You could still review and leave comments ofc.

@ledjon-behluli
Copy link
Contributor Author

ledjon-behluli commented Oct 21, 2023

@ReubenBond It should work as expected now! I've ported the fix to the other PRs too, so feel free to continue when you can

@ledjon-behluli
Copy link
Contributor Author

@ReubenBond are we good with this, so we can move onto the other?

@ReubenBond
Copy link
Member

I am tweaking the suffix incrementing code a little, but otherwise LGTM

@ReubenBond
Copy link
Member

@ledjon-behluli if you can rebase, I'm ready to merge.

@ReubenBond
Copy link
Member

@ledjon-behluli I performed a squash merge + force push of your latest, since it included changes from main which made final review harder.

@ReubenBond ReubenBond changed the title ORLEANS0011 Add Analyzer and CodeFix for duplicate method aliases (ORLEANS0011) Jan 9, 2024
@ledjon-behluli
Copy link
Contributor Author

@ReubenBond whatever it takes, stuff got mangled up

@ReubenBond ReubenBond enabled auto-merge (squash) January 9, 2024 18:46
@ReubenBond ReubenBond merged commit c7c08b3 into dotnet:main Jan 9, 2024
16 of 19 checks passed
@ReubenBond
Copy link
Member

Includes #8664 & #8672

@github-actions github-actions bot locked and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ORLEANS0011: Report error on duplicate aliases
2 participants