-
Notifications
You must be signed in to change notification settings - Fork 574
[dotnet-svcutil] Implement command switch for separating type files #5896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
0f5f0be
9b5ca9b
863dd3a
03a51af
dab071c
2cfda84
270c289
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Microsoft.Tools.ServiceModel.Svcutil.Metadata; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
|
|
@@ -13,6 +12,8 @@ | |
| using System.Text; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.CodeDom; | ||
| using Microsoft.Tools.ServiceModel.Svcutil.Metadata; | ||
| using DcNS = System.Runtime.Serialization; | ||
|
|
||
| namespace Microsoft.Tools.ServiceModel.Svcutil | ||
|
|
@@ -244,12 +245,31 @@ await serviceDescriptor.ImportMetadataAsync( | |
| using (await SafeLogger.WriteStartOperationAsync(options.Logger, "Processing Code DOM ...").ConfigureAwait(false)) | ||
| { | ||
| ToolConsole.WriteLine(SR.GeneratingFiles); | ||
| 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); | ||
|
mr-sven marked this conversation as resolved.
Outdated
|
||
| ToolConsole.WriteLine(filePath, LogTag.Important); | ||
|
mr-sven marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
|
mr-sven marked this conversation as resolved.
Outdated
|
||
| } | ||
|
Comment on lines
+251
to
+296
|
||
| else | ||
| { | ||
| CodeSerializer codeSerializer = new CodeSerializer(options, serviceDescriptor.MetadataDocuments); | ||
| var filePath = codeSerializer.Save(importModule.CodeCompileUnit); | ||
|
|
||
| CodeSerializer codeSerializer = new CodeSerializer(options, serviceDescriptor.MetadataDocuments); | ||
| var filePath = codeSerializer.Save(importModule.CodeCompileUnit); | ||
|
|
||
| // When in Infrastructure mode (WCF CS) it is assumed the output file path have been provided so no need to display it. | ||
| ToolConsole.WriteLineIf(options.ToolContext != OperationalContext.Infrastructure, filePath, LogTag.Important); | ||
| // When in Infrastructure mode (WCF CS) it is assumed the output file path have been provided so no need to display it. | ||
| ToolConsole.WriteLineIf(options.ToolContext != OperationalContext.Infrastructure, filePath, LogTag.Important); | ||
| } | ||
| } | ||
|
|
||
| return ToolConsole.ExitCode; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.