diff --git a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs index 3ead64c5ce9b71ae287bbfd8b0b0130cf1f6e653..a32ead0ac29a87bbd273a9351d40ad660a805ad9 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Test.Utilities; +using Roslyn.Test.Utilities; using Xunit; using static Microsoft.CodeAnalysis.Editor.UnitTests.Classification.FormattedClassifications; @@ -883,6 +884,20 @@ public async Task PP_PragmaWarningDisableOneWithComment() Comment("//Goo")); } + [Fact, Trait(Traits.Feature, Traits.Features.Classification)] + [WorkItem(30783, "https://github.com/dotnet/roslyn/issues/30783")] + public async Task PP_PragmaWarningDisableAllWithComment() + { + var code = @"#pragma warning disable //Goo"; + + await TestAsync(code, + PPKeyword("#"), + PPKeyword("pragma"), + PPKeyword("warning"), + PPKeyword("disable"), + Comment("//Goo")); + } + [Fact, Trait(Traits.Feature, Traits.Features.Classification)] public async Task PP_PragmaWarningRestoreOne() { @@ -910,6 +925,20 @@ public async Task PP_PragmaWarningRestoreOneWithComment() Comment("//Goo")); } + [Fact, Trait(Traits.Feature, Traits.Features.Classification)] + [WorkItem(30783, "https://github.com/dotnet/roslyn/issues/30783")] + public async Task PP_PragmaWarningRestoreAllWithComment() + { + var code = @"#pragma warning restore //Goo"; + + await TestAsync(code, + PPKeyword("#"), + PPKeyword("pragma"), + PPKeyword("warning"), + PPKeyword("restore"), + Comment("//Goo")); + } + [Fact, Trait(Traits.Feature, Traits.Features.Classification)] public async Task PP_PragmaWarningDisableTwo() { diff --git a/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs b/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs index 3f20f8f301be65234192ae2cee50e3069b4cfc47..b738bf602d58d2fd7e975bf9d5ba24a19fe2e533 100644 --- a/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs +++ b/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs @@ -270,6 +270,13 @@ private void ClassifyPragmaWarningDirective(PragmaWarningDirectiveTriviaSyntax n { ClassifyNodeOrToken(nodeOrToken); } + + if (node.ErrorCodes.Count == 0) + { + // When there are no error codes, we need to classify the directive's trivia. + // (When there are error codes, ClassifyNodeOrToken above takes care of that.) + ClassifyDirectiveTrivia(node); + } } private void ClassifyReferenceDirective(ReferenceDirectiveTriviaSyntax node)