-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sourceName forms not working #6853
Comments
I can confirm this. If the name contains any dashes "-" they will correctly be renamed in the file system, however, any references in .csproj files, or .sln files will instead replace all dashes with underscores. Similarly, all namespaces in the files generated have underscores instead of dashes. This bug essentially makes templating impossible with all project names containing dashes - like all kebab case projects, which is a popular naming convention. So it's rather serious. Even if .NET recommends pascal casing, it explicitly says to use the naming convention of your organization (in my case that's kebab casing) for project names. |
At a glance it seems like UnicodeCharacterUtilities.IsIdentifierPartCharacter only accepts letters, numbers and underscores as valid. This seems wrong to me - at least for references and project names. Both of which accept "-" '\u002D' The util method is called from DefaultSafeNamespaceValueFormFactory.ToSafeNamespace during processing. Seems the problem is it's using the same validation as namespaces for project names and references. |
Product
dotnet CLI (dotnet new)
Describe The Bug
According to https://github.com/dotnet/templating/wiki/Naming-and-default-value-forms, sourceName should be possible to be transformed using a predefined "namespace" form. Unfortunately this doesn't seem to be the case.
Take for example "sourceName" : "Re.Pro"
According to the documentation, using Re._Pro should result in the namespace transform. But this transform doesn't happen.
When running
dotnet new repro -n Some-Name
"Re._Pro" in solution files does not get replaced
"Re._Pro" in folder names does not get replaced
Indeed, "Re._Pro" is not replaced anywhere, as far as I tried.
See the attached template for reproduction.
Alternatively, "Re.Pro" is replaced, but the way the engine chooses the values it is replaced with is arcane to me.
When running
dotnet new repro -n Some-Name
"Re.Pro" in the solution file gets replaced with "Some_Name"
"Re.Pro" in folder names gets replaced with "Some-Name"
The result is a solution file targeting a project in the "Some_Name" directory, but the directory is actually called "Some-Name" .
To Reproduce
Steps:
Repro.zip
dotnet Info
output
.NET SDK: Version: 7.0.203 Commit: 5b005c19f5Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.203\
Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17
.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
6.0.313 [C:\Program Files\dotnet\sdk]
7.0.202 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Visual Studio Version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: