Skip to content

Fix generic marshaller names in generated projections - #2581

Open
Sergio Pedri (Sergio0694) wants to merge 2 commits into
staging/3.0from
user/sergiopedri/generic-marshaller-names
Open

Sergio Pedri (Sergio0694) wants to merge 2 commits into
staging/3.0from
user/sergiopedri/generic-marshaller-names

Conversation

@Sergio0694

Copy link
Copy Markdown
Member

Summary

Align generated projection accessors with the type names emitted into WinRT.Interop.dll. Preserve the existing source WinMD filename-stem convention and include the #corlib marker when encoding Guid generic arguments.

Motivation

Generated UnsafeAccessorType targets must match interop type names ordinally. The projection writer previously used declared assembly names where the interop generator used recorded WinMD filename stems, and encoded nested Guid arguments without their assembly marker. Both discrepancies could cause TypeLoadException even when the required marshaller and methods existed.

This is a conservative implementation-only fix: it preserves public/reference projection output and does not require republishing third-party reference-projection packages.

Changes

  • src\WinRT.Projection.Writer\: share filename-stem resolution between metadata entries and accessor names, propagate the metadata context through generic, array, IID, event-source, constructor and mapped-interface paths, and retain Guid's #corlib marker inside constructed types.
  • src\Tests\ProjectionWriterTest\: generate real projection and interop assemblies and verify exact target types, members and signatures. Cover filename casing and renamed/dotted stems, overloads, nested Guid generics, arrays, events, reference-source invariance, and isolated native-backed CoreCLR roundtrips. Add an opt-in Native AOT run of the same consumer via CSWINRT_TEST_GENERIC_MARSHALLERS_AOT=1.
  • .github\skills\interop-generator\references\name-mangling-scheme.md: document the shared naming contract and the need to regenerate affected precompiled SDK implementation projections when packaging updated tooling.

Validation

  • Final Release x64 build: no warnings or errors; 34 focused naming, event-source and metadata tests passed.
  • Native AOT regression run: all 7 cases passed, including execution of the native consumer.
  • Preserved original generator: the two reference-invariance cases passed and all four naming regressions failed as expected.
  • Full Windows SDK source comparison: all 318 reference-projection files were byte-identical. Across 6,334 implementation accessor occurrences, the only output changes were the expected Guid marker corrections in 13 files.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CsWinRT 3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant