Skip to content

Commit d860968

Browse files
committed
Fix modifier of the generated options builder object.
1 parent eb0ee98 commit d860968

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/DotNetCampus.CommandLine.Analyzer/Generators/BuilderGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace {{model.Namespace}};
7575
/// <summary>
7676
/// 辅助 <see cref="{{model.CommandObjectType.ToGlobalDisplayString()}}"/> 生成命令行选项、谓词或处理函数的创建。
7777
/// </summary>
78-
internal sealed class {{model.GetBuilderTypeName()}}
78+
{{(model.IsPublic ? "public" : "internal")}} sealed class {{model.GetBuilderTypeName()}}
7979
{
8080
public static object CreateInstance(global::DotNetCampus.Cli.CommandLine commandLine)
8181
{

src/DotNetCampus.CommandLine.Analyzer/Generators/ModelProviding/CommandModelProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ public static IncrementalValuesProvider<CommandObjectGeneratingModel> SelectComm
8181

8282
var @namespace = typeSymbol.ContainingNamespace.ToDisplayString();
8383
var verbName = attribute?.ConstructorArguments[0].Value?.ToString();
84+
var isPublic = typeSymbol.DeclaredAccessibility == Accessibility.Public;
8485

8586
return new CommandObjectGeneratingModel
8687
{
8788
Namespace = @namespace,
8889
CommandObjectType = typeSymbol,
90+
IsPublic = isPublic,
8991
VerbName = verbName,
9092
IsHandler = isHandler,
9193
OptionProperties = optionProperties,
@@ -132,6 +134,8 @@ internal record CommandObjectGeneratingModel
132134

133135
public required INamedTypeSymbol CommandObjectType { get; init; }
134136

137+
public required bool IsPublic { get; init; }
138+
135139
public required string? VerbName { get; init; }
136140

137141
public required bool IsHandler { get; init; }

0 commit comments

Comments
 (0)