Skip to content

Commit 45490dc

Browse files
authored
Fix For OAPH With Nested Classes (#156)
* Fix For OAPH With Nested Classes Simplify TargetInfo Generate Parent Class Declarations * Update Property builders to remove \ r
1 parent 902d429 commit 45490dc

File tree

31 files changed

+509
-51
lines changed

31 files changed

+509
-51
lines changed

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservableMethods#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace TestNs
99
{
1010
/// <summary>
11-
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
11+
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
1212
/// </summary>
1313
public partial class TestVM
1414
{

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservableMethodsWithName#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace TestNs
99
{
1010
/// <summary>
11-
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
11+
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
1212
/// </summary>
1313
public partial class TestVM
1414
{

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservableProp#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace TestNs
99
{
1010
/// <summary>
11-
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
11+
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
1212
/// </summary>
1313
public partial class TestVM
1414
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
2+
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
3+
// Licensed to the .NET Foundation under one or more agreements.
4+
// The .NET Foundation licenses this file to you under the MIT license.
5+
// See the LICENSE file in the project root for full license information.
6+
7+
using System;
8+
9+
// <auto-generated/>
10+
#pragma warning disable
11+
#nullable enable
12+
namespace ReactiveUI.SourceGenerators;
13+
14+
/// <summary>
15+
/// ObservableAsPropertyAttribute.
16+
/// </summary>
17+
/// <seealso cref="Attribute" />
18+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
19+
internal sealed class ObservableAsPropertyAttribute : Attribute
20+
{
21+
/// <summary>
22+
/// Gets the name of the property.
23+
/// </summary>
24+
/// <value>
25+
/// The name of the property.
26+
/// </value>
27+
public string? PropertyName { get; init; }
28+
29+
/// <summary>
30+
/// Gets the Readonly state of the OAPH property.
31+
/// </summary>
32+
/// <value>
33+
/// The is read only of the OAPH property.
34+
/// </value>
35+
public bool ReadOnly { get; init; } = true;
36+
}
37+
#nullable restore
38+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//HintName: TestNs.TestVM+TestVMInner1.ObservableAsPropertyFromObservable.g.cs
2+
// <auto-generated/>
3+
using ReactiveUI;
4+
5+
#pragma warning disable
6+
#nullable enable
7+
8+
namespace TestNs
9+
{
10+
public partial class TestVM
11+
{
12+
/// <summary>
13+
/// Partial class for the TestVMInner1 which contains ReactiveUI Observable As Property initialization.
14+
/// </summary>
15+
public partial class TestVMInner1
16+
{
17+
/// <inheritdoc cref="TestIn1Property"/>
18+
private int _testIn1Property;
19+
20+
/// <inheritdoc cref="_testIn1PropertyHelper"/>
21+
private ReactiveUI.ObservableAsPropertyHelper<int>? _testIn1PropertyHelper;
22+
23+
/// <inheritdoc cref="_testIn1Property"/>
24+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
25+
public int TestIn1Property { get => _testIn1Property = _testIn1PropertyHelper?.Value ?? _testIn1Property; }
26+
27+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
28+
protected void InitializeOAPH()
29+
{
30+
_testIn1PropertyHelper = TestIn1!.ToProperty(this, nameof(TestIn1Property));
31+
}
32+
}
33+
}
34+
35+
}
36+
#nullable restore
37+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//HintName: TestNs.TestVM+TestVMInner2+TestVMInner3.ObservableAsPropertyFromObservable.g.cs
2+
// <auto-generated/>
3+
using ReactiveUI;
4+
5+
#pragma warning disable
6+
#nullable enable
7+
8+
namespace TestNs
9+
{
10+
public partial class TestVM
11+
{
12+
public partial class TestVMInner2
13+
{
14+
/// <summary>
15+
/// Partial class for the TestVMInner3 which contains ReactiveUI Observable As Property initialization.
16+
/// </summary>
17+
public partial class TestVMInner3
18+
{
19+
/// <inheritdoc cref="TestIn3Property"/>
20+
private int _testIn3Property;
21+
22+
/// <inheritdoc cref="_testIn3PropertyHelper"/>
23+
private ReactiveUI.ObservableAsPropertyHelper<int>? _testIn3PropertyHelper;
24+
25+
/// <inheritdoc cref="_testIn3Property"/>
26+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
27+
public int TestIn3Property { get => _testIn3Property = _testIn3PropertyHelper?.Value ?? _testIn3Property; }
28+
29+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
30+
protected void InitializeOAPH()
31+
{
32+
_testIn3PropertyHelper = TestIn3!.ToProperty(this, nameof(TestIn3Property));
33+
}
34+
}
35+
}
36+
}
37+
38+
}
39+
#nullable restore
40+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//HintName: TestNs.TestVM+TestVMInner2.ObservableAsPropertyFromObservable.g.cs
2+
// <auto-generated/>
3+
using ReactiveUI;
4+
5+
#pragma warning disable
6+
#nullable enable
7+
8+
namespace TestNs
9+
{
10+
public partial class TestVM
11+
{
12+
/// <summary>
13+
/// Partial class for the TestVMInner2 which contains ReactiveUI Observable As Property initialization.
14+
/// </summary>
15+
public partial class TestVMInner2
16+
{
17+
/// <inheritdoc cref="TestIn2Property"/>
18+
private int _testIn2Property;
19+
20+
/// <inheritdoc cref="_testIn2PropertyHelper"/>
21+
private ReactiveUI.ObservableAsPropertyHelper<int>? _testIn2PropertyHelper;
22+
23+
/// <inheritdoc cref="_testIn2Property"/>
24+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
25+
public int TestIn2Property { get => _testIn2Property = _testIn2PropertyHelper?.Value ?? _testIn2Property; }
26+
27+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
28+
protected void InitializeOAPH()
29+
{
30+
_testIn2PropertyHelper = TestIn2!.ToProperty(this, nameof(TestIn2Property));
31+
}
32+
}
33+
}
34+
35+
}
36+
#nullable restore
37+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//HintName: TestNs.TestVM.ObservableAsPropertyFromObservable.g.cs
2+
// <auto-generated/>
3+
using ReactiveUI;
4+
5+
#pragma warning disable
6+
#nullable enable
7+
8+
namespace TestNs
9+
{
10+
/// <summary>
11+
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
12+
/// </summary>
13+
public partial class TestVM
14+
{
15+
/// <inheritdoc cref="Test1Property"/>
16+
private int _test1Property;
17+
18+
/// <inheritdoc cref="_test1PropertyHelper"/>
19+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test1PropertyHelper;
20+
21+
/// <inheritdoc cref="_test1Property"/>
22+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
23+
public int Test1Property { get => _test1Property = _test1PropertyHelper?.Value ?? _test1Property; }
24+
25+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
26+
protected void InitializeOAPH()
27+
{
28+
_test1PropertyHelper = Test1!.ToProperty(this, nameof(Test1Property));
29+
}
30+
}
31+
}
32+
#nullable restore
33+
#pragma warning restore

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservablePropertiesWithAttribute#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace TestNs
99
{
1010
/// <summary>
11-
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
11+
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
1212
/// </summary>
1313
public partial class TestVM
1414
{

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservablePropertiesWithAttributeNullableRef#TestNs.TestVM.ObservableAsPropertyFromObservable.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace TestNs
99
{
1010
/// <summary>
11-
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
11+
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
1212
/// </summary>
1313
public partial class TestVM
1414
{

0 commit comments

Comments
 (0)