@@ -145,6 +145,8 @@ private string GenerateCommandLineAsCode(ImmutableArray<InterceptorGeneratingMod
145
145
public static T CommandLine_As_{{ NamingHelper . MakePascalCase ( model . CommandObjectType . ToDisplayString ( ) ) }} <T>(this global::DotNetCampus.Cli.CommandLine commandLine)
146
146
where T : {{ model . CommandObjectType . ToGlobalDisplayString ( ) }}
147
147
{
148
+ // 请确保 {{ model . CommandObjectType . Name }} 类型中至少有一个属性标记了 [Option] 或 [Value] 特性;
149
+ // 否则下面的 {{ model . GetBuilderTypeName ( ) }} 类型将不存在,导致编译不通过。
148
150
return (T)global::{{ model . CommandObjectType . ContainingNamespace }} .{{ model . GetBuilderTypeName ( ) }} .CreateInstance(commandLine);
149
151
}
150
152
""" ;
@@ -161,6 +163,8 @@ private string GenerateCommandBuilderAddHandlerCode(ImmutableArray<InterceptorGe
161
163
public static global::DotNetCampus.Cli.IAsyncCommandRunnerBuilder CommandBuilder_AddHandler_{{ NamingHelper . MakePascalCase ( model . CommandObjectType . ToDisplayString ( ) ) }} <T>(this global::DotNetCampus.Cli.ICoreCommandRunnerBuilder builder)
162
164
where T : {{ model . CommandObjectType . ToGlobalDisplayString ( ) }} , global::DotNetCampus.Cli.ICommandHandler
163
165
{
166
+ // 请确保 {{ model . CommandObjectType . Name }} 类型中至少有一个属性标记了 [Option] 或 [Value] 特性;
167
+ // 否则下面的 {{ model . GetBuilderTypeName ( ) }} 类型将不存在,导致编译不通过。
164
168
return global::DotNetCampus.Cli.CommandRunnerBuilderExtensions.AddHandler<T>(builder, {{ ( model . VerbName is { } verb ? $ "\" { verb } \" " : "null" ) }} , global::{{ model . CommandObjectType . ContainingNamespace }} .{{ model . GetBuilderTypeName ( ) }} .CreateInstance);
165
169
}
166
170
""" ;
@@ -178,6 +182,8 @@ private string GenerateCommandBuilderAddHandlerActionCode(ImmutableArray<Interce
178
182
global::{{ parameterTypeFullName }} handler)
179
183
where T : class
180
184
{
185
+ // 请确保 {{ model . CommandObjectType . Name }} 类型中至少有一个属性标记了 [Option] 或 [Value] 特性;
186
+ // 否则下面的 {{ model . GetBuilderTypeName ( ) }} 类型将不存在,导致编译不通过。
181
187
return global::DotNetCampus.Cli.CommandRunnerBuilderExtensions.AddHandler<T>(builder, {{ ( model . VerbName is { } verb ? $ "\" { verb } \" " : "null" ) }} , global::{{ model . CommandObjectType . ContainingNamespace }} .{{ model . GetBuilderTypeName ( ) }} .CreateInstance, handler);
182
188
}
183
189
""" ;
0 commit comments