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
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ internal static class DiagnosticDescriptors
/// </summary>
public static readonly DiagnosticDescriptor PropertyToReactiveFieldRule = new(
id: "RXUISG0016",
title: "Property To Reactive Field, change to [Reactive] private type _fieldName;",
title: "Property To Reactive Field, change to `[Reactive]` private type _fieldName;",
messageFormat: "Replace the property with a INPC Reactive Property for ReactiveUI",
category: typeof(PropertyToReactiveFieldAnalyzer).FullName,
defaultSeverity: DiagnosticSeverity.Info,
isEnabledByDefault: true,
description: "Used to create a Read Write INPC Reactive Property for ReactiveUI, annotated with [Reactive].",
description: "Used to create a Read Write INPC Reactive Property for ReactiveUI, annotated with `[Reactive]`.",
helpLinkUri: "https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html");

/// <summary>
Expand All @@ -33,7 +33,7 @@ internal static class DiagnosticDescriptors
public static readonly DiagnosticDescriptor ReactiveAttributeRequiresPartialRule = new(
id: "RXUISG0020",
title: "[Reactive] requires partial property and containing type",
messageFormat: "`[Reactive]` requires the property to be `partial` and the containing type to be `partial` so source generation can run.",
messageFormat: "`[Reactive]` requires the property to be `partial` and the containing type to be partial so source generation can run",
category: typeof(ReactiveAttributeMisuseAnalyzer).FullName,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true,
Expand Down
33 changes: 33 additions & 0 deletions src/ReactiveUI.SourceGenerators.Execute/PLCInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2026 ReactiveUI and contributors. All rights reserved.
// Licensed to the ReactiveUI and contributors under one or more agreements.
// The ReactiveUI and contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

namespace SGReactiveUI.SourceGenerators.Test;

/// <summary>
/// Represents a programmable logic controller (PLC) instance within the application.
/// </summary>
public class PLCInstance
{
/// <summary>
/// Gets or sets the unique identifier for the PLC instance.
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets the name of the PLC instance.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the IP address of the PLC instance.
/// </summary>
public string IPAddress { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether the PLC instance is currently active.
/// </summary>
public bool IsActive { get; set; }
/// <summary>
/// Gets or sets the network port number used for the connection.
/// </summary>
public int Port { get; set; }
}
25 changes: 25 additions & 0 deletions src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public partial class TestViewModel : ReactiveObject, IActivatableViewModel, IDis
[Reactive]
private double _myDoubleNonNullProperty;

[Reactive]
private PLCInstance _plcInstanceCore = new();

[BindableDerivedList]
private ReadOnlyObservableCollection<Person>? _visiblePeople;

Expand Down Expand Up @@ -211,6 +214,10 @@ public TestViewModel()
.Bind(out _visiblePeople)
.Subscribe());

_pLCActiveHelper = this.WhenAnyValue(x => x.PartialRequiredPropertyTest).ToProperty(this, nameof(PLCActive));
_pLCPortHelper = this.WhenAnyValue(x => x.Test1Property).ToProperty(this, nameof(PLCPort));
_instanceOfPLCHelper = this.WhenAnyValue(x => x.PlcInstanceCore).ToProperty(this, nameof(InstanceOfPLC));

Console.ReadLine();
}

Expand Down Expand Up @@ -319,6 +326,24 @@ public TestViewModel()
[property: Test(AParameter = "Test Input")]
public IObservable<int> ObservableAsPropertyTest2 => Observable.Return(9);

/// <summary>
/// Gets the current active PLC identifier or name.
/// </summary>
[ObservableAsProperty(InitialValue = "Not Connected")]
public partial string? PLCActive { get; }

/// <summary>
/// Gets the TCP port number used to communicate with the PLC.
/// </summary>
[ObservableAsProperty(InitialValue = "9000")]
public partial int PLCPort { get; }

/// <summary>
/// Gets the current instance of the PLC (Programmable Logic Controller) used by the application.
/// </summary>
[ObservableAsProperty(InitialValue = $"new {nameof(PLCInstance)}()")]
public partial PLCInstance InstanceOfPLC { get; }

/// <summary>
/// Gets the Activator which will be used by the View when Activation/Deactivation occurs.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,10 @@ internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
public bool UseProtected { get; init; } = false;

/// <summary>
/// Gets the Initial value of the OAPH property.
/// Gets the Initial Value of the OAPH property.
/// This should be a string representation of the value. i.e. "42" or "DateTime.Now" or "new List&lt;string&gt;()".
/// String values are automatically quoted.
/// </summary>
/// <value>
/// The initial value of the OAPH property.
/// </value>
public string? InitialValue { get; init; }
}
#nullable restore
Expand Down
Loading
Loading