diff --git a/src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromPartialProperty#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromPartialProperty#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs
index f1be4f2..5b35344 100644
--- a/src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromPartialProperty#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs
+++ b/src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromPartialProperty#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs
@@ -21,7 +21,7 @@ public partial class TestVM
///
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.Runtime.Serialization.DataMemberAttribute()]
- public partial double? TestProperty { get => _testProperty = _testPropertyHelper?.Value ?? _testProperty; }
+ public partial double? TestProperty { get => _testProperty = (_testPropertyHelper == null ? _testProperty : _testPropertyHelper.Value); }
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
protected void InitializeOAPH()
diff --git a/src/ReactiveUI.SourceGenerators.Execute/TestClassOAPH_VM.cs b/src/ReactiveUI.SourceGenerators.Execute/TestClassOAPH_VM.cs
index bbfc266..060bfa6 100644
--- a/src/ReactiveUI.SourceGenerators.Execute/TestClassOAPH_VM.cs
+++ b/src/ReactiveUI.SourceGenerators.Execute/TestClassOAPH_VM.cs
@@ -24,6 +24,9 @@ public partial class TestClassOAPH_VM : ReactiveObject
private string value = string.Empty;
#pragma warning restore SX1309 // Field names should begin with underscore
+ [Reactive]
+ private string? _testProperty;
+
///
/// Initializes a new instance of the class.
///
@@ -34,6 +37,21 @@ public TestClassOAPH_VM()
_observableTestFieldHelper = this.WhenAnyValue(x => x.ReactiveTestField)
.ToProperty(this, x => x.ObservableTestField);
+
+ _testHelper = this.WhenAnyValue(x => x.TestProperty).ToProperty(this, x => x.Test);
+
+ TestProperty = null;
+ var t0 = Test;
+
+ TestProperty = "Test";
+
+ var t1 = Test;
+
+ TestProperty = null;
+ var t2 = Test;
+
+ TestProperty = "Test2";
+ var t3 = Test;
}
///
@@ -53,4 +71,13 @@ public TestClassOAPH_VM()
///
[Reactive]
public partial bool ReactiveTestProperty { get; set; }
+
+ ///
+ /// Gets the test.
+ ///
+ ///
+ /// The test.
+ ///
+ [ObservableAsProperty]
+ public partial string? Test { get; }
}
diff --git a/src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs b/src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
index 65b013e..c3c99d7 100644
--- a/src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
+++ b/src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
@@ -21,6 +21,9 @@ namespace SGReactiveUI.SourceGenerators.Test;
///
/// TestClass.
///
+///
+///
+///
///
///
///
@@ -218,6 +221,14 @@ public TestViewModel()
///
public static TestViewModel Instance { get; } = new();
+ ///
+ /// Gets the test class oaph vm.
+ ///
+ ///
+ /// The test class oaph vm.
+ ///
+ public TestClassOAPH_VM TestClassOAPH_VM { get; } = new();
+
///
/// Gets or sets the partial property test.
///
diff --git a/src/ReactiveUI.SourceGenerators.Roslyn/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs b/src/ReactiveUI.SourceGenerators.Roslyn/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs
index 7b3b47c..9aff6ea 100644
--- a/src/ReactiveUI.SourceGenerators.Roslyn/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs
+++ b/src/ReactiveUI.SourceGenerators.Roslyn/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs
@@ -307,7 +307,7 @@ private static string GetPropertySyntax(ObservableMethodInfo propertyInfo)
{
var propertyAttributes = string.Join("\n ", AttributeDefinitions.ExcludeFromCodeCoverage.Concat(propertyInfo.ForwardedPropertyAttributes));
var getterFieldIdentifierName = propertyInfo.GetGeneratedFieldName();
- var getterArrowExpression = propertyInfo.IsNullableType
+ var getterArrowExpression = propertyInfo.IsNullableType || propertyInfo.IsFromPartialProperty
? $"{getterFieldIdentifierName} = ({getterFieldIdentifierName}Helper == null ? {getterFieldIdentifierName} : {getterFieldIdentifierName}Helper.Value)"
: $"{getterFieldIdentifierName} = {getterFieldIdentifierName}Helper?.Value ?? {getterFieldIdentifierName}";