Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -34722,7 +34722,18 @@ static void Main()
}
""";
DoctorKrolic marked this conversation as resolved.
Show resolved Hide resolved

var verifier = CompileAndVerify([source, s_collectionExtensions], expectedOutput: "[1, 2, 3],", targetFramework: targetFramework, verify: Verification.Skipped);
var expectedOutputString = "[1, 2, 3],";
DoctorKrolic marked this conversation as resolved.
Show resolved Hide resolved
var verifier = CompileAndVerify(
[source, s_collectionExtensions],
expectedOutput: targetFramework switch
DoctorKrolic marked this conversation as resolved.
Show resolved Hide resolved
{
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