Skip to content

Commit 8a00c7e

Browse files
committed
Renames Content class to SystemCommandlineContent
Renames the `Content` class to `SystemCommandlineContent` for clarity and consistency. This change improves code organization and readability by providing a more descriptive name for the class that contains content related to system command line generation.
1 parent fc3c3da commit 8a00c7e

File tree

6 files changed

+57
-52
lines changed

6 files changed

+57
-52
lines changed

new-cli/GitVersion.Cli.Generator.Tests/SystemCommandlineGeneratorTests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public class SystemCommandlineGeneratorTests
2727
/*language=cs*/
2828
private const string ExpectedCommandImplText =
2929
$$"""
30-
{{Content.GeneratedHeader}}
30+
{{Constants.GeneratedHeader}}
3131
using System.CommandLine;
3232
using System.CommandLine.Binding;
3333
34-
using {{Content.CommandNamespaceName}};
34+
using {{Constants.CommandNamespaceName}};
3535
36-
namespace {{Content.GeneratedNamespaceName}};
36+
namespace {{Constants.GeneratedNamespaceName}};
3737
3838
public class TestCommandImpl : Command, ICommandImpl
3939
{
@@ -70,14 +70,14 @@ Task<int> Run(ParseResult parseResult, CancellationToken cancellationToken)
7070
/*language=cs*/
7171
private const string ExpectedCommandsModuleText =
7272
$$"""
73-
{{Content.GeneratedHeader}}
73+
{{Constants.GeneratedHeader}}
7474
using System.CommandLine;
75-
using {{Content.InfrastructureNamespaceName}};
76-
using {{Content.CommandNamespaceName}};
77-
using {{Content.CommonNamespaceName}};
75+
using {{Constants.InfrastructureNamespaceName}};
76+
using {{Constants.CommandNamespaceName}};
77+
using {{Constants.CommonNamespaceName}};
7878
using Microsoft.Extensions.DependencyInjection;
7979
80-
namespace {{Content.GeneratedNamespaceName}};
80+
namespace {{Constants.GeneratedNamespaceName}};
8181
8282
public class CommandsModule : IGitVersionModule
8383
{
@@ -93,11 +93,11 @@ public void RegisterTypes(IServiceCollection services)
9393
/*language=cs*/
9494
private const string ExpectedRootCommandImplText =
9595
$$"""
96-
{{Content.GeneratedHeader}}
96+
{{Constants.GeneratedHeader}}
9797
using System.CommandLine;
9898
99-
using {{Content.CommonNamespaceName}};
100-
namespace {{Content.GeneratedNamespaceName}};
99+
using {{Constants.CommonNamespaceName}};
100+
namespace {{Constants.GeneratedNamespaceName}};
101101
102102
public class RootCommandImpl : RootCommand
103103
{
@@ -127,10 +127,10 @@ private void AddCommand(ICommandImpl command, IDictionary<string, ICommandImpl>
127127
/*language=cs*/
128128
private const string TestCommandSourceCode =
129129
$$"""
130-
using {{Content.InfrastructureNamespaceName}};
130+
using {{Constants.InfrastructureNamespaceName}};
131131
using Microsoft.Extensions.Logging;
132132
133-
namespace {{Content.CommandNamespaceName}};
133+
namespace {{Constants.CommandNamespaceName}};
134134
135135
[CommandAttribute("test", "Test description.")]
136136
public class TestCommand(ILogger logger): ICommand<TestCommandSettings>
@@ -146,10 +146,10 @@ public Task<int> InvokeAsync(TestCommandSettings settings, CancellationToken can
146146
/*language=cs*/
147147
private const string TestCommandSettingsSourceCode =
148148
$$"""
149-
using {{Content.InfrastructureNamespaceName}};
149+
using {{Constants.InfrastructureNamespaceName}};
150150
using Microsoft.Extensions.Logging;
151151
152-
namespace {{Content.CommandNamespaceName}};
152+
namespace {{Constants.CommandNamespaceName}};
153153
154154
public record TestCommandSettings
155155
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace GitVersion;
44

55
public abstract class CommandBaseGenerator : IIncrementalGenerator
66
{
7-
private const string CommandInterfaceFullName = $"{Content.CommonNamespaceName}.ICommand<T>";
8-
private const string CommandAttributeFullName = $"{Content.CommonNamespaceName}.CommandAttribute";
9-
private const string CommandAttributeGenericFullName = $"{Content.CommonNamespaceName}.CommandAttribute<T>";
10-
private const string OptionAttributeFullName = $"{Content.CommonNamespaceName}.OptionAttribute";
7+
private const string CommandInterfaceFullName = $"{Constants.CommonNamespaceName}.ICommand<T>";
8+
private const string CommandAttributeFullName = $"{Constants.CommonNamespaceName}.CommandAttribute";
9+
private const string CommandAttributeGenericFullName = $"{Constants.CommonNamespaceName}.CommandAttribute<T>";
10+
private const string OptionAttributeFullName = $"{Constants.CommonNamespaceName}.OptionAttribute";
1111

1212
public void Initialize(IncrementalGeneratorInitializationContext context)
1313
{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace GitVersion;
2+
3+
public static class Constants
4+
{
5+
internal const string GeneratedNamespaceName = "GitVersion.Generated";
6+
internal const string CommonNamespaceName = "GitVersion";
7+
internal const string InfrastructureNamespaceName = "GitVersion.Infrastructure";
8+
internal const string CommandNamespaceName = "GitVersion.Commands";
9+
10+
/*language=cs*/
11+
internal const string GeneratedHeader =
12+
"""
13+
//------------------------------------------------------------------------------
14+
// <auto-generated>
15+
// This code was generated by a tool.
16+
//
17+
// Changes to this file may cause incorrect behavior and will be lost if
18+
// the code is regenerated.
19+
// </auto-generated>
20+
//------------------------------------------------------------------------------
21+
#nullable enable
22+
""";
23+
}

new-cli/GitVersion.Cli.Generator/Content.cs renamed to new-cli/GitVersion.Cli.Generator/SystemCommandlineContent.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
namespace GitVersion;
22

3-
public static class Content
3+
public static class SystemCommandlineContent
44
{
5-
internal const string GeneratedNamespaceName = "GitVersion.Generated";
6-
internal const string CommonNamespaceName = "GitVersion";
7-
internal const string InfrastructureNamespaceName = "GitVersion.Infrastructure";
8-
internal const string CommandNamespaceName = "GitVersion.Commands";
9-
10-
/*language=cs*/
11-
internal const string GeneratedHeader = """
12-
//------------------------------------------------------------------------------
13-
// <auto-generated>
14-
// This code was generated by a tool.
15-
//
16-
// Changes to this file may cause incorrect behavior and will be lost if
17-
// the code is regenerated.
18-
// </auto-generated>
19-
//------------------------------------------------------------------------------
20-
#nullable enable
21-
""";
22-
235
/*language=cs*/
246
public const string CommandImplContent = $$$"""
25-
{{{GeneratedHeader}}}
7+
{{{Constants.GeneratedHeader}}}
268
using System.CommandLine;
279
using System.CommandLine.Binding;
2810
@@ -78,7 +60,7 @@ Task<int> Run(ParseResult parseResult, CancellationToken cancellationToken)
7860

7961
/*language=cs*/
8062
public const string RootCommandImplContent = $$$"""
81-
{{{GeneratedHeader}}}
63+
{{{Constants.GeneratedHeader}}}
8264
using System.CommandLine;
8365
8466
using {{CommonNamespaceName}};
@@ -111,7 +93,7 @@ private void AddCommand(ICommandImpl command, IDictionary<string, ICommandImpl>
11193

11294
/*language=cs*/
11395
public const string CommandsModuleContent = $$$"""
114-
{{{GeneratedHeader}}}
96+
{{{Constants.GeneratedHeader}}}
11597
using System.CommandLine;
11698
using {{InfrastructureNamespaceName}};
11799
using {{CommandNamespaceName}};

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ internal override void GenerateSourceCode(SourceProductionContext context, Immut
1010
if (commandInfo == null)
1111
continue;
1212

13-
var commandHandlerTemplate = Template.Parse(Content.CommandImplContent);
13+
var commandHandlerTemplate = Template.Parse(SystemCommandlineContent.CommandImplContent);
1414

1515
var commandHandlerSource = commandHandlerTemplate.Render(new
1616
{
1717
Model = commandInfo,
18-
Content.GeneratedNamespaceName
18+
Constants.GeneratedNamespaceName
1919
}, member => member.Name);
2020

2121
context.AddSource($"{commandInfo.CommandTypeName}Impl.g.cs", string.Join("\n", commandHandlerSource));
2222
}
2323

24-
var commandHandlersModuleTemplate = Template.Parse(Content.CommandsModuleContent);
24+
var commandHandlersModuleTemplate = Template.Parse(SystemCommandlineContent.CommandsModuleContent);
2525
var commandHandlersModuleSource = commandHandlersModuleTemplate.Render(new
2626
{
2727
Model = commandInfos,
28-
Content.GeneratedNamespaceName,
29-
Content.CommonNamespaceName,
30-
Content.InfrastructureNamespaceName,
31-
Content.CommandNamespaceName
28+
Constants.GeneratedNamespaceName,
29+
Constants.CommonNamespaceName,
30+
Constants.InfrastructureNamespaceName,
31+
Constants.CommandNamespaceName
3232
}, member => member.Name);
3333
context.AddSource("CommandsModule.g.cs", string.Join("\n", commandHandlersModuleSource));
3434

35-
var rootCommandHandlerTemplate = Template.Parse(Content.RootCommandImplContent);
35+
var rootCommandHandlerTemplate = Template.Parse(SystemCommandlineContent.RootCommandImplContent);
3636
var rootCommandHandlerSource = rootCommandHandlerTemplate.Render(new
3737
{
38-
Content.GeneratedNamespaceName,
39-
Content.CommonNamespaceName
38+
Constants.GeneratedNamespaceName,
39+
Constants.CommonNamespaceName
4040
}, member => member.Name);
4141
context.AddSource("RootCommandImpl.g.cs", string.Join("\n", rootCommandHandlerSource));
4242
}

new-cli/GitVersion.Cli/TestCommandSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace GitVersion.Commands.Test.Settings;
22

33
public record TestCommandSettings : GitVersionSettings
44
{
5-
[Option("--input-file", "The input version file")]
5+
[Option("--input-file", description: "The input version file", aliases: ["-i"])]
66
public required string InputFile { get; init; }
77
}

0 commit comments

Comments
 (0)