[dotnet-svcutil] Implement command switch for separating type files#5896
[dotnet-svcutil] Implement command switch for separating type files#5896mr-sven wants to merge 7 commits intodotnet:mainfrom
Conversation
|
@dotnet-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Adds a new --separateFiles / -sf command-line switch to dotnet-svcutil to emit generated proxy types into separate files, addressing large single-file generation scenarios (e.g., very large WSDLs that degrade IDE performance).
Changes:
- Introduces a new command switch (
separateFiles/sf) and exposes it through options/serialization. - Updates help text and resource strings to document the new switch.
- Implements per-type file emission during CodeDOM serialization when the switch is enabled.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| src/dotnet-svcutil/lib/src/Tool.cs | Implements the per-type file generation path when SeparateFiles is enabled. |
| src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs | Adds the SeparateFiles command switch (-sf). |
| src/dotnet-svcutil/lib/src/HelpGenerator.cs | Adds help entry for --separateFiles. |
| src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs | Adds SeparateFiles option key/property and serialization support. |
| src/dotnet-svcutil/lib/src/SR.resx | Adds the English help resource string for the new switch. |
| src/dotnet-svcutil/lib/src/xlf/SR.zh-Hant.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.zh-Hans.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.tr.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.ru.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.pt-BR.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.pl.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.ko.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.ja.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.it.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.fr.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.es.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.de.xlf | Adds localized resource entry for help text (currently untranslated). |
| src/dotnet-svcutil/lib/src/xlf/SR.cs.xlf | Adds localized resource entry for help text (currently untranslated). |
| if (options.SeparateFiles == true) | ||
| { | ||
| foreach (CodeNamespace @namespace in importModule.CodeCompileUnit.Namespaces) | ||
| { | ||
| foreach (CodeTypeDeclaration type in @namespace.Types) | ||
| { | ||
| options.OutputFile = new FileInfo(Path.Combine(options.OutputDir.FullName, $"{type.Name}{CodeSerializer.GetOutputFileExtension(options)}")); | ||
| CodeSerializer codeSerializer = new CodeSerializer(options, serviceDescriptor.MetadataDocuments); | ||
| CodeCompileUnit compileUnit = new CodeCompileUnit(); | ||
| CodeNamespace splitNamespace = new CodeNamespace(@namespace.Name); | ||
| compileUnit.Namespaces.Add(splitNamespace); | ||
| splitNamespace.Types.Add(type); | ||
| var filePath = codeSerializer.Save(compileUnit); | ||
| ToolConsole.WriteLine(filePath, LogTag.Important); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
When SeparateFiles is enabled, the tool writes many .cs files but does not appear to clean up previously generated type files in the output directory. This can leave stale types behind on reruns/updates and cause compilation conflicts. Consider deleting previously generated type files (or generating into a dedicated subfolder and managing it) before writing the new set.
There was a problem hiding this comment.
@mconnew I'm not sure about this, cleaning up the output directory is nothing I would recommend. That should be a user task.
| if (options.SeparateFiles == true) | ||
| { | ||
| foreach (CodeNamespace @namespace in importModule.CodeCompileUnit.Namespaces) | ||
| { | ||
| foreach (CodeTypeDeclaration type in @namespace.Types) | ||
| { | ||
| options.OutputFile = new FileInfo(Path.Combine(options.OutputDir.FullName, $"{type.Name}{CodeSerializer.GetOutputFileExtension(options)}")); | ||
| CodeSerializer codeSerializer = new CodeSerializer(options, serviceDescriptor.MetadataDocuments); | ||
| CodeCompileUnit compileUnit = new CodeCompileUnit(); | ||
| CodeNamespace splitNamespace = new CodeNamespace(@namespace.Name); | ||
| compileUnit.Namespaces.Add(splitNamespace); | ||
| splitNamespace.Types.Add(type); | ||
| var filePath = codeSerializer.Save(compileUnit); | ||
| ToolConsole.WriteLine(filePath, LogTag.Important); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
New separate-files behavior is introduced here, but there’s no accompanying test coverage verifying (1) multiple files are produced, (2) names are deterministic/collision-safe, and (3) update/rerun behavior doesn’t leave stale files. Since this repo has an existing baseline/E2E test harness, it would be good to add a targeted test case for --separateFiles/-sf.
|
@mr-sven, copilot has raised some genuine gaps in the implementation. If you have any questions about any of its feedback, feel free to mention me with your question and I'll do my best to answer them. |
Implemented command line switch (-separateFiles|-sf) to implement requested feature #3512
Tested using current Cisco AXL 15 successfully:
dotnet-svcutil.exe *.wsdl *.xsd -n "*,Cisco.UCM.AXL15" -sf.Created around 5623 separate files.