Skip to content

Commit 7ee7f18

Browse files
authored
Update OAPH From Field Generator (#102)
1 parent 3467bf4 commit 7ee7f18

17 files changed

+373
-470
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
//HintName: TestNs.TestVM.ObservableAsProperties.g.cs
1+
//HintName: TestVM.ObservableAsProperties.g.cs
22
// <auto-generated/>
33
#pragma warning disable
44
#nullable enable
55
namespace TestNs
66
{
77
/// <inheritdoc/>
8-
partial class TestVM
8+
public partial class TestVM
99
{
10-
/// <inheritdoc cref="_test1Helper"/>
1110
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
11+
/// <inheritdoc cref="_test1Helper"/>
1212
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _test1Helper;
13+
1314
/// <inheritdoc cref="_test1"/>
14-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1515
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
1616
public int Test1 { get => _test1 = _test1Helper?.Value ?? _test1; }
1717
}
18-
}
18+
}
19+
#nullable restore
20+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
//HintName: TestNs.TestVM.ObservableAsProperties.g.cs
1+
//HintName: TestVM.ObservableAsProperties.g.cs
22
// <auto-generated/>
33
#pragma warning disable
44
#nullable enable
55
namespace TestNs
66
{
77
/// <inheritdoc/>
8-
partial class TestVM
8+
public partial class TestVM
99
{
10-
/// <inheritdoc cref="_test2Helper"/>
1110
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
11+
/// <inheritdoc cref="_test2Helper"/>
1212
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _test2Helper;
13+
1314
/// <inheritdoc cref="_test2"/>
14-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1515
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
1616
public int Test2 { get => _test2 = _test2Helper?.Value ?? _test2; }
1717
}
18-
}
18+
}
19+
#nullable restore
20+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
//HintName: TestNs.TestVM.ObservableAsProperties.g.cs
1+
//HintName: TestVM.ObservableAsProperties.g.cs
22
// <auto-generated/>
33
#pragma warning disable
44
#nullable enable
55
namespace TestNs
66
{
77
/// <inheritdoc/>
8-
partial class TestVM
8+
public partial class TestVM
99
{
10-
/// <inheritdoc cref="_test2Helper"/>
1110
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
11+
/// <inheritdoc cref="_test2Helper"/>
1212
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _test2Helper;
13+
1314
/// <inheritdoc cref="_test2"/>
14-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1515
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
1616
public int Test2 { get => _test2 = _test2Helper?.Value ?? _test2; }
1717
}
18-
}
18+
}
19+
#nullable restore
20+
#pragma warning restore

src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public partial class TestViewModel : ReactiveObject, IActivatableViewModel, IDis
3535
[ObservableAsProperty(ReadOnly = false)]
3636
private double? _test11Property = 11.1d;
3737

38+
[ObservableAsProperty(ReadOnly = false)]
39+
private double _test13Property = 11.1d;
40+
3841
[property: Test(AParameter = "Test Input")]
3942
[Reactive]
4043
private double? _test12Property = 12.1d;
@@ -138,6 +141,10 @@ public TestViewModel()
138141
Console.Out.WriteLine(_myReadOnlyNonNullProperty);
139142
_testNonNullSubject.OnNext(default);
140143

144+
Console.Out.WriteLine(_test13Property);
145+
Console.Out.WriteLine(Test13Property);
146+
Console.Out.WriteLine(_test13PropertyHelper);
147+
141148
// expected value 0 as the _testNonNullSubject has been updated.
142149
Console.Out.WriteLine(MyReadOnlyNonNullProperty);
143150
Console.Out.WriteLine(_myReadOnlyNonNullProperty);

src/ReactiveUI.SourceGenerators/AttributeDefinitions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ namespace ReactiveUI.SourceGenerators.Helpers;
1212
internal static class AttributeDefinitions
1313
{
1414
public const string GeneratedCode = "global::System.CodeDom.Compiler.GeneratedCode";
15-
public const string ExcludeFromCodeCoverage = "global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage";
1615
public const string Obsolete = "global::System.Obsolete";
1716

1817
public const string AccessModifierType = "ReactiveUI.SourceGenerators.AccessModifier";
18+
public static string[] ExcludeFromCodeCoverage = ["[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]"];
19+
public static string ExcludeFromCodeCoverageString = "global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage";
1920

2021
public static string GetAccessModifierEnum() => $$"""
2122
// Copyright (c) {{DateTime.Now.Year}} .NET Foundation and Contributors. All rights reserved.

src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.Execute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ namespace {{containingNamespace}}
189189
/// Partial class for the {{containingTypeName}} which contains ReactiveUI IViewFor initialization.
190190
/// </summary>
191191
{{forwardedAttributesString}}
192-
partial class {{containingTypeName}} : IViewFor<{{iviewForInfo.ViewModelTypeName}}>
192+
{{containingClassVisibility}} partial {{containingType}} {{containingTypeName}} : IViewFor<{{iviewForInfo.ViewModelTypeName}}>
193193
{
194194
/// <inheritdoc/>
195195
[Category("ReactiveUI")]
@@ -223,7 +223,7 @@ namespace {{containingNamespace}}
223223
/// Partial class for the {{containingTypeName}} which contains ReactiveUI IViewFor initialization.
224224
/// </summary>
225225
{{forwardedAttributesString}}
226-
public partial class {{containingTypeName}} : IViewFor<{{iviewForInfo.ViewModelTypeName}}>
226+
{{containingClassVisibility}} partial {{containingType}} {{containingTypeName}} : IViewFor<{{iviewForInfo.ViewModelTypeName}}>
227227
{
228228
/// <summary>
229229
/// The view model dependency property.
@@ -282,7 +282,7 @@ namespace {{containingNamespace}}
282282
/// Partial class for the {{containingTypeName}} which contains ReactiveUI IViewFor initialization.
283283
/// </summary>
284284
{{forwardedAttributesString}}
285-
public partial class {{containingTypeName}} : IViewFor<{{iviewForInfo.ViewModelTypeName}}>
285+
{{containingClassVisibility}} partial {{containingType}} {{containingTypeName}} : IViewFor<{{iviewForInfo.ViewModelTypeName}}>
286286
{
287287
public static readonly BindableProperty ViewModelProperty = BindableProperty.Create(nameof(ViewModel), typeof({{iviewForInfo.ViewModelTypeName}}), typeof(IViewFor<{{iviewForInfo.ViewModelTypeName}}>), default({{iviewForInfo.ViewModelTypeName}}), BindingMode.OneWay, propertyChanged: OnViewModelChanged);
288288

0 commit comments

Comments
 (0)