From e99549aefa5a72c17057e56cedadb2504873b330 Mon Sep 17 00:00:00 2001 From: Artyom Date: Fri, 4 Nov 2022 18:23:26 +0300 Subject: [PATCH 1/2] fix: Name Generation for Identical View Class Names --- README.md | 6 ++ .../App.xaml.cs | 3 +- .../Controls/SignUpView.xaml | 38 +++++++++ .../Controls/SignUpView.xaml.cs | 53 ++++++++++++ .../Views/SignUpView.xaml | 32 +------- .../Views/SignUpView.xaml.cs | 31 +------ .../Views/View.cs | 2 - .../XamlXNameResolverTests.cs | 29 +++---- .../Domain/ICodeGenerator.cs | 2 +- .../Domain/INameResolver.cs | 48 +---------- src/Avalonia.NameGenerator/Generator.cs | 6 +- .../Generator/AvaloniaNameGenerator.cs | 13 ++- .../InitializeComponentCodeGenerator.cs | 3 +- .../Generator/OnlyPropertiesCodeGenerator.cs | 4 +- .../Generator/XamlXNameResolver.cs | 15 ++-- .../GeneratorOptions.cs | 81 +++++++------------ 16 files changed, 173 insertions(+), 193 deletions(-) create mode 100644 src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml create mode 100644 src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml.cs diff --git a/README.md b/README.md index 450544b..52fb996 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,11 @@ The `x:Name` generator can be configured via MsBuild properties that you can put The generator will process only XAML files with base classes' namespaces matching the specified glob pattern(s). Example: `MyApp.Presentation.*`, `MyApp.Presentation.Views;MyApp.Presentation.Controls` +- `AvaloniaNameGeneratorViewFileNamingStrategy` + Possible values: `ClassName`, `NamespaceAndClassName` + Default value: `NamespaceAndClassName` + Determines how the automatically generated view files should be [named](https://github.com/AvaloniaUI/Avalonia.NameGenerator/issues/92). + The default values are given by: ```xml @@ -119,6 +124,7 @@ The default values are given by: internal * * + NamespaceAndClassName diff --git a/src/Avalonia.NameGenerator.Sandbox/App.xaml.cs b/src/Avalonia.NameGenerator.Sandbox/App.xaml.cs index 896de18..320d78b 100644 --- a/src/Avalonia.NameGenerator.Sandbox/App.xaml.cs +++ b/src/Avalonia.NameGenerator.Sandbox/App.xaml.cs @@ -1,6 +1,5 @@ using Avalonia.Markup.Xaml; using Avalonia.NameGenerator.Sandbox.ViewModels; -using Avalonia.NameGenerator.Sandbox.Views; namespace Avalonia.NameGenerator.Sandbox; @@ -10,7 +9,7 @@ public class App : Application public override void OnFrameworkInitializationCompleted() { - var view = new SignUpView + var view = new Views.SignUpView { ViewModel = new SignUpViewModel() }; diff --git a/src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml b/src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml new file mode 100644 index 0000000..0f26a6f --- /dev/null +++ b/src/Avalonia.NameGenerator.Sandbox/Controls/SignUpView.xaml @@ -0,0 +1,38 @@ + + + + + + + + +