22// The .NET Foundation licenses this file to you under the MIT license.
33
44using System . CommandLine ;
5- using System . Text . RegularExpressions ;
65using Aspire . Cli . Certificates ;
76using Aspire . Cli . Configuration ;
87using Aspire . Cli . DotNet ;
1312using Aspire . Cli . Templating ;
1413using Aspire . Cli . Utils ;
1514using Semver ;
16- using Spectre . Console ;
1715using NuGetPackage = Aspire . Shared . NuGetPackageCli ;
1816
1917namespace Aspire . Cli . Commands ;
@@ -203,9 +201,6 @@ public virtual async Task<string> PromptForProjectNameAsync(string defaultName,
203201 return await interactionService . PromptForStringAsync (
204202 NewCommandStrings . EnterTheProjectName ,
205203 defaultValue : defaultName ,
206- validator : name => ProjectNameValidator . IsProjectNameValid ( name )
207- ? ValidationResult . Success ( )
208- : ValidationResult . Error ( NewCommandStrings . InvalidProjectName ) ,
209204 cancellationToken : cancellationToken ) ;
210205 }
211206
@@ -219,21 +214,3 @@ public virtual async Task<ITemplate> PromptForTemplateAsync(ITemplate[] validTem
219214 ) ;
220215 }
221216}
222-
223- internal static partial class ProjectNameValidator
224- {
225- // Regex for Unicode-aware project name validation:
226- // - Starts with Unicode letter or number [\p{L}\p{N}]
227- // - Can contain Unicode letters, numbers, connector punctuation (underscore), dash, dot, and combining marks
228- // - Must end with Unicode letter or number, optionally followed by combining marks
229- // - Length: 1-254 characters
230- // - Excludes unsafe characters: / \ : * ? " < > |
231- [ GeneratedRegex ( @"^[\p{L}\p{N}]([\p{L}\p{N}\p{Pc}.\-\p{Mn}\p{Mc}]{0,252}[\p{L}\p{N}][\p{Mn}\p{Mc}]*|[\p{L}\p{N}\p{Pc}.\-\p{Mn}\p{Mc}]{0,252}[\p{L}\p{N}])?$" , RegexOptions . Compiled ) ]
232- internal static partial Regex GetAssemblyNameRegex ( ) ;
233-
234- public static bool IsProjectNameValid ( string projectName )
235- {
236- var regex = GetAssemblyNameRegex ( ) ;
237- return regex . IsMatch ( projectName ) ;
238- }
239- }
0 commit comments