提交 162cd0b2 编写于 作者: S shyamn

Implement IEquatable<ISuggestedActions> for all Roslyn ISuggestedActions. The...

Implement IEquatable<ISuggestedActions> for all Roslyn ISuggestedActions. The implementation treats any SuggestedActions that have the same provider as well as CodeActions with equal non-null 'Id's as equivalent.

Also override 'Id 'for
CodeActions of the following code fixes to reduce the occurence of duplicate fixes in the lightbulb menu - Add Imports, Generate Type and  Generate Property / Field.

Note: Addressing the above three code fixes takes care of the most common cases where users currently see duplicate fixes in the light bulb menu. We can apply similar de-duping for several other code fixes but we will address them separately later.

Also fixing a couple of other problems discovered while testing this fix -

1. The 'implement interface' code fix provider was using same Id for the simple 'implement interface' code action as well as the 'implement dispose pattern' code action causing the latter to be filtered out. This was also causing problems during 'fix all occurrences'. Fixed this by including the type name of the code action in its Id.

2. When invoking SuggestedActionSet constructor, we were passing in linq queries that would construct new SuggestedActions in a couple of places. The platform implementation for SuggestedActionSet would store this query directly in a field and end up returning a new set of SuggestedActions each time the field was accssed. This ended up causing problems when the platform code tried to de-dupe the fixes (because different fixes would be returned each time). I have changed Roslyn-side code to pass in ImmutableArrays instead - but platform (Oleg) is also fixing the platfrom code to be more robust for this issue. (changeset 1396084)
上级 f0afeb65
......@@ -27,6 +27,16 @@ public abstract partial class CodeAction
/// An optional Id for the code action.
/// If non-null, then this Id must be unique amongst all the code actions produced by the corresponding <see cref="CodeFixProvider"/> or <see cref="CodeRefactoringProvider"/>.
/// </summary>
/// <remarks>
/// The Id of a code action is used to determine equivalence / uniqueness. For instance, if multiple code actions
/// with the same Id are returned from a code fix or code refactoring provider, Visual Studio's light bulb UI
/// will present only one of these 'equivalent' code actions to the end user.
///
/// Also, if a code fix provider supports 'fix all occurences', and if the end user selects to fix all occurences
/// (in a document, project or solution) of a particular issue addressed by this provider, then the Id of the code
/// action returned by this provider is used to compute the 'equivalent' code actions that should be applied at
/// other locations in the end user's document, project or solution in order to fix all occurences of the issue.
/// </remarks>
public virtual string Id { get { return null; } }
/// <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册