diff --git a/src/PerformanceTests/Tests/Enabled/CSharp_CA1416.cs b/src/PerformanceTests/Tests/Enabled/CSharp_CA1416.cs index 4c64392625..404a5ff307 100644 --- a/src/PerformanceTests/Tests/Enabled/CSharp_CA1416.cs +++ b/src/PerformanceTests/Tests/Enabled/CSharp_CA1416.cs @@ -37,6 +37,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(); + }} + }} +}} ")); } @@ -48,6 +84,8 @@ public class B { [SupportedOSPlatform(""Windows10.1.1.1"")] public void M2() { } + [UnsupportedOSPlatform(""macOS11.0.1"")] + public void M3() {} } }"; sources.Add((nameof(targetTypesForTest), targetTypesForTest)); @@ -79,7 +117,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}'"); }