Repository: dotnet/roslyn
File: src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (C#)

Code before:
                        break;

                    case IPropertySymbol or IFieldSymbol:
                        AddDebuggerDisplayAttributeArgumentsCore(member, builder);
                        break;
                }
            }
        }

        private void AddDebuggerDisplayAttributeArgumentsCore(ISymbol symbol, ArrayBuilder<string> builder)
        {
            foreach (var attribute in symbol.GetAttributes())
            {
                if (attribute.AttributeClass == _debuggerDisplayAttributeType)
                {
                    // Add the constructor argument (Value parameter)
                    if (attribute.ConstructorArguments is [{ Kind: TypedConstantKind.Primitive, Type.SpecialType: SpecialType.System_String, Value: string value }])
                    {
                        builder.Add(value);
                    }

                    // Add the Name and Type named parameters
                    foreach (var namedArgument in attribute.NamedArguments)
                    {
                        if ((namedArgument.Key == "Name" || namedArgument.Key == "Type") &&
                            namedArgument.Value is { Kind: TypedConstantKind.Primitive, Type.SpecialType: SpecialType.System_String, Value: string namedValue })
                        {
                            builder.Add(namedValue);
                        }
                    }
                }
            }
        }

        /// <summary>
        /// Returns true if the given symbol meets the following criteria to be
        /// a candidate for dead code analysis:
        ///     1. It is marked as "private".
        ///     2. It is not an implicitly declared symbol.
        ///     3. It is either a method, field, property or an event.
        ///     4. If method, then it is a constructor OR a method with <see cref="MethodKind.Ordinary"/>,
        ///        such that is meets a few criteria (see implementation details below).
        ///     5. If field, then it must not be a backing field for an auto property.
        ///        Backing fields have a non-null <see cref="IFieldSymbol.AssociatedSymbol"/>.
        ///     6. If property, then it must not be an explicit interface property implementation
        ///        or the 'IsCompleted' property which is needed to make a type awaitable.
        ///     7. If event, then it must not be an explicit interface event implementation.
        /// </summary>
        private bool IsCandidateSymbol([NotNullWhen(true)] ISymbol? memberSymbol)
        {
            if (memberSymbol is null)

Review comment (suggestion):
```suggestion
                        if ((namedArgument is { Key: "Name" or "Type", Value: { Kind: TypedConstantKind.Primitive, Type.SpecialType: SpecialType.System_String, Value: string namedValue } })
```

Code after:
                        break;

                    case IPropertySymbol or IFieldSymbol:
                        AddDebuggerDisplayAttributeArgumentsCore(member, builder);
                        break;
                }
            }
        }

        private void AddDebuggerDisplayAttributeArgumentsCore(ISymbol symbol, ArrayBuilder<string> builder)
        {
            foreach (var attribute in symbol.GetAttributes())
            {
                if (attribute.AttributeClass == _debuggerDisplayAttributeType)
                {
                    // Add the constructor argument (Value parameter)
                    if (attribute.ConstructorArguments is [{ Kind: TypedConstantKind.Primitive, Type.SpecialType: SpecialType.System_String, Value: string value }])
                    {
                        builder.Add(value);
                    }

                    // Add the Name and Type named parameters
                    foreach (var namedArgument in attribute.NamedArguments)
                    {
                        if (namedArgument is
                            {
                                Key: "Name" or "Type",
                                Value: { Kind: TypedConstantKind.Primitive, Type.SpecialType: SpecialType.System_String, Value: string namedValue },
                            })
                        {
                            builder.Add(namedValue);
                        }
                    }
                }
            }
        }

        /// <summary>
        /// Returns true if the given symbol meets the following criteria to be
        /// a candidate for dead code analysis:
        ///     1. It is marked as "private".
        ///     2. It is not an implicitly declared symbol.
        ///     3. It is either a method, field, property or an event.
        ///     4. If method, then it is a constructor OR a method with <see cref="MethodKind.Ordinary"/>,
        ///        such that is meets a few criteria (see implementation details below).
        ///     5. If field, then it must not be a backing field for an auto property.
        ///        Backing fields have a non-null <see cref="IFieldSymbol.AssociatedSymbol"/>.
        ///     6. If property, then it must not be an explicit interface property implementation
        ///        or the 'IsCompleted' property which is needed to make a type awaitable.
        ///     7. If event, then it must not be an explicit interface event implementation.
        /// </summary>