Skip to content

Add assembly-to-package mappings for ProxyGenerator#2189

Closed
Copilot wants to merge 6 commits into
mainfrom
copilot/add-type-mapping-for-proxygenerator
Closed

Add assembly-to-package mappings for ProxyGenerator#2189
Copilot wants to merge 6 commits into
mainfrom
copilot/add-type-mapping-for-proxygenerator

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

Types from referenced assemblies that have a corresponding npm package should be imported from that package rather than generated as local TypeScript files. This adds a configurable mapping from C# assembly name to npm package name.

Added

  • AssemblyToPackageMapping MSBuild ItemGroup support — maps C# assembly types to an npm package instead of generating local TypeScript files
<ItemGroup>
    <AssemblyToPackageMapping Assembly="MyCompany.Shared" Package="@mycompany/shared" />
</ItemGroup>
  • --assembly-to-package=Assembly=Package CLI flag (repeatable) for direct proxy generator invocation
  • TypeExtensions.SetAssemblyPackageMappings() / IsFromMappedAssembly() for configuring and querying the mapping at runtime
  • Specs covering GetTargetType, IsFromMappedAssembly, CollectTypesInvolved exclusion, and an end-to-end command generation scenario
  • Documentation for the new feature in configuration.md with a relatable multi-project shared library example

Changed

  • Generator.Generate() accepts an optional assemblyPackageMappings dictionary and filters mapped types from generated typeDescriptors / enumDescriptors
  • GetTargetType() returns a package-based TargetType (FromPackage=true, Module=<packageName>) for types whose assembly is mapped
  • All CollectTypesInvolved overloads skip types from mapped assemblies to prevent recursive local type generation

Copilot AI linked an issue May 3, 2026 that may be closed by this pull request
@einari
Copy link
Copy Markdown
Contributor

einari commented May 3, 2026

@copilot Great. I had an error in the spec; AssemblyToPageMapping should be AssemblyToPackageMapping. Let's create a better sample than the Cratis sample in the documentation, something others can relate to - like a reusable .NET Project that gets used by multiple other projects.

Comment on lines +76 to +79
catch
{
_typeScriptIsValid = false;
}
Comment thread Source/DotNET/Tools/ProxyGenerator/Program.cs Fixed
…ping to AssemblyToPackageMapping

Agent-Logs-Url: https://github.com/Cratis/Arc/sessions/ae058189-02e3-477c-a131-5c0cd4a543da

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Copilot AI changed the title [WIP] Add mapping types for ProxyGenerator configuration Add assembly-to-package mappings for ProxyGenerator May 3, 2026
Copilot finished work on behalf of einari May 3, 2026 08:32
Copilot AI requested a review from einari May 3, 2026 08:32
…le multi-project example

Agent-Logs-Url: https://github.com/Cratis/Arc/sessions/fd53fd75-bc6a-4d3e-ab26-8c3680af0e37

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 3, 2026

@copilot Great. I had an error in the spec; AssemblyToPageMapping should be AssemblyToPackageMapping. Let's create a better sample than the Cratis sample in the documentation, something others can rel...

The AssemblyToPageMapping typo was already fixed in a previous commit. I've now also rewritten the documentation example (4d00147) to use a generic multi-project solution structure (MyCompany.Shared / MyCompany.Inventory / MyCompany.Purchasing) with a shared class library that ships both a NuGet package and an npm package — a pattern most .NET teams will recognise.

Copilot finished work on behalf of einari May 3, 2026 08:34
…ect'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
@einari einari added the minor label May 3, 2026
@einari einari marked this pull request as ready for review May 3, 2026 08:59
@einari
Copy link
Copy Markdown
Contributor

einari commented May 3, 2026

@copilot fix the markdown lint errors - run the verification script in the Documentation folder

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

NuGet packages for this PR, e.g. Cratis.Arc:
https://github.com/cratis/arc/packages/1655206?version=20.13.1-pr2189.03c1910

…in configuration.md

Agent-Logs-Url: https://github.com/Cratis/Arc/sessions/560ada5c-342f-4fbc-acc8-1f0bed712c4b

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 3, 2026

@copilot fix the markdown lint errors - run the verification script in the Documentation folder

Fixed in 6c058c6 — the solution structure code block was missing a language specifier (text). All markdown checks now pass.

Copilot finished work on behalf of einari May 3, 2026 09:01
einari added a commit that referenced this pull request May 3, 2026
Combines flags enum template support with assembly-to-package mappings.
Both regular and flags enum descriptors now respect IsFromMappedAssembly()
so types from mapped assemblies are imported from their package rather than
generated locally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@einari
Copy link
Copy Markdown
Contributor

einari commented May 3, 2026

Superseded by #2187 which now includes both the assembly-to-package mapping feature and the flags enum template support.

@einari einari closed this May 3, 2026
@einari einari deleted the copilot/add-type-mapping-for-proxygenerator branch May 3, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mapping types for ProxyGenerator

2 participants