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 @@ -21,7 +21,7 @@ public partial class TestVM
/// <inheritdoc cref="_testProperty"/>
[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()
Expand Down
27 changes: 27 additions & 0 deletions src/ReactiveUI.SourceGenerators.Execute/TestClassOAPH_VM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Initializes a new instance of the <see cref="TestClassOAPH_VM"/> class.
/// </summary>
Expand All @@ -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;
}

/// <summary>
Expand All @@ -53,4 +71,13 @@ public TestClassOAPH_VM()
/// </value>
[Reactive]
public partial bool ReactiveTestProperty { get; set; }

/// <summary>
/// Gets the test.
/// </summary>
/// <value>
/// The test.
/// </value>
[ObservableAsProperty]
public partial string? Test { get; }
}
11 changes: 11 additions & 0 deletions src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ namespace SGReactiveUI.SourceGenerators.Test;
/// <summary>
/// TestClass.
/// </summary>
/// <seealso cref="ReactiveUI.ReactiveObject" />
/// <seealso cref="ReactiveUI.IActivatableViewModel" />
/// <seealso cref="System.IDisposable" />
/// <seealso cref="ReactiveObject" />
/// <seealso cref="IActivatableViewModel" />
/// <seealso cref="IDisposable" />
Expand Down Expand Up @@ -218,6 +221,14 @@ public TestViewModel()
/// </value>
public static TestViewModel Instance { get; } = new();

/// <summary>
/// Gets the test class oaph vm.
/// </summary>
/// <value>
/// The test class oaph vm.
/// </value>
public TestClassOAPH_VM TestClassOAPH_VM { get; } = new();

/// <summary>
/// Gets or sets the partial property test.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}";

Expand Down
Loading