Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UnifiedSuggestions.UnifiedSuggestedActions;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.UnifiedSuggestions.UnifiedSuggestedActions;
using Microsoft.VisualStudio.Language.Intellisense;
Expand Down Expand Up @@ -58,7 +58,7 @@ public override bool TryGetTelemetryId(out Guid telemetryId)
// We get the telemetry id for the original code action we are fixing,
// not the special 'FixAllCodeAction'. that is the .CodeAction this
// SuggestedAction is pointing at.
telemetryId = OriginalCodeAction.GetType().GetTelemetryId(FixAllState.Scope.GetScopeIdForTelemetry());
telemetryId = OriginalCodeAction.GetTelemetryId(FixAllState.Scope);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Extensions;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
Expand Down Expand Up @@ -67,7 +67,7 @@ internal SuggestedAction(

public virtual bool TryGetTelemetryId(out Guid telemetryId)
{
telemetryId = CodeAction.GetType().GetTelemetryId();
telemetryId = CodeAction.GetTelemetryId();
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private static CodeAction GetNestedActionsFromActionSet(IUnifiedSuggestedAction
}
}

return new CodeActionWithNestedActions(
return CodeActionWithNestedActions.Create(
codeAction.Title, nestedActions.ToImmutable(), codeAction.IsInlinable, codeAction.Priority);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex
c => ChangeImplementationAsync(project, implementedMembersFromAllInterfaces, c)));
}

context.RegisterRefactoring(new CodeAction.CodeActionWithNestedActions(
context.RegisterRefactoring(CodeAction.CodeActionWithNestedActions.Create(
Implement, nestedActions.ToImmutableAndFree(), isInlinable: true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ private static ImmutableArray<CodeAction> GetGroupedActions(AddConstructorParame
{
if (!result.RequiredParameterActions.IsDefaultOrEmpty)
{
actions.Add(new CodeAction.CodeActionWithNestedActions(
actions.Add(CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Add_parameter_to_constructor,
result.RequiredParameterActions.Cast<AddConstructorParametersCodeAction, CodeAction>(),
isInlinable: false));
}

actions.Add(new CodeAction.CodeActionWithNestedActions(
actions.Add(CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Add_optional_parameter_to_constructor,
result.OptionalParameterActions.Cast<AddConstructorParametersCodeAction, CodeAction>(),
isInlinable: false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected override async Task<IEnumerable<CodeActionOperation>> ComputePreviewOp
{
// Make a SolutionChangeAction. This way we can let it generate the diff
// preview appropriately.
var solutionChangeAction = new SolutionChangeAction("", c => GetUpdatedSolutionAsync(c), "");
var solutionChangeAction = SolutionChangeAction.Create("", c => GetUpdatedSolutionAsync(c), "");

using var _ = ArrayBuilder<CodeActionOperation>.GetInstance(out var result);
result.AddRange(await solutionChangeAction.GetPreviewOperationsAsync(cancellationToken).ConfigureAwait(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ImmutableArray<CodeAction> NestByOverload()
var titleForNesting = GetCodeFixTitle(FeaturesResources.Add_parameter_to_0, data.Method, includeParameters: true);
var titleCascading = GetCodeFixTitle(FeaturesResources.Add_parameter_to_0_and_overrides_implementations, data.Method,
includeParameters: true);
codeAction = new CodeAction.CodeActionWithNestedActions(
codeAction = CodeAction.CodeActionWithNestedActions.Create(
title: titleForNesting,
ImmutableArray.Create(
codeAction,
Expand Down Expand Up @@ -297,14 +297,14 @@ ImmutableArray<CodeAction> NestByCascading()

// Create a sub-menu entry with all the non-cascading CodeActions.
// We make sure the IDE does not inline. Otherwise the context menu gets flooded with our fixes.
builder.Add(new CodeAction.CodeActionWithNestedActions(nestedNonCascadingTitle, nonCascadingActions, isInlinable: false));
builder.Add(CodeAction.CodeActionWithNestedActions.Create(nestedNonCascadingTitle, nonCascadingActions, isInlinable: false));

if (cascadingActions.Length > 0)
{
// if there are cascading CodeActions create a second sub-menu.
var nestedCascadingTitle = GetCodeFixTitle(FeaturesResources.Add_parameter_to_0_and_overrides_implementations,
aMethod, includeParameters: false);
builder.Add(new CodeAction.CodeActionWithNestedActions(nestedCascadingTitle, cascadingActions, isInlinable: false));
builder.Add(CodeAction.CodeActionWithNestedActions.Create(nestedCascadingTitle, cascadingActions, isInlinable: false));
}

return builder.ToImmutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
}

var groupingTitle = string.Format(FeaturesResources.Alias_ambiguous_type_0, diagnosticNode.ToString());
var groupingCodeAction = new CodeActionWithNestedActions(groupingTitle, codeActionsBuilder.ToImmutable(), isInlinable: true);
var groupingCodeAction = CodeActionWithNestedActions.Create(groupingTitle, codeActionsBuilder.ToImmutable(), isInlinable: true);
context.RegisterCodeFix(groupingCodeAction, context.Diagnostics.First());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)

ReportTelemetryIfNecessary(potentialConversionTypes);

context.RegisterCodeFix(new CodeAction.CodeActionWithNestedActions(
context.RegisterCodeFix(CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Add_explicit_cast,
actions.ToImmutable(), isInlinable: false),
context.Diagnostics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void AddCodeActionWithOptionValue(ICodeStyleOption codeStyleOption, object newVa

// Add code action to configure the optionValue.
nestedActions.Add(
new SolutionChangeAction(
SolutionChangeAction.Create(
parts.optionValue,
solution => ConfigurationUpdater.ConfigureCodeStyleOptionAsync(parts.optionName, parts.optionValue, diagnostic, isPerLanguage, project, cancellationToken),
parts.optionValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static ImmutableArray<CodeFix> GetConfigurations(Project project, IEnume
foreach (var (value, title) in s_editorConfigSeverityStrings)
{
nestedActions.Add(
new SolutionChangeAction(
SolutionChangeAction.Create(
title,
solution => ConfigurationUpdater.ConfigureSeverityAsync(value, diagnostic, project, cancellationToken),
value));
Expand Down Expand Up @@ -101,7 +101,7 @@ void AddBulkConfigurationCodeFixes(ImmutableArray<Diagnostic> diagnostics, strin
foreach (var (value, title) in s_editorConfigSeverityStrings)
{
nestedActions.Add(
new SolutionChangeAction(
SolutionChangeAction.Create(
title,
solution => category != null
? ConfigurationUpdater.BulkConfigureSeverityAsync(value, category, project, cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected virtual Task AddProjectFixesAsync(
if (newSolution != null && newSolution != solution)
{
var title = GetFixAllTitle(fixAllState);
return new CodeAction.SolutionChangeAction(title, _ => Task.FromResult(newSolution), title);
return CodeAction.SolutionChangeAction.Create(title, _ => Task.FromResult(newSolution), title);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public async Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(
// Add the Refactoring Provider Name to the parent CodeAction's CustomTags.
// Always add a name even in cases of 3rd party refactorings that do not export
// name metadata.
action.AddCustomTag(providerMetadata?.Name ?? provider.GetTypeDisplayName());
action.AddCustomTagAndTelemetryInfo(providerMetadata, provider);

actions.Add((action, applicableToSpan));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
// anonymous type, and one to fixup all anonymous types.
if (allAnonymousNodes.Any(t => !anonymousType.Equals(t.symbol, SymbolEqualityComparer.Default)))
{
context.RegisterRefactoring(new CodeAction.CodeActionWithNestedActions(
context.RegisterRefactoring(CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Convert_to_tuple,
ImmutableArray.Create<CodeAction>(
new MyCodeAction(FeaturesResources.just_this_anonymous_type, c => FixInCurrentMemberAsync(document, anonymousNode, anonymousType, allAnonymousTypes: false, c)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
if (recordChildActions.Length > 0)
{
context.RegisterRefactoring(
new CodeAction.CodeActionWithNestedActions(
CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Convert_to_record_struct,
recordChildActions,
isInlinable: false),
Expand All @@ -105,7 +105,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
if (childActions.Length > 0)
{
context.RegisterRefactoring(
new CodeAction.CodeActionWithNestedActions(
CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Convert_to_struct,
childActions,
isInlinable: false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
nameof(FeaturesResources.Generate_for_0) + "_" + displayString));
}

context.RegisterRefactoring(new CodeAction.CodeActionWithNestedActions(
context.RegisterRefactoring(CodeAction.CodeActionWithNestedActions.Create(
FeaturesResources.Generate_comparison_operators,
nestedActions.ToImmutable(),
isInlinable: false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
callerDeclarationNode,
inlineExpression, invocationOperation);

var nestedCodeAction = new CodeAction.CodeActionWithNestedActions(
var nestedCodeAction = CodeAction.CodeActionWithNestedActions.Create(
string.Format(FeaturesResources.Inline_0, calleeMethodSymbol.ToNameDisplayString()),
codeActions,
isInlinable: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex

if (actions.Value.actions.Length > 0)
{
context.RegisterRefactoring(new CodeActionWithNestedActions(
context.RegisterRefactoring(CodeActionWithNestedActions.Create(
string.Format(FeaturesResources.Introduce_parameter_for_0, nodeString), actions.Value.actions, isInlinable: false, priority: CodeActionPriority.Low), textSpan);
}

if (actions.Value.actionsAllOccurrences.Length > 0)
{
context.RegisterRefactoring(new CodeActionWithNestedActions(
context.RegisterRefactoring(CodeActionWithNestedActions.Create(
string.Format(FeaturesResources.Introduce_parameter_for_all_occurrences_of_0, nodeString), actions.Value.actionsAllOccurrences, isInlinable: false,
priority: CodeActionPriority.Low), textSpan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task<CodeAction> IntroduceVariableAsync(
// the code action as 'inlinable' so that if the lightbulb is not cluttered
// then the nested items can just be lifted into it, giving the user fast
// access to them.
return new CodeActionWithNestedActions(title, actions, isInlinable: true);
return CodeActionWithNestedActions.Create(title, actions, isInlinable: true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
.WhereNotNull().Concat(new PullMemberUpWithDialogCodeAction(document, selectedMember, _service))
.ToImmutableArray();

var nestedCodeAction = new CodeActionWithNestedActions(
var nestedCodeAction = CodeActionWithNestedActions.Create(
string.Format(FeaturesResources.Pull_0_up, selectedMember.ToNameDisplayString()),
allActions, isInlinable: true);
context.RegisterRefactoring(nestedCodeAction, selectedMemberNode.Span);
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Core/Portable/PullMemberUp/MembersPuller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static CodeAction TryComputeCodeAction(
}

var title = string.Format(FeaturesResources.Pull_0_up_to_1, selectedMember.Name, result.Destination.Name);
return new SolutionChangeAction(
return SolutionChangeAction.Create(
title,
cancellationToken => PullMembersUpAsync(document, result, cancellationToken),
title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public async Task<ImmutableArray<CodeAction>> GetTopLevelCodeActionsAsync()
// Make our code action low priority. This option will be offered *a lot*, and
// much of the time will not be something the user particularly wants to do.
// It should be offered after all other normal refactorings.
result.Add(new CodeActionWithNestedActions(
result.Add(CodeActionWithNestedActions.Create(
wrappingActions[0].ParentTitle, sorted,
group.IsInlinable, CodeActionPriority.Low));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private static async Task<ImmutableArray<CodeFix>> GetCodeFixesAsync(
// Add the CodeFix Provider Name to the parent CodeAction's CustomTags.
// Always add a name even in cases of 3rd party fixers that do not export
// name metadata.
action.AddCustomTag(fixerMetadata?.Name ?? fixer.GetTypeDisplayName());
action.AddCustomTagAndTelemetryInfo(fixerMetadata, fixer);

fixes.Add(new CodeFix(document.Project, action, applicableDiagnostics));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private static ImmutableArray<UnifiedSuggestedActionSet> PrioritizeFixGroups(
{
// Wrap the suppression/configuration actions within another top level suggested action
// to avoid clutter in the light bulb menu.
var suppressOrConfigureCodeAction = new NoChangeAction(CodeFixesResources.Suppress_or_Configure_issues, nameof(CodeFixesResources.Suppress_or_Configure_issues));
var suppressOrConfigureCodeAction = NoChangeAction.Create(CodeFixesResources.Suppress_or_Configure_issues, nameof(CodeFixesResources.Suppress_or_Configure_issues));
var wrappingSuggestedAction = new UnifiedSuggestedActionWithNestedActions(
workspace, codeAction: suppressOrConfigureCodeAction,
codeActionPriority: suppressOrConfigureCodeAction.Priority, provider: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\InterpolatedStringHandlerArgumentAttribute.cs" Link="Utilities\InterpolatedStringHandlerArgumentAttribute.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\InterpolatedStringHandlerAttribute.cs" Link="Utilities\InterpolatedStringHandlerAttribute.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\NullableAttributes.cs" Link="Utilities\NullableAttributes.cs" />
<Compile Include="..\..\EditorFeatures\Core\Shared\Extensions\TelemetryExtensions.cs" Link="Utilities\TelemetryExtensions.cs" />
<Compile Include="..\..\Workspaces\Core\Portable\Shared\Extensions\TelemetryExtensions.cs" Link="Utilities\TelemetryExtensions.cs" />
<Compile Include="..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\EditorConfigSeverityStrings.cs" Link="Utilities\EditorConfigSeverityStrings.cs" />
<Compile Include="..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\DiagnosticDescriptorExtensions.cs" Link="Utilities\DiagnosticDescriptorExtensions.cs" />
<Compile Include="..\..\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Contract.cs" Link="Utilities\Contract.cs" />
Expand Down
Loading