diff --git a/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs b/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs index 6961ca3793e0c..fab99c5a9ce45 100644 --- a/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs +++ b/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs @@ -1333,6 +1333,8 @@ await TestInRegularAndScriptAsync( [InlineData("_")] [InlineData("_1")] [InlineData("_123")] + [InlineData("__")] + [InlineData("___")] public async Task TestDiscardParameterAsync(string identifier) { await TestMissingInRegularAndScriptAsync( @@ -1348,6 +1350,8 @@ void M(int [|{identifier}|]) [InlineData("_")] [InlineData("_1")] [InlineData("_123")] + [InlineData("__")] + [InlineData("___")] public async Task TestDiscardLocalAsync(string identifier) { await TestMissingInRegularAndScriptAsync( diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs index 68fa8d01fbfec..38fad72af3ed2 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs @@ -726,12 +726,12 @@ public static bool IsKind(this ISymbol symbol, SymbolKind kind, [NotNul /// /// Returns true for symbols whose name starts with an underscore and - /// are optionally followed by an integer, such as '_', '_1', '_2', etc. + /// are optionally followed by an integer or other underscores, such as '_', '_1', '_2', '__', '___', etc. /// These are treated as special discard symbol names. /// public static bool IsSymbolWithSpecialDiscardName(this ISymbol symbol) => symbol.Name.StartsWith("_") && - (symbol.Name.Length == 1 || uint.TryParse(symbol.Name[1..], out _)); + (symbol.Name.Length == 1 || uint.TryParse(symbol.Name[1..], out _) || symbol.Name.All(n => n.Equals('_'))); /// /// Returns , if the symbol is marked with the .