public static async Task ComputeRefactoringAsync(RefactoringContext context, AttributeSyntax attribute) { if (attribute.ArgumentList?.Arguments.Count(f => f.NameEquals == null) != 1) { return; } if (!attribute.IsParentKind(SyntaxKind.AttributeList)) { return; } if (!attribute.Parent.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration)) { return; } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); string value = semanticModel .GetDeclaredSymbol((TypeDeclarationSyntax)attribute.Parent.Parent, context.CancellationToken) .GetAttribute(MetadataNames.System_Diagnostics_DebuggerDisplayAttribute)? .ConstructorArguments .SingleOrDefault(shouldThrow: false) .Value? .ToString(); if (value == null) { return; } if (string.Equals(value, $"{{{DefaultNames.DebuggerDisplayPropertyName},nq}}", StringComparison.Ordinal)) { return; } if (!CanRefactor(value)) { return; } context.RegisterRefactoring( $"Generate property '{DefaultNames.DebuggerDisplayPropertyName}'", cancellationToken => RefactorAsync(context.Document, attribute, cancellationToken), RefactoringIdentifiers.GeneratePropertyForDebuggerDisplayAttribute); }