Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#13: Add the "allow byref-like" anti-constraint #957

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Mono.Cecil/GenericParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public bool IsContravariant {
set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Contravariant, value); }
}

public bool HasNoSpecialConstraint {
get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.SpecialConstraintMask, (ushort) GenericParameterAttributes.NoSpecialConstraint); }
set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.SpecialConstraintMask, (ushort) GenericParameterAttributes.NoSpecialConstraint, value); }
}

public bool HasReferenceTypeConstraint {
get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint); }
set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint, value); }
Expand All @@ -165,9 +170,9 @@ public bool HasDefaultConstructorConstraint {
set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint, value); }
}

public bool AllowByRefLikeConstraint {
get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.AllowByRefLikeConstraint); }
set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.AllowByRefLikeConstraint, value); }
public bool AllowsByRefLike {
get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.AllowByRefLike); }
set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.AllowByRefLike, value); }
}

#endregion
Expand Down
5 changes: 3 additions & 2 deletions Mono.Cecil/GenericParameterAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public enum GenericParameterAttributes : ushort {
Covariant = 0x0001,
Contravariant = 0x0002,

SpecialConstraintMask = 0x001c,
SpecialConstraintMask = 0x003c,
NoSpecialConstraint = 0x0000,
ReferenceTypeConstraint = 0x0004,
NotNullableValueTypeConstraint = 0x0008,
DefaultConstructorConstraint = 0x0010,
AllowByRefLikeConstraint = 0x0020,
AllowByRefLike = 0x0020,
}
}