Skip to content

Add source-file-as-output-file option to ProxyGenerator#1845

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-proxy-generator-option
Draft

Add source-file-as-output-file option to ProxyGenerator#1845
Copilot wants to merge 3 commits intomainfrom
copilot/add-proxy-generator-option

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Adds an option to group all TypeScript proxy types from the same C# source file into a single .ts file named after that source file, instead of generating one file per type.

Added

  • SourceFileResolver — reads portable PDB (embedded or external) to map type full names → source file names using System.Reflection.Metadata
  • TypeScriptContentCombiner — merges multiple generated TypeScript file contents: deduplicates ESLint directives and import statements, concatenates export blocks
  • --use-source-file-as-output-file CLI flag for the proxygenerator tool
  • CratisProxiesUseSourceFileAsOutputFile MSBuild property in .targets file
  • useSourceFileAsOutputFile parameter on Generator.Generate()
  • sourceFileMap parameter on DescriptorExtensions.Write() — when provided, descriptors are grouped by source file name rather than type name, with combined content written to a single file per group

Example: a C# file AccountCommands.cs defining CreateAccount, UpdateAccount, DeleteAccount previously produced three .ts files. With CratisProxiesUseSourceFileAsOutputFile=true, they are combined into a single AccountCommands.ts.

Requires PDB files alongside the compiled assembly. Falls back to per-type files when PDB is unavailable.

Changed

  • DescriptorExtensions.Write() signature extended with optional sourceFileMap — fully backward compatible; existing call sites are unaffected
  • Duplicate-path detection is suppressed when sourceFileMap is active (intentional grouping), but remains enforced for the default per-type mode

Fixed

  • Spec constants renamed from _camelCase to PascalCase to comply with naming conventions (underscore prefix is reserved for private instance fields, not constants)
  • Added #pragma warning disable MA0136 around raw string literals in spec files — in Release mode TreatWarningsAsErrors=True promoted these warnings to build errors
Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for ProxyGenerator generating into the same file name as the C# file</issue_title>
<issue_description>Today we generate TypeScript proxy objects into separate files called the same as the type.
We want an option that we can enable to allow for multiple TypeScript types from the same C# file into one file - named the same as the C# file - with .ts as extension instead.

  • You'll need to add the option in the CLI version and MSBuild version.
  • Add specs
  • Add documentation</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: einari <134365+einari@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for generating TypeScript proxy in same file as C# Add source-file-as-output-file option to ProxyGenerator Feb 25, 2026
@github-actions
Copy link

NuGet packages for this PR, e.g. Cratis.Arc:
https://github.com/cratis/arc/packages/1655206?version=19.6.5-pr1845.d0d93c9

@einari
Copy link
Contributor

einari commented Mar 1, 2026

@copilot seems to be introducing some regression here. Look at the failing specs in the .net build.

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

Copilot AI commented Mar 1, 2026

@copilot seems to be introducing some regression here. Look at the failing specs in the .net build.

Fixed in d751b7b. The spec files used _content, _firstContent, etc. as constant names (the _ prefix is only for private instance fields), and also lacked #pragma warning disable MA0136 around raw string literals. In Release mode TreatWarningsAsErrors=True promoted these to build errors. Both issues are now corrected.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Cratis/Arc/actions/runs/22405986475/attempts/1/jobs
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

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.

Add support for ProxyGenerator generating into the same file name as the C# file

2 participants