-
Hi, I would like to generate properties for Avalonia like https://github.com/HavenDV/DependencyPropertyGenerator does. Another question: is it possible to introduce a field with the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, by accessing public override void BuildAspect(IAspectBuilder<INamedType> builder)
{
base.BuildAspect(builder);
this.BuildAspectInstance(builder);
foreach (var instance in builder.AspectInstance.SecondaryInstances)
{
((StyledPropertyAttribute)instance.Aspect).BuildAspectInstance(builder);
}
}
private void BuildAspectInstance(IAspectBuilder<INamedType> builder)
{
// your original BuildAspect code here
}
Yes, if you use a template field, e.g.: [Template]
private readonly object Field;
...
var field = builder.Advice.IntroduceField(builder.Target, nameof(Field),
buildField: f =>
{
f.Name = $"{Name}Property";
f.Type = fieldType;
f.IsStatic = true;
f.Accessibility = Accessibility.Public;
f.InitializerExpression = ExpressionFactory.Parse(s.ToString());
}).Declaration; Though the inability to directly set |
Beta Was this translation helpful? Give feedback.
Yes, by accessing
builder.AspectInstance.SecondaryInstances
. For example, like this:Yes, if you use a template field, e.g.: