Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ This documentation covers using ReactiveUI Source Generators to simplify and enh
ReactiveUI Source Generators automatically generate ReactiveUI objects to streamline your code. These Source Generators are designed to work with ReactiveUI V19.5.31+ and support the following features:

- `[Reactive]` With field and access modifiers, partial property support (C# 13 Visual Studio Version 17.12.0), partial properties with initializer support (C# preview only)
- `[Reactive(SetModifier = AccessModifier.Protected)]` With field and access modifiers.
- `[Reactive(SetModifier = AccessModifier.Protected)]` With field and access modifiers, (Not Required for partial properties, configure set accessor with the property decalaration).
- `[Reactive(Inheritance = InheritanceModifier.Virtual)]` With field and access modifiers. This will generate a virtual property.
- `[Reactive(UseRequired = true)]` With field and access modifiers. This will generate a required property.
- `[Reactive(UseRequired = true)]` With field and access modifiers. This will generate a required property, (Not Required for partial properties, use required keyword for property decalaration).
- `[ObservableAsProperty]` With field, method, Observable property and partial property support (C# 13 Visual Studio Version 17.12.0)
- `[ObservableAsProperty(ReadOnly = false)]` Removes readonly keyword from the generated helper field
- `[ObservableAsProperty(PropertyName = "ReadOnlyPropertyName")]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ internal partial class InternalTestViewModel : ReactiveObject
[Reactive]
public partial int PublicPartialPropertyTest { get; set; }

[Reactive]
public required partial bool PublicRequiredPartialPropertyTest { get; set; }

[Reactive]
public partial int PublicPartialPropertyWithInternalProtectedTest { get; protected internal set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public sealed partial class ReactiveGenerator

var inheritance = propertySymbol.IsVirtual ? " virtual" : propertySymbol.IsOverride ? " override" : string.Empty;

attributeData.TryGetNamedArgument("UseRequired", out bool useRequiredArgument);
var useRequired = useRequiredArgument ? "required " : string.Empty;
var useRequired = propertySymbol.IsRequired ? "required " : string.Empty;

var typeNameWithNullabilityAnnotations = propertySymbol.Type.GetFullyQualifiedNameWithNullabilityAnnotations();
var fieldName = propertySymbol.GetGeneratedFieldName();
Expand Down Expand Up @@ -410,7 +409,7 @@ private static string GetPropertySyntax(PropertyInfo propertyInfo)
{{fieldSyntax}}
/// <inheritdoc cref="{{setFieldName}}"/>
{{propertyAttributes}}
{{accessModifier}}{{propertyInfo.Inheritance}} {{partialModifier}}{{propertyInfo.UseRequired}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{getFieldName}}; {{setAccessModifier}} => this.RaiseAndSetIfChanged(ref {{setFieldName}}, value); }
{{accessModifier}}{{propertyInfo.Inheritance}} {{propertyInfo.UseRequired}}{{partialModifier}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{getFieldName}}; {{setAccessModifier}} => this.RaiseAndSetIfChanged(ref {{setFieldName}}, value); }
""";
}
}
Loading