Skip to content

Fix v22 NativeTypeName global-scope churn and inline-array field address-of#830

Merged
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:fix-namespace-qualifier-const-pointer
Jul 19, 2026
Merged

Fix v22 NativeTypeName global-scope churn and inline-array field address-of#830
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:fix-namespace-qualifier-const-pointer

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Two independent v22.1.8 regen regressions found regenerating terrafx.interop.windows, both fallout from the round-1 namespace-qualifier / address-of work.


Strip the redundant global-scope qualifier from NativeTypeName

clang 22 spells a name with a leading :: when the unqualified name is shadowed by a type in an enclosing namespace, and we passed it through verbatim -- e.g. [NativeTypeName("::boolean *")]. The C# type is correctly byte*, but the qualifier is spurious churn that is inconsistent with the ~874 other unqualified boolean sites. Strip a leading global-scope :: at the type-name position (after cv/tag qualifiers) so ::boolean * normalizes to boolean *. The refactor also extracts the leading-qualifier skip into a shared SkipLeadingTypeQualifiers helper.


Take the address of an inline-array field decayed to a pointer

An array-to-pointer decay of an inline-array field was emitted unaddressed, e.g. NativeMemory.Fill(a->u.Byte, ...). That does not compile in Default/Latest/Preview because an [InlineArray] field has no implicit void* conversion (CS1503). Emit the & when a MemberExpr of ConstantArrayType decays to a pointer, except in compatible mode where the fixed buffer decays naturally (adding & there would be T**). Restricting to MemberExpr leaves managed-array locals and explicit source & untouched -- locals need fixed/pinning, not &.


Added regression tests GlobalScopeQualifierIsStrippedTest and ArrayFieldToPointerArgumentTest with unified baselines. Full suite green (4205 passed, 0 failed), zero existing-baseline churn.

tannergooding and others added 2 commits July 19, 2026 10:25
clang 22 spells a name with a leading `::` when the unqualified name is
shadowed by a type in an enclosing namespace. Strip the leading global-scope
qualifier so `::boolean *` matches the ~874 other unqualified `boolean` sites
instead of emitting spurious churn.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
An array-to-pointer decay of an inline-array field was passed unaddressed,
producing e.g. `NativeMemory.Fill(a->u.Byte, ...)` which does not compile
because an `[InlineArray]` field has no implicit `void*` conversion. Emit the
`&` when a `MemberExpr` of `ConstantArrayType` decays to a pointer, except in
compatible mode where the `fixed` buffer decays naturally.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding merged commit 9f8f8ca into dotnet:main Jul 19, 2026
12 checks passed
@tannergooding
tannergooding deleted the fix-namespace-qualifier-const-pointer branch July 19, 2026 17:43
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