Skip to content

Commit

Permalink
Merge pull request #5319 from buyaa-n/add_regression_test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarolf committed Oct 20, 2021
2 parents d581cc4 + a9bd453 commit 428861b
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 @@ -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();
}}
}}
}}
"));
}

Expand All @@ -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));
Expand Down Expand Up @@ -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}'");
}
Expand Down

0 comments on commit 428861b

Please sign in to comment.