Change to SetterModifier
MODIFY
WalletWasabi.Fluent.Generators/AutoNotifyGenerator.cs
WalletWasabi.Fluent.Generators/AutoNotifyGenerator.cs
@@ -26,7 +26,7 @@ namespace WalletWasabi.Fluent
public string? PropertyName { get; set; }
- public AccessModifier Modifier { get; set; } = AccessModifier.Public;
+ public AccessModifier SetterModifier { get; set; } = AccessModifier.Public;
}
}";
@@ -192,10 +192,9 @@ namespace {namespaceName}
return;
}
- var overridenModifierOpt = attributeData.NamedArguments.SingleOrDefault(kvp => kvp.Key == "Modifier").Value;
- var modifier = ChooseModifier(overridenModifierOpt);
-
- if (modifier is null)
+ var overridenSetterModifierOpt = attributeData.NamedArguments.SingleOrDefault(kvp => kvp.Key == "SetterModifier").Value;
+ var setterModifier = ChooseSetterModifier(overridenSetterModifierOpt);
+ if (setterModifier is null)
{
source.Append($@"
public {fieldType} {propertyName}
@@ -206,25 +205,24 @@ namespace {namespaceName}
else
{
source.Append($@"
- {modifier} {fieldType} {propertyName}
+ public {fieldType} {propertyName}
{{
get => {fieldName};
- set => this.RaiseAndSetIfChanged(ref {fieldName}, value);
+ {setterModifier}set => this.RaiseAndSetIfChanged(ref {fieldName}, value);
}}");
}
-
- static string? ChooseModifier(TypedConstant overridenModifierOpt)
+ static string? ChooseSetterModifier(TypedConstant overridenSetterModifierOpt)
{
- if (!overridenModifierOpt.IsNull && overridenModifierOpt.Value is not null)
+ if (!overridenSetterModifierOpt.IsNull && overridenSetterModifierOpt.Value is not null)
{
- var value = (int)overridenModifierOpt.Value;
+ var value = (int)overridenSetterModifierOpt.Value;
return value switch
{
// None
0 => null,
// Public
- 1 => "public",
+ 1 => "",
// Protected
2 => "protected ",
// Private
@@ -232,12 +230,12 @@ namespace {namespaceName}
// Internal
4 => "internal ",
// Default
- _ => "public"
+ _ => ""
};
}
else
{
- return "public";
+ return "";
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/TestViewModel2.cs
WalletWasabi.Fluent/ViewModels/TestViewModel2.cs
public partial class TestViewModel2
{
[AutoNotify(PropertyName = "TestName")] private bool _prop1;
- [AutoNotify(Modifier = AccessModifier.None)] private bool _prop2 = false;
- [AutoNotify(Modifier = AccessModifier.Public)] private bool _prop3;
- [AutoNotify(Modifier = AccessModifier.Protected)] private bool _prop4;
- [AutoNotify(Modifier = AccessModifier.Private)] private bool _prop5;
- [AutoNotify(Modifier = AccessModifier.Internal)] private bool _prop6;
+ [AutoNotify(SetterModifier = AccessModifier.None)] private bool _prop2 = false;
+ [AutoNotify(SetterModifier = AccessModifier.Public)] private bool _prop3;
+ [AutoNotify(SetterModifier = AccessModifier.Protected)] private bool _prop4;
+ [AutoNotify(SetterModifier = AccessModifier.Private)] private bool _prop5;
+ [AutoNotify(SetterModifier = AccessModifier.Internal)] private bool _prop6;
}
}
\ No newline at end of file

Change to SetterModifier