Skip to content

Collapse Desc flag boilerplate into shared helpers#710

Merged
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:refactor-flag-boilerplate
Jul 12, 2026
Merged

Collapse Desc flag boilerplate into shared helpers#710
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:refactor-flag-boilerplate

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Each single-bit flag property on the *Desc abstractions duplicated the same (Flags & X) != 0 get and value ? Flags | X : Flags & ~X set logic. This routes them through per-struct GetFlag/SetFlag helpers so each accessor is a single line, which makes the boilerplate far easier to scan and keeps the three types consistent with one another.

  • FunctionOrDelegateDesc -- 16 flag properties collapsed
  • StructDesc -- 4 flag properties collapsed
  • EnumDesc -- 1 flag property collapsed

Purely behavior-preserving. The tri-state IsStatic on FunctionOrDelegateDesc is intentionally left as-is since it spans two flags (IsStatic/IsNotStatic), and ValueDesc already used concise read-only getters so it needed no change.

Block-bodied accessors are kept to satisfy the repo's csharp_style_expression_bodied_accessors = false rule; the helpers themselves are single-line expression-bodied methods.

Verified with a 0-warning build and all 3706 golden tests passing.

Note

This PR description was drafted by Copilot.

tannergooding and others added 2 commits July 12, 2026 15:39
`FunctionOrDelegateDesc`, `StructDesc`, and `EnumDesc` each duplicated the same `(Flags & X) != 0` get and `value ? Flags | X : Flags & ~X` set logic across every single-bit flag property. Route them through per-struct `GetFlag`/`SetFlag` helpers so the accessors are one line each. Behavior-preserving; the tri-state `IsStatic` on `FunctionOrDelegateDesc` is left as-is since it spans two flags, and `ValueDesc` already used concise read-only getters.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding enabled auto-merge July 12, 2026 22:52
@tannergooding
tannergooding disabled auto-merge July 12, 2026 22:52
@tannergooding
tannergooding merged commit 36ac734 into dotnet:main Jul 12, 2026
14 checks passed
@tannergooding
tannergooding deleted the refactor-flag-boilerplate branch July 12, 2026 22:52
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