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 code action equivalence key validation in test framework #44728

Merged
merged 10 commits into from
Jun 2, 2020

Conversation

mavasani
Copy link
Contributor

Fixes #44553

@mavasani mavasani requested a review from CyrusNajmabadi May 30, 2020 22:05
@mavasani mavasani requested a review from a team as a code owner May 30, 2020 22:05
@mavasani
Copy link
Contributor Author

@CyrusNajmabadi I will create a separate PR to loosen the de-dupe logic added in #41768 for back compat to allow same provider to register different code actions with different title and same equivalence key. The test framework check added in this PR should help catch our fixers/refactorings from doing so.

@sharwell
Copy link
Member

@mavasani For this pull request, I am only expecting changes to equivalence keys for code actions that must change or else they will not work. Changes beyond that can produce subtle changes in the observed behavior which will be difficult to understand during the review.

@mavasani mavasani force-pushed the AddCodeActionValidation branch from 6c6173e to 6d68dce Compare June 1, 2020 12:51
@mavasani
Copy link
Contributor Author

mavasani commented Jun 1, 2020

@sharwell @CyrusNajmabadi - I have rebased the PR to add minimal test framework validation:

  1. Only validate equivalence key uniqueness for code actions registered by code fixers that support FixAll - this is the only real use case that gets affected by equivalence keys today (modulo the fix to relax the CodeFixService de-dupe logic, which I will create a separate PR)
  2. Revert validation for refactorings to require unique, non-null equivalence keys - this is not required until refactorings start supporting FixAll.
  3. For any test failures after my rebase, if any, I will do targeted fixes for code fixers that are affected by this.

I will mark the PR for re-review once it is ready.

@sharwell
Copy link
Member

sharwell commented Jun 1, 2020

Only validate equivalence key uniqueness for code actions registered by code fixers that support FixAll

It should also only apply to cases that register more than one action.

Also, when more than one action is registered, is it a problem for the code fix driver if exactly one of those is null?

@mavasani
Copy link
Contributor Author

mavasani commented Jun 1, 2020

It should also only apply to cases that register more than one action.

Yes, the current validation only asserts when the fixer has more then one registered code action, such that the code actions use different title, but same equivalence key.

Also, when more than one action is registered, is it a problem for the code fix driver if exactly one of those is null?

No, the code fix service and fix all work fine for such a case. The validation method doesn't assert for this scenario.

@mavasani
Copy link
Contributor Author

mavasani commented Jun 1, 2020

This PR is now ready for review.

@CyrusNajmabadi The only remaining 3 test failures are legitimate failures in Implement interface code fixer, when implementing through a member. I believe the following method needs to be fixed, but I am not sure what is the correct fix. Can you please checkout this PR branch and push a correct fix? Thanks!

private static string GetCodeActionEquivalenceKey(
string interfaceTypeAssemblyName,
string interfaceTypeFullyQualifiedName,
bool explicitly,
bool abstractly,
bool onlyRemaining,
ISymbol throughMember,
string codeActionTypeName)
{
if (throughMember != null)
{
return null;
}
return explicitly.ToString() + ";" +
abstractly.ToString() + ";" +
onlyRemaining.ToString() + ":" +
interfaceTypeAssemblyName + ";" +
interfaceTypeFullyQualifiedName + ";" +
codeActionTypeName;
}

@sharwell
Copy link
Member

sharwell commented Jun 1, 2020

I'm much happier with this narrower scoping, particularly in how it clearly reveals the feature(s) that were impacted by this bug.

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi The only remaining 3 test failures are legitimate failures in Implement interface code fixer, when implementing through a member.

I have no idea why implement interface would need a fix-all :-/

but i'll take a look to see if i can figure out waht's going on here.

@mavasani
Copy link
Contributor Author

mavasani commented Jun 1, 2020

I have no idea why implement interface would need a fix-all :-/

It would then be easy to just ensure we pass in false here and the tests should pass:

protected SyntaxEditorBasedCodeFixProvider(bool supportsFixAll = true)

@sharwell
Copy link
Member

sharwell commented Jun 1, 2020

It would then be easy to just ensure we pass in false here and the tests should pass:

👍

@CyrusNajmabadi
Copy link
Member

I'm going to bring the implement interface issue to design meeting today.

@mavasani
Copy link
Contributor Author

mavasani commented Jun 1, 2020

@CyrusNajmabadi there still seems to be a failing test in implement interface. Can you please take a look?

@CyrusNajmabadi
Copy link
Member

looking!

@mavasani
Copy link
Contributor Author

mavasani commented Jun 2, 2020

Thanks @CyrusNajmabadi!

@mavasani mavasani merged commit 6ce8ded into dotnet:master Jun 2, 2020
@ghost ghost added this to the Next milestone Jun 2, 2020
@mavasani mavasani deleted the AddCodeActionValidation branch June 2, 2020 13:10
@RikkiGibson RikkiGibson modified the milestones: Next, 16.7.P3 Jun 8, 2020
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.

CodeAction testing infrastructure does not behave hte same as VS wrt EquivalenceKey
4 participants