Skip to content

Commit

Permalink
Add new AllowByRefLike generic parameter attribute (#557)
Browse files Browse the repository at this point in the history
* Add new `AllowByRefLike` generic parameter attribute

* Update `GenericParamAttributes.SpecialConstraintMask`
  • Loading branch information
ElektroKill authored May 28, 2024
1 parent 0b2dc95 commit 006c640
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/DotNet/GenericParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ public bool HasDefaultConstructorConstraint {
set => ModifyAttributes(value, GenericParamAttributes.DefaultConstructorConstraint);
}

/// <summary>
/// Gets/sets the <see cref="GenericParamAttributes.AllowByRefLike"/> bit
/// </summary>
public bool AllowsByRefLike {
get => ((GenericParamAttributes)attributes & GenericParamAttributes.AllowByRefLike) != 0;
set => ModifyAttributes(value, GenericParamAttributes.AllowByRefLike);
}

/// <inheritdoc/>
void IListListener<GenericParamConstraint>.OnLazyAdd(int index, ref GenericParamConstraint value) => OnLazyAdd2(index, ref value);

Expand Down
4 changes: 3 additions & 1 deletion src/DotNet/GenericParamAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum GenericParamAttributes : ushort {
Contravariant = 0x0002,

/// <summary/>
SpecialConstraintMask = 0x001C,
SpecialConstraintMask = 0x003C,
/// <summary/>
NoSpecialConstraint = 0x0000,
/// <summary>type argument must be a reference type</summary>
Expand All @@ -27,5 +27,7 @@ public enum GenericParamAttributes : ushort {
NotNullableValueTypeConstraint = 0x0008,
/// <summary>type argument must have a public default constructor</summary>
DefaultConstructorConstraint = 0x0010,
/// <summary>type argument can be ByRefLike</summary>
AllowByRefLike = 0x0020,
}
}

0 comments on commit 006c640

Please sign in to comment.