Skip to content

Commit

Permalink
Fix For OAPH With Nested Classes (#156)
Browse files Browse the repository at this point in the history
* Fix For OAPH With Nested Classes

Simplify TargetInfo Generate Parent Class Declarations

* Update Property builders to remove \ r
  • Loading branch information
ChrisPulman authored Jan 6, 2025
1 parent 902d429 commit 45490dc
Show file tree
Hide file tree
Showing 31 changed files with 509 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System;

// <auto-generated/>
#pragma warning disable
#nullable enable
namespace ReactiveUI.SourceGenerators;

/// <summary>
/// ObservableAsPropertyAttribute.
/// </summary>
/// <seealso cref="Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
internal sealed class ObservableAsPropertyAttribute : Attribute
{
/// <summary>
/// Gets the name of the property.
/// </summary>
/// <value>
/// The name of the property.
/// </value>
public string? PropertyName { get; init; }

/// <summary>
/// Gets the Readonly state of the OAPH property.
/// </summary>
/// <value>
/// The is read only of the OAPH property.
/// </value>
public bool ReadOnly { get; init; } = true;
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//HintName: TestNs.TestVM+TestVMInner1.ObservableAsPropertyFromObservable.g.cs
// <auto-generated/>
using ReactiveUI;

#pragma warning disable
#nullable enable

namespace TestNs
{
public partial class TestVM
{
/// <summary>
/// Partial class for the TestVMInner1 which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVMInner1
{
/// <inheritdoc cref="TestIn1Property"/>
private int _testIn1Property;

/// <inheritdoc cref="_testIn1PropertyHelper"/>
private ReactiveUI.ObservableAsPropertyHelper<int>? _testIn1PropertyHelper;

/// <inheritdoc cref="_testIn1Property"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int TestIn1Property { get => _testIn1Property = _testIn1PropertyHelper?.Value ?? _testIn1Property; }

[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
protected void InitializeOAPH()
{
_testIn1PropertyHelper = TestIn1!.ToProperty(this, nameof(TestIn1Property));
}
}
}

}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//HintName: TestNs.TestVM+TestVMInner2+TestVMInner3.ObservableAsPropertyFromObservable.g.cs
// <auto-generated/>
using ReactiveUI;

#pragma warning disable
#nullable enable

namespace TestNs
{
public partial class TestVM
{
public partial class TestVMInner2
{
/// <summary>
/// Partial class for the TestVMInner3 which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVMInner3
{
/// <inheritdoc cref="TestIn3Property"/>
private int _testIn3Property;

/// <inheritdoc cref="_testIn3PropertyHelper"/>
private ReactiveUI.ObservableAsPropertyHelper<int>? _testIn3PropertyHelper;

/// <inheritdoc cref="_testIn3Property"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int TestIn3Property { get => _testIn3Property = _testIn3PropertyHelper?.Value ?? _testIn3Property; }

[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
protected void InitializeOAPH()
{
_testIn3PropertyHelper = TestIn3!.ToProperty(this, nameof(TestIn3Property));
}
}
}
}

}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//HintName: TestNs.TestVM+TestVMInner2.ObservableAsPropertyFromObservable.g.cs
// <auto-generated/>
using ReactiveUI;

#pragma warning disable
#nullable enable

namespace TestNs
{
public partial class TestVM
{
/// <summary>
/// Partial class for the TestVMInner2 which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVMInner2
{
/// <inheritdoc cref="TestIn2Property"/>
private int _testIn2Property;

/// <inheritdoc cref="_testIn2PropertyHelper"/>
private ReactiveUI.ObservableAsPropertyHelper<int>? _testIn2PropertyHelper;

/// <inheritdoc cref="_testIn2Property"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int TestIn2Property { get => _testIn2Property = _testIn2PropertyHelper?.Value ?? _testIn2Property; }

[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
protected void InitializeOAPH()
{
_testIn2PropertyHelper = TestIn2!.ToProperty(this, nameof(TestIn2Property));
}
}
}

}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//HintName: TestNs.TestVM.ObservableAsPropertyFromObservable.g.cs
// <auto-generated/>
using ReactiveUI;

#pragma warning disable
#nullable enable

namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
/// <inheritdoc cref="Test1Property"/>
private int _test1Property;

/// <inheritdoc cref="_test1PropertyHelper"/>
private ReactiveUI.ObservableAsPropertyHelper<int>? _test1PropertyHelper;

/// <inheritdoc cref="_test1Property"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int Test1Property { get => _test1Property = _test1PropertyHelper?.Value ?? _test1Property; }

[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
protected void InitializeOAPH()
{
_test1PropertyHelper = Test1!.ToProperty(this, nameof(Test1Property));
}
}
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace TestNs
{
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization.
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#nullable enable
namespace TestNs
{
/// <inheritdoc/>
/// <summary>
/// Partial class for the TestVM which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVM
{
/// <inheritdoc cref="_test1Helper"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System;

// <auto-generated/>
#pragma warning disable
#nullable enable
namespace ReactiveUI.SourceGenerators;

/// <summary>
/// ObservableAsPropertyAttribute.
/// </summary>
/// <seealso cref="Attribute" />
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
internal sealed class ObservableAsPropertyAttribute : Attribute
{
/// <summary>
/// Gets the name of the property.
/// </summary>
/// <value>
/// The name of the property.
/// </value>
public string? PropertyName { get; init; }

/// <summary>
/// Gets the Readonly state of the OAPH property.
/// </summary>
/// <value>
/// The is read only of the OAPH property.
/// </value>
public bool ReadOnly { get; init; } = true;
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//HintName: TestNs.TestVM+TestVMInner1.ObservableAsProperties.g.cs
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace TestNs
{
public partial class TestVM
{
/// <summary>
/// Partial class for the TestVMInner1 which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVMInner1
{
/// <inheritdoc cref="_testIn1Helper"/>
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _testIn1Helper;

/// <inheritdoc cref="_testIn1"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int TestIn1 { get => _testIn1 = _testIn1Helper?.Value ?? _testIn1; }
}
}

}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//HintName: TestNs.TestVM+TestVMInner2+TestVMInner3.ObservableAsProperties.g.cs
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace TestNs
{
public partial class TestVM
{
public partial class TestVMInner2
{
/// <summary>
/// Partial class for the TestVMInner3 which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVMInner3
{
/// <inheritdoc cref="_testIn3Helper"/>
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _testIn3Helper;

/// <inheritdoc cref="_testIn3"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int TestIn3 { get => _testIn3 = _testIn3Helper?.Value ?? _testIn3; }
}
}
}

}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//HintName: TestNs.TestVM+TestVMInner2.ObservableAsProperties.g.cs
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace TestNs
{
public partial class TestVM
{
/// <summary>
/// Partial class for the TestVMInner2 which contains ReactiveUI Observable As Property initialization.
/// </summary>
public partial class TestVMInner2
{
/// <inheritdoc cref="_testIn2Helper"/>
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _testIn2Helper;

/// <inheritdoc cref="_testIn2"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public int TestIn2 { get => _testIn2 = _testIn2Helper?.Value ?? _testIn2; }
}
}

}
#nullable restore
#pragma warning restore
Loading

0 comments on commit 45490dc

Please sign in to comment.