xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] Hyphen/dash in project name breaks it #8539

Open XavierAP opened 4 years ago

XavierAP commented 4 years ago

Description

A project created from a template with an hyphen in its name will not build. After creating a blank project from scratch, the App class name can't be resolved, across namespaces that should be the same. It looks like the "-" is replaced by "_" during project creation in some occurrences but not all.

I would very much have "-" not supported at all with a clear error message.

Steps to Reproduce

  1. Create a new Xamarin Forms project, with a name containing an hyphen.
  2. Try to build.

Expected Behavior

Build successful, since the project is fresh and unchanged from the template.

Actual Behavior

Time wasted, because the error message doesn't point to the problem either.

Basic Information

hartez commented 4 years ago

Hyphenated-Project Repro.zip

hartez commented 4 years ago

The attached project is what I got by creating a blank project with the name Hyphenated-Project.

The initial build issue is due to the head projects' references to the netstandard project; for example, in the Android project it references <AssemblyName>Hyphenated-Project.Android</AssemblyName>.

The netstandard project has an incorrect value (with the hyphen instead of the underscore) for "Default namespace"; any new items you add to the project are generated with invalid namespaces.