Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use manual foreach instead of AddRange method for certain collection expression spreads #74630

Merged
merged 9 commits into from
Aug 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -34722,7 +34722,18 @@ static void Main()
}
""";

var verifier = CompileAndVerify([source, s_collectionExtensions], expectedOutput: "[1, 2, 3],", targetFramework: targetFramework, verify: Verification.Skipped);
var expectedOutputString = "[1, 2, 3],";
var verifier = CompileAndVerify(
[source, s_collectionExtensions],
expectedOutput: targetFramework switch
{
TargetFramework.Net80 => IncludeExpectedOutput(expectedOutputString),
TargetFramework.Standard => expectedOutputString,
_ => throw new InvalidOperationException("Update expected output!"),
},
targetFramework: targetFramework,
verify: Verification.Skipped);

verifier.VerifyDiagnostics();

switch (targetFramework)
Expand Down Expand Up @@ -34806,6 +34817,8 @@ .locals init (MyCollection V_0)
}
""");
break;
default:
throw new InvalidOperationException("Update verified IL!");
}
}

Expand Down Expand Up @@ -35117,7 +35130,18 @@ static void Main()
}
""";

var verifier = CompileAndVerify([source, s_collectionExtensions], expectedOutput: "[1, 2, 3],", targetFramework: targetFramework, verify: Verification.Skipped);
var expectedOutputString = "[1, 2, 3],";
var verifier = CompileAndVerify(
[source, s_collectionExtensions],
expectedOutput: targetFramework switch
{
TargetFramework.Net80 => IncludeExpectedOutput(expectedOutputString),
TargetFramework.Standard => expectedOutputString,
_ => throw new InvalidOperationException("Update expected output!"),
},
targetFramework: targetFramework,
verify: Verification.Skipped);

verifier.VerifyDiagnostics();

switch (targetFramework)
Expand Down Expand Up @@ -35200,6 +35224,8 @@ .locals init (MyCollection V_0)
}
""");
break;
default:
throw new InvalidOperationException("Update verified IL!");
}
}

Expand Down
Loading