Skip to content

Commit 006c640

Browse files
authored
Add new AllowByRefLike generic parameter attribute (#557)
* Add new `AllowByRefLike` generic parameter attribute * Update `GenericParamAttributes.SpecialConstraintMask`
1 parent 0b2dc95 commit 006c640

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/DotNet/GenericParam.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ public bool HasDefaultConstructorConstraint {
260260
set => ModifyAttributes(value, GenericParamAttributes.DefaultConstructorConstraint);
261261
}
262262

263+
/// <summary>
264+
/// Gets/sets the <see cref="GenericParamAttributes.AllowByRefLike"/> bit
265+
/// </summary>
266+
public bool AllowsByRefLike {
267+
get => ((GenericParamAttributes)attributes & GenericParamAttributes.AllowByRefLike) != 0;
268+
set => ModifyAttributes(value, GenericParamAttributes.AllowByRefLike);
269+
}
270+
263271
/// <inheritdoc/>
264272
void IListListener<GenericParamConstraint>.OnLazyAdd(int index, ref GenericParamConstraint value) => OnLazyAdd2(index, ref value);
265273

src/DotNet/GenericParamAttributes.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public enum GenericParamAttributes : ushort {
1818
Contravariant = 0x0002,
1919

2020
/// <summary/>
21-
SpecialConstraintMask = 0x001C,
21+
SpecialConstraintMask = 0x003C,
2222
/// <summary/>
2323
NoSpecialConstraint = 0x0000,
2424
/// <summary>type argument must be a reference type</summary>
@@ -27,5 +27,7 @@ public enum GenericParamAttributes : ushort {
2727
NotNullableValueTypeConstraint = 0x0008,
2828
/// <summary>type argument must have a public default constructor</summary>
2929
DefaultConstructorConstraint = 0x0010,
30+
/// <summary>type argument can be ByRefLike</summary>
31+
AllowByRefLike = 0x0020,
3032
}
3133
}

0 commit comments

Comments
 (0)