Skip to content
Merged
Show file tree
Hide file tree
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 @@ -857,6 +857,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IntrinsicAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsByRefLikeAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InlineArray.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InlineArrayAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsConst.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsExternalInit.cs" />
Expand Down Expand Up @@ -2790,4 +2791,4 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Wasi\WasiPollWorld.wit.imports.wasi.io.v0_2_0.IPoll.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Wasi\WasiPollWorld.wit.imports.wasi.io.v0_2_0.PollInterop.cs" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Runtime.CompilerServices
{
/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 2.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(2)]
public struct InlineArray2<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 3.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(3)]
public struct InlineArray3<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 4.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(4)]
public struct InlineArray4<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 5.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(5)]
public struct InlineArray5<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 6.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(6)]
public struct InlineArray6<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 7.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(7)]
public struct InlineArray7<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 8.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(8)]
public struct InlineArray8<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 9.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(9)]
public struct InlineArray9<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 10.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(10)]
public struct InlineArray10<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 11.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(11)]
public struct InlineArray11<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 12.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(12)]
public struct InlineArray12<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 13.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(13)]
public struct InlineArray13<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 14.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(14)]
public struct InlineArray14<T>
{
private T t;
}

/// <summary>
/// Represents an inline array of <typeparamref name="T"/> with a fixed length of 15.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
[InlineArray(15)]
public struct InlineArray15<T>
{
private T t;
}
}
70 changes: 70 additions & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13490,6 +13490,76 @@ public sealed partial class IndexerNameAttribute : System.Attribute
{
public IndexerNameAttribute(string indexerName) { }
}
[System.Runtime.CompilerServices.InlineArray(2)]
public struct InlineArray2<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(3)]
public struct InlineArray3<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(4)]
public struct InlineArray4<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(5)]
public struct InlineArray5<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(6)]
public struct InlineArray6<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(7)]
public struct InlineArray7<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(8)]
public struct InlineArray8<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(9)]
public struct InlineArray9<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(10)]
public struct InlineArray10<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(11)]
public struct InlineArray11<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(12)]
public struct InlineArray12<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(13)]
public struct InlineArray13<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(14)]
public struct InlineArray14<T>
{
private T t;
}
[System.Runtime.CompilerServices.InlineArray(15)]
public struct InlineArray15<T>
{
private T t;
}
[System.AttributeUsageAttribute(System.AttributeTargets.Struct, AllowMultiple=false)]
public sealed partial class InlineArrayAttribute : System.Attribute
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Reflection;
using Xunit;

namespace System.Runtime.CompilerServices.Tests
{
public static class InlineArrayTests
{
private static void WriteRead(Span<int> span, int expectedLength)
{
Assert.Equal(expectedLength, span.Length);

for (int i = 0; i < span.Length; i++)
{
span[i] = i + 1;
}

for (int i = 0; i < span.Length; i++)
{
Assert.Equal(i + 1, span[i]);
}
}

[Fact]
public void InlineArray2Test()
{
InlineArray2<int> inlineArray2 = new();
WriteRead(inlineArray2, 2);
}

[Fact]
public void InlineArray3Test()
{
InlineArray3<int> inlineArray3 = new();
WriteRead(inlineArray3, 3);
}

[Fact]
public void InlineArray4Test()
{
InlineArray4<int> inlineArray4 = new();
WriteRead(inlineArray4, 4);
}

[Fact]
public void InlineArray5Test()
{
InlineArray5<int> inlineArray5 = new();
WriteRead(inlineArray5, 5);
}

[Fact]
public void InlineArray6Test()
{
InlineArray6<int> inlineArray6 = new();
WriteRead(inlineArray6, 6);
}

[Fact]
public void InlineArray7Test()
{
InlineArray7<int> inlineArray7 = new();
WriteRead(inlineArray7, 7);
}

[Fact]
public void InlineArray8Test()
{
InlineArray8<int> inlineArray8 = new();
WriteRead(inlineArray8, 8);
}

[Fact]
public void InlineArray9Test()
{
InlineArray9<int> inlineArray9 = new();
WriteRead(inlineArray9, 9);
}

[Fact]
public void InlineArray10Test()
{
InlineArray10<int> inlineArray10 = new();
WriteRead(inlineArray10, 10);
}

[Fact]
public void InlineArray11Test()
{
InlineArray11<int> inlineArray11 = new();
WriteRead(inlineArray11, 11);
}

[Fact]
public void InlineArray12Test()
{
InlineArray12<int> inlineArray12 = new();
WriteRead(inlineArray12, 12);
}

[Fact]
public void InlineArray13Test()
{
InlineArray13<int> inlineArray13 = new();
WriteRead(inlineArray13, 13);
}

[Fact]
public void InlineArray14Test()
{
InlineArray14<int> inlineArray14 = new();
WriteRead(inlineArray14, 14);
}

[Fact]
public void InlineArray15Test()
{
InlineArray15<int> inlineArray15 = new();
WriteRead(inlineArray15, 15);
}
}
}
Loading