mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Validate names for invalid for C# namespaces in cmdpal (#39401)
## Summary of the Pull Request The Command Palette allows users to create extensions with dashes in their names, which is invalid for C# namespaces. This causes projects to fail during build because the name cannot be used as a valid namespace. ## Changes - Updated the validation regex in `NewExtensionForm.cs` to only allow valid C# identifiers - Now only allows names starting with a letter or underscore, followed by letters, numbers, or underscores - Explicitly prevents dashes, spaces, and other special characters - Improved the error message to clearly explain the requirements for valid C# identifiers ## Before Previously, the input only validated that no spaces were used: ```csharp "regex": "^[^\\s]+$" ``` ## After Now the input properly validates for C# namespace compatibility: ```csharp "regex": "^[a-zA-Z_][a-zA-Z0-9_]*$" ``` This ensures that users cannot create extension projects with names that would fail to build. ## PR Checklist - [ ] **Closes:** https://github.com/microsoft/PowerToys/issues/38522
This commit is contained in:
@@ -55,7 +55,7 @@ internal sealed partial class NewExtensionForm : NewExtensionFormBase
|
||||
"errorMessage": {{FormatJsonString(Properties.Resources.builtin_create_extension_name_required)}},
|
||||
"id": "ExtensionName",
|
||||
"placeholder": "ExtensionName",
|
||||
"regex": "^[^\\s]+$"
|
||||
"regex": "^[a-zA-Z_][a-zA-Z0-9_]*$"
|
||||
},
|
||||
{
|
||||
"type": "TextBlock",
|
||||
|
||||
Reference in New Issue
Block a user