-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add InlineArrayX types #113403
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
Merged
Merged
Add InlineArrayX types #113403
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/InlineArray.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // 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 | ||
| { | ||
| [InlineArray(2)] | ||
| public struct InlineArray2<T> | ||
| { | ||
| private T t; | ||
333fred marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
333fred marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [InlineArray(3)] | ||
| public struct InlineArray3<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(4)] | ||
| public struct InlineArray4<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(5)] | ||
| public struct InlineArray5<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(6)] | ||
| public struct InlineArray6<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(7)] | ||
| public struct InlineArray7<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(8)] | ||
| public struct InlineArray8<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(9)] | ||
| public struct InlineArray9<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(10)] | ||
| public struct InlineArray10<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(11)] | ||
| public struct InlineArray11<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(12)] | ||
| public struct InlineArray12<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(13)] | ||
| public struct InlineArray13<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(14)] | ||
| public struct InlineArray14<T> | ||
| { | ||
| private T t; | ||
| } | ||
| [InlineArray(15)] | ||
| public struct InlineArray15<T> | ||
| { | ||
| private T t; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 201 additions & 0 deletions
201
...em.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/InlineArrayTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| // 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 | ||
| { | ||
| [Fact] | ||
| public void InlineArray2Test() | ||
| { | ||
| InlineArray2<int> inlineArray2 = new InlineArray2<int>(); | ||
| inlineArray2[0] = 1; | ||
| inlineArray2[1] = 2; | ||
| Assert.Equal(1, inlineArray2[0]); | ||
| Assert.Equal(2, inlineArray2[1]); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray3Test() | ||
| { | ||
| InlineArray3<int> inlineArray3 = new InlineArray3<int>(); | ||
| inlineArray3[0] = 1; | ||
| inlineArray3[1] = 2; | ||
| inlineArray3[2] = 3; | ||
| Assert.Equal(1, inlineArray3[0]); | ||
| Assert.Equal(2, inlineArray3[1]); | ||
| Assert.Equal(3, inlineArray3[2]); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray4Test() | ||
| { | ||
| InlineArray4<int> inlineArray4 = new InlineArray4<int>(); | ||
| for (int i = 0; i < 4; i++) | ||
| { | ||
| inlineArray4[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 4; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray4[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray5Test() | ||
| { | ||
| InlineArray5<int> inlineArray5 = new InlineArray5<int>(); | ||
| for (int i = 0; i < 5; i++) | ||
| { | ||
| inlineArray5[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 5; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray5[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray6Test() | ||
| { | ||
| InlineArray6<int> inlineArray6 = new InlineArray6<int>(); | ||
| for (int i = 0; i < 6; i++) | ||
| { | ||
| inlineArray6[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 6; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray6[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray7Test() | ||
| { | ||
| InlineArray7<int> inlineArray7 = new InlineArray7<int>(); | ||
| for (int i = 0; i < 7; i++) | ||
| { | ||
| inlineArray7[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 7; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray7[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray8Test() | ||
| { | ||
| InlineArray8<int> inlineArray8 = new InlineArray8<int>(); | ||
| for (int i = 0; i < 8; i++) | ||
| { | ||
| inlineArray8[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 8; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray8[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray9Test() | ||
| { | ||
| InlineArray9<int> inlineArray9 = new InlineArray9<int>(); | ||
| for (int i = 0; i < 9; i++) | ||
| { | ||
| inlineArray9[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 9; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray9[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray10Test() | ||
| { | ||
| InlineArray10<int> inlineArray10 = new InlineArray10<int>(); | ||
| for (int i = 0; i < 10; i++) | ||
| { | ||
| inlineArray10[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 10; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray10[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray11Test() | ||
| { | ||
| InlineArray11<int> inlineArray11 = new InlineArray11<int>(); | ||
| for (int i = 0; i < 11; i++) | ||
| { | ||
| inlineArray11[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 11; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray11[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray12Test() | ||
| { | ||
| InlineArray12<int> inlineArray12 = new InlineArray12<int>(); | ||
| for (int i = 0; i < 12; i++) | ||
| { | ||
| inlineArray12[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 12; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray12[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray13Test() | ||
| { | ||
| InlineArray13<int> inlineArray13 = new InlineArray13<int>(); | ||
| for (int i = 0; i < 13; i++) | ||
| { | ||
| inlineArray13[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 13; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray13[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray14Test() | ||
| { | ||
| InlineArray14<int> inlineArray14 = new InlineArray14<int>(); | ||
| for (int i = 0; i < 14; i++) | ||
| { | ||
| inlineArray14[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 14; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray14[i]); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void InlineArray15Test() | ||
| { | ||
| InlineArray15<int> inlineArray15 = new InlineArray15<int>(); | ||
| for (int i = 0; i < 15; i++) | ||
| { | ||
| inlineArray15[i] = i + 1; | ||
| } | ||
| for (int i = 0; i < 15; i++) | ||
| { | ||
| Assert.Equal(i + 1, inlineArray15[i]); | ||
| } | ||
333fred marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.