Skip to content

Fix custom marshaller namespaces for root metadata types - #1849

Merged
Jevan Saks (jevansaks) merged 1 commit into
mainfrom
jevansaks-flat-namespace-marshallers
Oct 8, 2026
Merged

Jevan Saks (jevansaks) merged 1 commit into
mainfrom
jevansaks-flat-namespace-marshallers

Conversation

@jevansaks

Copy link
Copy Markdown
Member

Summary

Fixes #1848; also addresses the malformed namespace reported in #1632.

  • Handle an empty relative namespace when placing native typedef and associated enum marshallers in InteropServices, avoiding leading dots in namespace declarations and doubled dots in qualified marshaller references.
  • Preserve existing marshaller placement for types in nested namespaces.
  • Add a small authored metadata fixture with root and nested typedefs and associated enums, with its IL source and regeneration instructions.
  • Add build-task generator regression coverage that verifies the marshaller references and compiles the generated projection with .NET source generators for .NET 8, 9, and 10.

Validation

The root typedef and enum cases reproduced CS1001: Identifier expected before the fix. After the fix, all 12 new regression cases and 3 neighboring typedef/SafeHandle regression cases pass, with no build warnings or errors.

$env:NBGV_GitEngine = 'Disabled'
dotnet test .\test\CsWin32Generator.Tests\CsWin32Generator.Tests.csproj --no-restore --filter 'FullyQualifiedName~MarshallerNamespace|FullyQualifiedName~CrossWinMD_NTSTATUSSafeHandleConstant|FullyQualifiedName~ICCloseSafeHandle_CustomClassName' --verbosity quiet

Avoid empty namespace segments in native typedef and associated enum marshallers. Add build-task generation and compilation coverage for root and nested metadata namespaces on .NET 8 through .NET 10.

Fixes #1848

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ad80cd5b-a9a2-4cee-aa3d-030ab5462c4d
@jevansaks
Jevan Saks (jevansaks) marked this pull request as ready for review October 8, 2026 21:14
@jevansaks
Jevan Saks (jevansaks) enabled auto-merge (squash) October 8, 2026 21:48
@jevansaks
Jevan Saks (jevansaks) merged commit 505d80f into main Oct 8, 2026
20 checks passed
@jevansaks
Jevan Saks (jevansaks) deleted the jevansaks-flat-namespace-marshallers branch October 8, 2026 22:05
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.

Flat-namespace native typedef marshallers emit invalid C# in build-task mode

2 participants