Support CodeAction.NestedActions via light-up

Closes #1136
This commit is contained in:
Sam Harwell 2023-12-19 08:43:17 -06:00
Родитель 8c5ae6fcf7
Коммит 0aa8da7d5f
2 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -164,7 +164,7 @@ namespace Microsoft.CodeAnalysis.Testing
for (var i = builder.Count - 1; i >= 0; i--)
{
var action = builder[i];
var nestedActions = action.NestedCodeActions();
var nestedActions = action.NestedActions();
if (!nestedActions.IsEmpty)
{
builder.RemoveAt(i);

Просмотреть файл

@ -11,13 +11,29 @@ namespace Microsoft.CodeAnalysis.Testing
{
internal static class CodeActionExtensions
{
private static readonly Func<CodeAction, ImmutableArray<CodeAction>> s_nestedActions =
LightupHelpers.CreatePropertyAccessor<CodeAction, ImmutableArray<CodeAction>>(
typeof(CodeAction),
nameof(NestedActions),
defaultValue: default);
private static readonly Func<CodeAction, ImmutableArray<CodeAction>> s_nestedCodeActions =
LightupHelpers.CreatePropertyAccessor<CodeAction, ImmutableArray<CodeAction>>(
typeof(CodeAction),
nameof(NestedCodeActions),
"NestedCodeActions",
defaultValue: ImmutableArray<CodeAction>.Empty);
public static ImmutableArray<CodeAction> NestedCodeActions(this CodeAction action)
=> s_nestedCodeActions(action);
public static ImmutableArray<CodeAction> NestedActions(this CodeAction action)
{
// CodeAction.NestedCodeActions was renamed to CodeAction.NestedActions in
// https://github.com/dotnet/roslyn/pull/71327
var nestedActions = s_nestedActions(action);
if (nestedActions.IsDefault)
{
nestedActions = s_nestedCodeActions(action);
}
return nestedActions;
}
}
}