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
9 changes: 9 additions & 0 deletions src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ public TestViewModel()
[Reactive]
public partial string? PartialPropertyTest { get; set; }

/// <summary>
/// Gets or sets the partial property test.
/// </summary>
/// <value>
/// The partial property test.
/// </value>
[Reactive(UseRequired = true)]
public required partial string? PartialRequiredPropertyTest { get; set; }

/// <summary>
/// Gets the internal test property. Should not prompt to replace with INPC Reactive Property.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public sealed partial class ReactiveGenerator
token.ThrowIfCancellationRequested();

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

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

var typeNameWithNullabilityAnnotations = propertySymbol.Type.GetFullyQualifiedNameWithNullabilityAnnotations();
var fieldName = propertySymbol.GetGeneratedFieldName();
var propertyName = propertySymbol.Name;
Expand Down Expand Up @@ -326,7 +329,7 @@ private static string GetPropertySyntax(PropertyInfo propertyInfo)
{{fieldSyntax}}
/// <inheritdoc cref="{{fieldName}}"/>
{{propertyAttributes}}
{{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{partialModifier}}{{propertyInfo.UseRequired}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}}
{{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.UseRequired}}{{partialModifier}}{{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}}
{
get => {{propertyInfo.FieldName}};
[global::System.Diagnostics.CodeAnalysis.MemberNotNull("{{fieldName}}")]
Expand Down
Loading