Skip to content

Commit 15b401d

Browse files
committed
Refactor module naming and improve code consistency
Renamed `CommandsImplModule` to `CommandsModule` for clarity and updated related references. Adjusted the accessibility of `GeneratedHeader` and added required namespaces. Enhanced syntax consistency and replaced array construction with shorthand for better readability.
1 parent 7c59034 commit 15b401d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

new-cli/GitVersion.Cli.Generator/CommandImplGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ where optionAttribute is not null
118118
CommandDescription = description,
119119
SettingsTypeName = settingsType.Name,
120120
SettingsTypeNamespace = settingsType.ContainingNamespace.ToDisplayString(),
121-
SettingsProperties = settingsPropertyInfos.ToArray()
121+
SettingsProperties = [.. settingsPropertyInfos]
122122
};
123123
return commandInfo;
124124
}
@@ -132,7 +132,7 @@ private static SettingsPropertyInfo MapToPropertyInfo(IPropertySymbol propertySy
132132
name.NotNull();
133133
description.NotNull();
134134

135-
string alias = string.Empty;
135+
var alias = string.Empty;
136136
if (ctorArguments.Length == 3)
137137
{
138138
var aliasesArgs = ctorArguments[2];

new-cli/GitVersion.Cli.Generator/Content.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace GitVersion;
33
public static class Content
44
{
55
/*language=cs*/
6-
private const string GeneratedHeader = """
6+
public const string GeneratedHeader = """
77
//------------------------------------------------------------------------------
88
// <auto-generated>
99
// This code was generated by a tool.
@@ -20,6 +20,8 @@ public static class Content
2020
{{{GeneratedHeader}}}
2121
using System.CommandLine;
2222
using System.CommandLine.Binding;
23+
using System.Threading;
24+
using System.Threading.Tasks;
2325
2426
using {{Model.CommandTypeNamespace}};
2527
{{- if Model.SettingsTypeNamespace != Model.CommandTypeNamespace }}
@@ -55,7 +57,7 @@ public class {{Model.CommandTypeName}}Impl : Command, ICommandImpl
5557
{{- for $prop in $settingsProperties ~}}
5658
Add({{$prop.Name}}Option);
5759
{{~ end ~}}
58-
60+
5961
this.SetAction(Run);
6062
return;
6163
@@ -76,7 +78,10 @@ Task<int> Run(ParseResult parseResult, CancellationToken cancellationToken)
7678
/*language=cs*/
7779
public const string RootCommandImplContent = $$$"""
7880
{{{GeneratedHeader}}}
81+
using System.Collections.Generic;
7982
using System.CommandLine;
83+
using System.Linq;
84+
8085
using {{InfraNamespaceName}};
8186
namespace {{Namespace}};
8287
@@ -115,7 +120,7 @@ private void AddCommand(ICommandImpl command, IDictionary<string, ICommandImpl>
115120
116121
namespace {{Namespace}};
117122
118-
public class CommandsImplModule : IGitVersionModule
123+
public class CommandsModule : IGitVersionModule
119124
{
120125
public void RegisterTypes(IContainerRegistrar services)
121126
{
@@ -124,7 +129,6 @@ public void RegisterTypes(IContainerRegistrar services)
124129
{{~ for $command in $commands ~}}
125130
services.AddSingleton<{{$command.CommandTypeName}}>();
126131
services.AddSingleton<ICommandImpl, {{$command.CommandTypeName}}Impl>();
127-
128132
{{~ end ~}}
129133
}
130134
}

new-cli/GitVersion.Cli.Generator/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"SourceGenerator": {
44
"commandName": "DebugRoslynComponent",
5-
"targetProject": "..\\GitVersion.Cli\\GitVersion.Cli.csproj"
5+
"targetProject": "../GitVersion.Cli/GitVersion.Cli.csproj"
66
}
77
}
8-
}
8+
}

new-cli/GitVersion.Cli/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{
99
new CoreModule(),
1010
new LibGit2SharpCoreModule(),
11-
new CommandsImplModule()
11+
new CommandsModule()
1212
};
1313

1414
var cts = new CancellationTokenSource();

0 commit comments

Comments
 (0)