Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
346 lines (340 sloc) 18.5 KB
<Type Name="GenericParameterAttributes" FullName="System.Reflection.GenericParameterAttributes">
<TypeSignature Language="C#" Value="public enum GenericParameterAttributes" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed GenericParameterAttributes extends System.Enum" />
<TypeSignature Language="DocId" Value="T:System.Reflection.GenericParameterAttributes" />
<TypeSignature Language="VB.NET" Value="Public Enum GenericParameterAttributes" />
<TypeSignature Language="C++ CLI" Value="public enum class GenericParameterAttributes" />
<TypeSignature Language="F#" Value="type GenericParameterAttributes = " />
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Enum</BaseTypeName>
</Base>
<Attributes>
<Attribute FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8;netcore-2.2;dotnet-uwp-10.0;netcore-3.0;netstandard-2.1">
<AttributeName>System.Flags</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Describes the constraints on a generic type parameter of a generic type or method.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The members of the <xref:System.Reflection.GenericParameterAttributes> enumeration are divided into two groups, the variance group and the special constraints group. To test a <xref:System.Reflection.GenericParameterAttributes> value for variance flags, first perform a bitwise AND operation with VarianceMask. If the result is None, there are no variance flags. Similarly, use SpecialConstraintMask to test for constraint flags.
## Examples
The following code example defines a generic type `Test` with two type parameters. The second type parameter has a base class constraint and a reference type constraint. When the program executes, the constraints are examined using the <xref:System.Type.GenericParameterAttributes%2A?displayProperty=nameWithType> property and the <xref:System.Type.GetGenericParameterConstraints%2A?displayProperty=nameWithType> method.
[!code-cpp[System.Type.GetGenericParameterConstraints#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp#1)]
[!code-csharp[System.Type.GetGenericParameterConstraints#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CS/source.cs#1)]
[!code-vb[System.Type.GetGenericParameterConstraints#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/VB/source.vb#1)]
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName="Contravariant">
<MemberSignature Language="C#" Value="Contravariant" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes Contravariant = int32(2)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.Contravariant" />
<MemberSignature Language="VB.NET" Value="Contravariant" />
<MemberSignature Language="C++ CLI" Value="Contravariant" />
<MemberSignature Language="F#" Value="Contravariant = 2" Usage="System.Reflection.GenericParameterAttributes.Contravariant" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>2</MemberValue>
<Docs>
<summary>The generic type parameter is contravariant. A contravariant type parameter can appear as a parameter type in method signatures.</summary>
</Docs>
</Member>
<Member MemberName="Covariant">
<MemberSignature Language="C#" Value="Covariant" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes Covariant = int32(1)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.Covariant" />
<MemberSignature Language="VB.NET" Value="Covariant" />
<MemberSignature Language="C++ CLI" Value="Covariant" />
<MemberSignature Language="F#" Value="Covariant = 1" Usage="System.Reflection.GenericParameterAttributes.Covariant" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>1</MemberValue>
<Docs>
<summary>The generic type parameter is covariant. A covariant type parameter can appear as the result type of a method, the type of a read-only field, a declared base type, or an implemented interface.</summary>
</Docs>
</Member>
<Member MemberName="DefaultConstructorConstraint">
<MemberSignature Language="C#" Value="DefaultConstructorConstraint" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes DefaultConstructorConstraint = int32(16)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.DefaultConstructorConstraint" />
<MemberSignature Language="VB.NET" Value="DefaultConstructorConstraint" />
<MemberSignature Language="C++ CLI" Value="DefaultConstructorConstraint" />
<MemberSignature Language="F#" Value="DefaultConstructorConstraint = 16" Usage="System.Reflection.GenericParameterAttributes.DefaultConstructorConstraint" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>16</MemberValue>
<Docs>
<summary>A type can be substituted for the generic type parameter only if it has a parameterless constructor.</summary>
</Docs>
</Member>
<Member MemberName="None">
<MemberSignature Language="C#" Value="None" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes None = int32(0)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.None" />
<MemberSignature Language="VB.NET" Value="None" />
<MemberSignature Language="C++ CLI" Value="None" />
<MemberSignature Language="F#" Value="None = 0" Usage="System.Reflection.GenericParameterAttributes.None" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>0</MemberValue>
<Docs>
<summary>There are no special flags.</summary>
</Docs>
</Member>
<Member MemberName="NotNullableValueTypeConstraint">
<MemberSignature Language="C#" Value="NotNullableValueTypeConstraint" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes NotNullableValueTypeConstraint = int32(8)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.NotNullableValueTypeConstraint" />
<MemberSignature Language="VB.NET" Value="NotNullableValueTypeConstraint" />
<MemberSignature Language="C++ CLI" Value="NotNullableValueTypeConstraint" />
<MemberSignature Language="F#" Value="NotNullableValueTypeConstraint = 8" Usage="System.Reflection.GenericParameterAttributes.NotNullableValueTypeConstraint" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>8</MemberValue>
<Docs>
<summary>A type can be substituted for the generic type parameter only if it is a value type and is not nullable.</summary>
</Docs>
</Member>
<Member MemberName="ReferenceTypeConstraint">
<MemberSignature Language="C#" Value="ReferenceTypeConstraint" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes ReferenceTypeConstraint = int32(4)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.ReferenceTypeConstraint" />
<MemberSignature Language="VB.NET" Value="ReferenceTypeConstraint" />
<MemberSignature Language="C++ CLI" Value="ReferenceTypeConstraint" />
<MemberSignature Language="F#" Value="ReferenceTypeConstraint = 4" Usage="System.Reflection.GenericParameterAttributes.ReferenceTypeConstraint" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>4</MemberValue>
<Docs>
<summary>A type can be substituted for the generic type parameter only if it is a reference type.</summary>
</Docs>
</Member>
<Member MemberName="SpecialConstraintMask">
<MemberSignature Language="C#" Value="SpecialConstraintMask" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes SpecialConstraintMask = int32(28)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.SpecialConstraintMask" />
<MemberSignature Language="VB.NET" Value="SpecialConstraintMask" />
<MemberSignature Language="C++ CLI" Value="SpecialConstraintMask" />
<MemberSignature Language="F#" Value="SpecialConstraintMask = 28" Usage="System.Reflection.GenericParameterAttributes.SpecialConstraintMask" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>28</MemberValue>
<Docs>
<summary>Selects the combination of all special constraint flags. This value is the result of using logical OR to combine the following flags: <see cref="F:System.Reflection.GenericParameterAttributes.DefaultConstructorConstraint" />, <see cref="F:System.Reflection.GenericParameterAttributes.ReferenceTypeConstraint" />, and <see cref="F:System.Reflection.GenericParameterAttributes.NotNullableValueTypeConstraint" />.</summary>
</Docs>
</Member>
<Member MemberName="VarianceMask">
<MemberSignature Language="C#" Value="VarianceMask" />
<MemberSignature Language="ILAsm" Value=".field public static literal valuetype System.Reflection.GenericParameterAttributes VarianceMask = int32(3)" />
<MemberSignature Language="DocId" Value="F:System.Reflection.GenericParameterAttributes.VarianceMask" />
<MemberSignature Language="VB.NET" Value="VarianceMask" />
<MemberSignature Language="C++ CLI" Value="VarianceMask" />
<MemberSignature Language="F#" Value="VarianceMask = 3" Usage="System.Reflection.GenericParameterAttributes.VarianceMask" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Reflection.Primitives</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Reflection.GenericParameterAttributes</ReturnType>
</ReturnValue>
<MemberValue>3</MemberValue>
<Docs>
<summary>Selects the combination of all variance flags. This value is the result of using logical OR to combine the following flags: <see cref="F:System.Reflection.GenericParameterAttributes.Contravariant" /> and <see cref="F:System.Reflection.GenericParameterAttributes.Covariant" />.</summary>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.