- fix: DesignMode think
This commit is contained in:
@@ -39,23 +39,28 @@ public class DependencyAutoGenerator : IIncrementalGenerator
|
||||
var namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
|
||||
var className = classDeclarationSyntax.Identifier.Text;
|
||||
|
||||
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 = "";
|
||||
|
||||
var propertiesGeneratedC = GetProperties(classSymbol)
|
||||
.Where(a=>
|
||||
SourceHelper.HasAttribute(a,"Nebula.Shared.Attributes.DesignConstructAttribute"))
|
||||
.ToList();
|
||||
|
||||
var bodyC = propertiesGeneratedC.Select(a => $"this.{a.Name} = new {a.Type.ToDisplayString()}();");
|
||||
|
||||
var code = $@"// <auto-generated/>
|
||||
namespace {namespaceName};
|
||||
|
||||
partial class {className}
|
||||
{{
|
||||
{defaultConstruct}
|
||||
|
||||
public {className}(){{
|
||||
{string.Join("\n\t\t", bodyC)}
|
||||
InitialiseInDesignMode();
|
||||
}}
|
||||
public {className}(
|
||||
{string.Join(",\n\t\t", constr)}
|
||||
) : base(){{
|
||||
|
||||
Reference in New Issue
Block a user