- tweak: Change views logic

This commit is contained in:
2025-01-16 21:07:50 +03:00
parent 5d7f443532
commit 6cb4666d08
9 changed files with 213 additions and 170 deletions

View File

@@ -39,32 +39,28 @@ public class DependencyAutoGenerator : IIncrementalGenerator
var namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
var className = classDeclarationSyntax.Identifier.Text;
var defaultConstruct = $@"public {className}(){{}}";
var defaultConstruct = $@"public {className}(){{
InitialiseInDesignMode();
}}";
var propertiesGenerated = GetProperties(classSymbol).ToList();
var constr = propertiesGenerated.Select(a => $"{a.Type.ToDisplayString()} g{a.Name}");
var body = propertiesGenerated.Select(a => $"this.{a.Name} = g{a.Name};");
if (!constr.Any()) defaultConstruct = "";
//if (!constr.Any()) defaultConstruct = "";
var code = $@"// <auto-generated/>
using System;
using System.Collections.Generic;
namespace {namespaceName};
partial class {className}
{{
{defaultConstruct}
public {className}(
{string.Join(",\n\t\t", constr)}
) : base(){{
{string.Join("\n\t\t", body)}
if (Avalonia.Controls.Design.IsDesignMode) InitialiseInDesignMode();
else Initialise();
Initialise();
}}
}}
";