Closed jstedfast closed 2 years ago
Indeed, this is an edge case that doesn't work. There are undoubtedly thousands of names that wouldn't work in practice, such as int
, or System
, and this is also one of them.
Even if we wanted to fix this, I'm not sure it's possible to have some list of known "disallowed" names, so I don't think we even could fix this.
I think it's fair to close WONTFIX, I just wanted to present this as something that may (or may not?) be a "common" issue for newbies.
Obviously, for anyone that understands C# reasonably well, they'd figure out the problem and find a work-around pretty quickly.
@jstedfast understood, it's a perfectly reasonable bug, and hopefully not too many people run into it 😄 I think that the tourism board of Hawaii might be the main user to legitimately run into this with very little recourse 😁
Ideally such forbidden names should get blocked on creation. Like if you type the name of the app in VS, VS should refuse to continue and tell user that this name is not allowed. If you create it using dotnet
it should print out that this name is not allowed.
Then we don't have to fix it and no longer have to worry about. And new users don't spend minutes/hours of work into something that then suddenly fails at the very last step (compiling). Not sure which team/repo is responsible for VS/dotnet and where we could suggest this change.
@Symbai the problem is that the list of problematic names is enormous. Various C# reserved words, various names that conflict with built-in .NET types, etc. are all problematic. It's a list of literally thousands (if not even 10,000's or 100,000's) of names. And whether they cause a problematic conflict depends on the exact code that's in the template. Some names might work fine at first, but once you add one more thing to the project, the name could start to conflict.
I'm fine keeping this issue open to see if it is a sufficiently common problem, but so far I don't recall seeing it much across any project type, let alone .NET MAUI. We have various telemetry channels in Visual Studio and I don't think that using problematic names has ever shown up as a key failure point.
Ideally such forbidden names should get blocked on creation. Like if you type the name of the app in VS, VS should refuse to continue and tell user that this name is not allowed. If you create it using
dotnet
it should print out that this name is not allowed.
It's ok, I am a strong independent woman that is going to figure out renaming the class name to @MauiApp, since I don't want my web browser blocking me for searching a word that's banned by the government anyways.
As pointed out, this is not specific to .NET MAUI, naming your project like any type in code isn't going to work great. If this will ever be fixed, it needs to be done in tooling to prevent the project from even being created. There is nothing for us to do here.
Description
I just used Visual Studio for Mac 17.3 Preview 3 (in case that matters for the template being used) and I just so happened to name the app "MauiApp" which coincidentally conflicts with a type that is used in the generated MauiProgram.cs (and other files) which causes the following build errors:
Steps to Reproduce
Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
macOS 12.4
Did you find any workaround?
I can change the namespace to MauiApp1 to fix it.
Relevant log output