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

Add a ParamCollection test which uses the attribute included in .NET 9 SDK #74338

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15756,5 +15756,52 @@ static void Main()
var comp = CreateCompilation(source, options: TestOptions.ReleaseExe);
CompileAndVerify(comp, expectedOutput: "2").VerifyDiagnostics();
}

[Fact]
public void AttributeFromSDK()
{
var source = """
using System;

C.M(1, 2, 3);

class C
{
public static void M(params Span<int> span)
{
foreach (var item in span)
Console.Write(item);
}
}
""";

var verifier = CompileAndVerify(
source,
targetFramework: TargetFramework.Net80,
symbolValidator: verify8,
verify: Verification.Skipped,
expectedOutput: ExpectedOutput("123"));
verifier.VerifyDiagnostics();

void verify8(ModuleSymbol module)
{
// attribute is embedded.
Assert.NotNull(module.GlobalNamespace.GetMember("System.Runtime.CompilerServices.ParamCollectionAttribute"));
}

verifier = CompileAndVerify(
source,
targetFramework: TargetFramework.Net90,
symbolValidator: verify9,
verify: Verification.Skipped,
expectedOutput: ExpectedOutput("123"));
verifier.VerifyDiagnostics();

void verify9(ModuleSymbol module)
{
// attribute is not embedded.
Assert.Empty(module.GlobalNamespace.GetMembers("System"));
}
}
}
}