Feature request: add markup to specify supressed/unsuppressed diagnostics
DoctorKrolic opened this issue · 0 comments
DoctorKrolic commented
Right now in order to test diagnostic suppressor it is required to use code instead of more visual markup. It might be a good thing to add a pair of markup rules to express this directly there instead of having to dive into code. Therefore I suggest the following:
- if a named span ends with
?
treat it as suppressed diagnostic name - if a named span ends with
!
verify that this diagnostic is not suppressed
Consider the following example:
[Fact]
public async Task Test1()
{
var source = """
class C
{
public string {|#0:Prop|} { get; set; }
public string {|#1:OtherProp|} { get; set; }
}
""";
await new MyAnalyzerVerifier<MySuppressor>.Test
{
TestCode = source,
ExpectedDiagnostics =
{
DiagnosticResult.CompilerWarning("CS8618").WithLocation(0).WithLocation(0).WithIsSuppressed(true)
DiagnosticResult.CompilerWarning("CS8618").WithLocation(1).WithLocation(1).WithIsSuppressed(false)
},
CompilerDiagnostics = CompilerDiagnostics.Warnings
}.RunAsync();
}
Using proposed rules this test can be simplified to:
[Fact]
public async Task Test1()
{
var source = """
class C
{
public string {|CS8618?:Prop|} { get; set; }
public string {|CS8618!:OtherProp|} { get; set; }
}
""";
await new MyAnalyzerVerifier<MySuppressor>.Test
{
TestCode = source,
CompilerDiagnostics = CompilerDiagnostics.Warnings
}.RunAsync();
}
Not a big deal, just a little quality of life thing.