Skip to content
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

Creating new items in Visual Studio doesn't replace invalid characters in namespace #244

Open
joe7057 opened this issue Feb 3, 2024 · 1 comment
Labels

Comments

@joe7057
Copy link

joe7057 commented Feb 3, 2024

Describe the bug

Normally when creating a new file in Visual Studio, if the project name has an invalid character such as a dash ("-"), when a new file is generated, the namespace will use a substituted valid character, such as an underscore ("_"). The Avalonia item types (Class, Window, etc.) do not do this, resulting in un-compliable code.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Avalonia project in Visual Studio and choose a project name that includes the character "-".
  2. Build the project. It will build properly.
  3. In solution explorer, right-click on a folder and choose "Add" -> "New Item". Add a class, Avalonia Window, Avalonia UserControl, or other Avalonia item.
  4. Check the namespace that is auto-defined in the associated .cs file. It will contain the "-", which is not an allowed character in the namespace. The code will not compile.

Expected behavior

The "-" should be removed or substituted with a valid character. Microsoft uses "_".

Screenshots

image
image

Environment

  • OS: Windows
  • Avalonia-Version: 11.0.6
  • IDE: Visual Studio 2022 Community Edition
@joe7057 joe7057 added the bug label Feb 3, 2024
@hez2010
Copy link

hez2010 commented Feb 3, 2024

I believe this should be reported to Roslyn repo. There's nothing we can do on the Avalonia side.

@maxkatz6 maxkatz6 transferred this issue from AvaloniaUI/Avalonia Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants