// 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 { /// /// Indicates that the use of on a member is meant to be treated as a tuple with element names. /// [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; /// /// Initializes a new instance of the class. /// /// /// Specifies, in a pre-order depth-first traversal of a type's /// construction, which occurrences are /// meant to carry element names. /// /// /// This constructor is meant to be used on types that contain an /// instantiation of that contains /// element names. For instance, if C is a generic type with /// two type parameters, then a use of the constructed type 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 /// transformNames value of { "name1", "name2", null, null, /// null }. /// public TupleElementNamesAttribute(string[] transformNames) { if (transformNames == null) { throw new ArgumentNullException(nameof(transformNames)); } _transformNames = transformNames; } /// /// Specifies, in a pre-order depth-first traversal of a type's /// construction, which elements are /// meant to carry element names. /// public IList TransformNames => _transformNames; } }