Skip to content

Commit ed1e0ab

Browse files
authored
Add ParamCollectionAttribute (#99385)
* Add ParamCollectionAttribute In support of new C# params collection feature * Update System.Runtime.cs
1 parent 8330db9 commit ed1e0ab

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@
874874
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\NullableContextAttribute.cs" />
875875
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\NullablePublicOnlyAttribute.cs" />
876876
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ReferenceAssemblyAttribute.cs" />
877+
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\ParamCollectionAttribute.cs" />
877878
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilder.cs" />
878879
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs" />
879880
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\PreserveBaseOverridesAttribute.cs" />
@@ -2762,4 +2763,4 @@
27622763
<Compile Include="$(MSBuildThisFileDirectory)System\Numerics\IUnaryPlusOperators.cs" />
27632764
<Compile Include="$(MSBuildThisFileDirectory)System\Numerics\IUnsignedNumber.cs" />
27642765
</ItemGroup>
2765-
</Project>
2766+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace System.Runtime.CompilerServices
5+
{
6+
/// <summary>
7+
/// Indicates that a method will allow a variable number of arguments in its invocation.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
10+
public sealed class ParamCollectionAttribute : Attribute
11+
{
12+
}
13+
}

src/libraries/System.Runtime/ref/System.Runtime.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13059,6 +13059,11 @@ public sealed partial class NullablePublicOnlyAttribute : System.Attribute
1305913059
public readonly bool IncludesInternals;
1306013060
public NullablePublicOnlyAttribute(bool value) { }
1306113061
}
13062+
[System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
13063+
public sealed partial class ParamCollectionAttribute : System.Attribute
13064+
{
13065+
public ParamCollectionAttribute() { }
13066+
}
1306213067
public partial struct PoolingAsyncValueTaskMethodBuilder
1306313068
{
1306413069
private object _dummy;

src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
<Compile Include="System\Runtime\CompilerServices\DefaultInterpolatedStringHandlerTests.cs" />
269269
<Compile Include="System\Runtime\CompilerServices\FormattableStringFactoryTests.cs" />
270270
<Compile Include="System\Runtime\CompilerServices\StrongBoxTests.cs" />
271+
<Compile Include="System\Runtime\CompilerServices\ParamCollectionAttributeTests.cs" />
271272
<Compile Include="System\Runtime\CompilerServices\RuntimeHelpersTests.cs" />
272273
<Compile Include="System\Runtime\ConstrainedExecution\PrePrepareMethodAttributeTests.cs" />
273274
<Compile Include="System\Runtime\ExceptionServices\HandleProcessCorruptedStateExceptions.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Xunit;
5+
6+
namespace System.Runtime.CompilerServices.Tests
7+
{
8+
public static class ParamCollectionAttributeTests
9+
{
10+
[Fact]
11+
public static void Ctor()
12+
{
13+
var attribute = new ParamCollectionAttribute();
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)