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

Open
Zastai wants to merge 2 commits from Zastai/add-allows-ref-struct-constraint into master
Zastai commented 2024-08-17 09:30:36 -05:00 (Migrated from github.com)

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: github.com/dotnet/runtime@9daa4b41eb/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. Reference: corresponding constants in the CLR code: https://github.com/dotnet/runtime/blob/9daa4b41eb9f157e79eaf05e2f7451c9c8f6dbdc/src/coreclr/inc/corhdr.h#L850
Zastai commented 2024-08-17 09:31:28 -05:00 (Migrated from github.com)

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

Hmm, looks like it's already there; could have sworn I updated my fork.
Zastai commented 2024-08-17 09:43:16 -05:00 (Migrated from github.com)

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
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
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'Zastai/add-allows-ref-struct-constraint:Zastai/add-allows-ref-struct-constraint'
git switch 'Zastai/add-allows-ref-struct-constraint'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'master'
git merge --no-ff 'Zastai/add-allows-ref-struct-constraint'
git switch 'Zastai/add-allows-ref-struct-constraint'
git rebase 'master'
git switch 'master'
git merge --ff-only 'Zastai/add-allows-ref-struct-constraint'
git switch 'Zastai/add-allows-ref-struct-constraint'
git rebase 'master'
git switch 'master'
git merge --no-ff 'Zastai/add-allows-ref-struct-constraint'
git switch 'master'
git merge --squash 'Zastai/add-allows-ref-struct-constraint'
git switch 'master'
git merge --ff-only 'Zastai/add-allows-ref-struct-constraint'
git switch 'master'
git merge 'Zastai/add-allows-ref-struct-constraint'
git push origin 'master'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil!957
No description provided.