AvaloniaUI/AvaloniaVS

Incorrect behavior of adding a new Avalonia item to project in Visual Studio

JDr111 opened this issue · 1 comments

Describe the bug

Adding a new Avalonia item via Visual Studio's "New Item" dialog always produces a new XAML file with content of a previously deleted item, when the name of the newly added item is the same as the name of the previously deleted item.

To Reproduce

  1. In the Solution Explorer, right-click on the project (or any of the project's subfolders) -> Add -> New Item
  2. Pick "Avalonia" in the left category panel, pick any of the 5 templates (I tested "User Control" and "Templated Control")
  3. Give the new item a name.
  4. Edit the XAML of the newly added item.
  5. Save the XAML, rebuild the project.
  6. Delete the newly added item.
  7. Repeat steps 1, 2 and 3, giving the new item the same name as the previously deleted item. The template type doesn't have to be the same (I tested "User Control" and "Templated Control").
  8. The XAML of the newly added item will contain the contents of the previously deleted item.

Expected behavior

Each time a new item is added from the item templates, its content should match the one defined in the item template.

Avalonia version

11.0.9, 11.0.10

OS

Windows

Additional context

IDE: Visual Studio 2022 Community Edition
Current workaround: Restart Visual Studio

Note that the template you're using is coming from the VS extension package.
Please install the avalonia-dotnet-templates instead, which should work fine.

The templates provided by the extension have been removed in #453.
Future versions of the extension will install the avalonia-dotnet-templates automatically.