AvaloniaUI / avalonia-dotnet-templates

Avalonia Templates for `dotnet new`
MIT License
516 stars 89 forks source link

Template namespaces missing subfolder #235

Open moon6969 opened 1 year ago

moon6969 commented 1 year ago

When adding a new Avalonia Window or UserControl in a subfolder, the new item does not include the subfolder in the namespace. EG: for /Views/UserControl1.axaml.cs :

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace AvaloniaTemplateNamespaceIssue;

public partial class UserControl1 : UserControl

This is different & confusing behaviour since the initial items created by the new project template do include the subfolder. EG: for /Views/MainWindow.axaml.cs :

using Avalonia.Controls;

namespace AvaloniaTemplateNamespaceIssue.Views;

public partial class MainWindow : Window

Avalonia v11.0.4 Avalonia for Visual Studio 2022 v11.1 Avalonia.Templates v11.0.2

Mrxx99 commented 1 year ago

This is a limitation of the dotnet templating engine currently, see https://github.com/dotnet/templating/issues/6010. Feel free to upvote and add your voice to that issue.