forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ValueTuple and ITuple to corlib in CoreCLR (dotnet/coreclr#8695)
* Adding ValueTuple * Adding ITuple * Porting equality comparer optimization from corefx PR dotnet/coreclr#14187 Commit migrated from dotnet/coreclr@2d49c2c
- Loading branch information
Showing
10 changed files
with
4,186 additions
and
214 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
22 changes: 22 additions & 0 deletions
22
src/coreclr/src/mscorlib/src/System/Runtime/CompilerServices/ITuple.cs
This file contains 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,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
/// <summary> | ||
/// This interface is required for types that want to be indexed into by dynamic patterns. | ||
/// </summary> | ||
public interface ITuple | ||
{ | ||
/// <summary> | ||
/// The number of positions in this data structure. | ||
/// </summary> | ||
int Length { get; } | ||
|
||
/// <summary> | ||
/// Get the element at position <param name="index"/>. | ||
/// </summary> | ||
object this[int index] { get; } | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/coreclr/src/mscorlib/src/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs
This file contains 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,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
/// <summary> | ||
/// Indicates that the use of <see cref="System.ValueTuple"/> on a member is meant to be treated as a tuple with element names. | ||
/// </summary> | ||
[CLSCompliant(false)] | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Event)] | ||
public sealed class TupleElementNamesAttribute : Attribute | ||
{ | ||
private readonly string[] _transformNames; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see | ||
/// cref="TupleElementNamesAttribute"/> class. | ||
/// </summary> | ||
/// <param name="transformNames"> | ||
/// Specifies, in a pre-order depth-first traversal of a type's | ||
/// construction, which <see cref="System.ValueType"/> occurrences are | ||
/// meant to carry element names. | ||
/// </param> | ||
/// <remarks> | ||
/// This constructor is meant to be used on types that contain an | ||
/// instantiation of <see cref="System.ValueType"/> that contains | ||
/// element names. For instance, if <c>C</c> is a generic type with | ||
/// two type parameters, then a use of the constructed type <c>C{<see | ||
/// cref="System.ValueTuple{T1, T2}"/>, <see | ||
/// cref="System.ValueTuple{T1, T2, T3}"/></c> might be intended to | ||
/// treat the first type argument as a tuple with element names and the | ||
/// second as a tuple without element names. In which case, the | ||
/// appropriate attribute specification should use a | ||
/// <c>transformNames</c> value of <c>{ "name1", "name2", null, null, | ||
/// null }</c>. | ||
/// </remarks> | ||
public TupleElementNamesAttribute(string[] transformNames) | ||
{ | ||
if (transformNames == null) | ||
{ | ||
throw new ArgumentNullException(nameof(transformNames)); | ||
} | ||
|
||
_transformNames = transformNames; | ||
} | ||
|
||
/// <summary> | ||
/// Specifies, in a pre-order depth-first traversal of a type's | ||
/// construction, which <see cref="System.ValueTuple"/> elements are | ||
/// meant to carry element names. | ||
/// </summary> | ||
public IList<string> TransformNames => _transformNames; | ||
} | ||
} |
Oops, something went wrong.