未验证 提交 ddea05f3 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #31473 from jhinder/fix/pragma-warning-classifier

Fix classification for comments after "#pragma warning" directives
......@@ -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()
{
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册