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

Conversation

Zastai
Copy link
Contributor

@Zastai Zastai commented Aug 17, 2024

This adds a new AllowsByRefLike flag to GenericParameterAttributes which, unlike the others, is an anti-constraint (i.e. it removes restrictions rather than adding them) added in C# 13. Because of this, AllowsByRefLike was chosen as the corresponding bool property on GenericParameter (instead of
HasAllowByRefLineConstraint; the constant also does not include Constraint in its name).

At the same time, it adds the NoSpecialConstraint flag and a corresponding HasNoSpecialConstraint property.

Reference: corresponding constants in the CLR code: https://github.com/dotnet/runtime/blob/9daa4b41eb9f157e79eaf05e2f7451c9c8f6dbdc/src/coreclr/inc/corhdr.h#L850

This adds a new `AllowsByRefLike` flag to `GenericParameterAttributes`
which, unlike the others, is an anti-constraint (i.e. it removes
restrictions rather than adding them) added in C# 13.
Because of this, `AllowsByRefLike` was chosen as the corresponding bool
property on `GenericParameter` (instead of
`HasAllowByRefLineConstraint`; the constant also does not include
`Constraint` in its name).

At the same time, it adds the `NoSpecialConstraint` flag and a
corresponding `HasNoSpecialConstraint` property.
@Zastai
Copy link
Contributor Author

Zastai commented Aug 17, 2024

Hmm, looks like it's already there; could have sworn I updated my fork.

@Zastai
Copy link
Contributor Author

Zastai commented Aug 17, 2024

Right, still keeping this PR because:

  • it updates SpecialConstraintMask to include the new flag
  • I kept the enum constant name in like with the CLR/COR header (no Constraint at the end, because it's not a constraint)
  • the property name lacked the Has (needed because the Allow referred only to the ByRefLike, not the Constraint
    • I'm still keeping AllowsByRefLike for now, because it reads better than HasAllowByRefLike
      • but I'm open to changing it to the latter for consistency with the other property names
  • it also adds the NoSpecialConstraint flag and property, to better match the whole of the CLR/COR version of the attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant