Skip to content

Commit

Permalink
Add more scenarios into CA1416 regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
buyaa-n committed Jul 28, 2021
1 parent 92cc133 commit a9bd453
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/PerformanceTests/Tests/Enabled/CSharp_CA1416.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,42 @@ public void M1()
field.M2();
}}
}}
"));
name += "Unsupported";
sources.Add((name + "Unsupport", @$"
using System;
using PlatformCompatDemo.SupportedUnupported;
class {name}
{{
private B field = new B();
public void M1()
{{
field.M3();
}}
}}
"));

name += "Flow";
sources.Add((name, @$"
using System;
using PlatformCompatDemo.SupportedUnupported;
class {name}
{{
private B field = new B();
public void M1()
{{
if (OperatingSystem.IsWindowsVersionAtLeast(10, 2))
{{
field.M2();
}}
else
{{
field.M2();
}}
}}
}}
"));
}

Expand All @@ -46,6 +82,8 @@ public class B
{
[SupportedOSPlatform(""Windows10.1.1.1"")]
public void M2() { }
[UnsupportedOSPlatform(""macOS11.0.1"")]
public void M3() {}
}
}";
sources.Add((nameof(targetTypesForTest), targetTypesForTest));
Expand Down Expand Up @@ -77,7 +115,7 @@ public async Task CA1416_DiagnosticsProduced()
throw new InvalidOperationException($"Expected no compilation diagnostics but found '{analysisResult.CompilationDiagnostics.Count}'");
}

if (diagnostics.Length != 1 * Constants.Number_Of_Code_Files)
if (diagnostics.Length != 3 * Constants.Number_Of_Code_Files)
{
throw new InvalidOperationException($"Expected '{1 * Constants.Number_Of_Code_Files:N0}' analyzer diagnostics but found '{diagnostics.Length}'");
}
Expand Down

0 comments on commit a9bd453

Please sign in to comment.