Skip to content

Commit 7b0e3f9

Browse files
authored
Add Tests for Source Generators (#86)
* Add Tests for Source Generators
1 parent e6aa927 commit 7b0e3f9

File tree

34 files changed

+1203
-74
lines changed

34 files changed

+1203
-74
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//HintName: TestNs.TestVM.ObservableAsPropertyFromObservable.g.cs
2+
using ReactiveUI;
3+
// <auto-generated/>
4+
#pragma warning disable
5+
#nullable enable
6+
namespace TestNs
7+
{
8+
/// <inheritdoc/>
9+
partial class TestVM
10+
{
11+
/// <inheritdoc cref="Test2Property"/>
12+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
13+
private int _test2Property;
14+
/// <inheritdoc cref="_test2PropertyHelper"/>
15+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
16+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test2PropertyHelper;
17+
/// <inheritdoc cref="_test2Property"/>
18+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
19+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
20+
public int Test2Property { get => _test2Property = _test2PropertyHelper?.Value ?? _test2Property; }
21+
22+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
23+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
24+
protected void InitializeOAPH()
25+
{
26+
_test2PropertyHelper = Test2()!.ToProperty(this, nameof(Test2Property));
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//HintName: TestNs.TestVM.ObservableAsPropertyFromObservable.g.cs
2+
using ReactiveUI;
3+
// <auto-generated/>
4+
#pragma warning disable
5+
#nullable enable
6+
namespace TestNs
7+
{
8+
/// <inheritdoc/>
9+
partial class TestVM
10+
{
11+
/// <inheritdoc cref="Test3Property"/>
12+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
13+
private int _test3Property;
14+
/// <inheritdoc cref="_test3PropertyHelper"/>
15+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
16+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test3PropertyHelper;
17+
/// <inheritdoc cref="_test3Property"/>
18+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
19+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
20+
public int Test3Property { get => _test3Property = _test3PropertyHelper?.Value ?? _test3Property; }
21+
22+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
23+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
24+
protected void InitializeOAPH()
25+
{
26+
_test3PropertyHelper = Test3()!.ToProperty(this, nameof(Test3Property));
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//HintName: TestNs.TestVM.ObservableAsPropertyFromObservable.g.cs
2+
using ReactiveUI;
3+
// <auto-generated/>
4+
#pragma warning disable
5+
#nullable enable
6+
namespace TestNs
7+
{
8+
/// <inheritdoc/>
9+
partial class TestVM
10+
{
11+
/// <inheritdoc cref="Test1Property"/>
12+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
13+
private int _test1Property;
14+
/// <inheritdoc cref="_test1PropertyHelper"/>
15+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
16+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test1PropertyHelper;
17+
/// <inheritdoc cref="_test1Property"/>
18+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
19+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
20+
public int Test1Property { get => _test1Property = _test1PropertyHelper?.Value ?? _test1Property; }
21+
22+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
23+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
24+
protected void InitializeOAPH()
25+
{
26+
_test1PropertyHelper = Test1!.ToProperty(this, nameof(Test1Property));
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//HintName: TestNs.TestVM.ObservableAsPropertyFromObservable.g.cs
2+
using ReactiveUI;
3+
// <auto-generated/>
4+
#pragma warning disable
5+
#nullable enable
6+
namespace TestNs
7+
{
8+
/// <inheritdoc/>
9+
partial class TestVM
10+
{
11+
/// <inheritdoc cref="Test4Property"/>
12+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
13+
private int _test4Property;
14+
/// <inheritdoc cref="_test4PropertyHelper"/>
15+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
16+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test4PropertyHelper;
17+
/// <inheritdoc cref="_test4Property"/>
18+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
19+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
20+
public int Test4Property { get => _test4Property = _test4PropertyHelper?.Value ?? _test4Property; }
21+
22+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator", "1.1.0.0")]
23+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
24+
protected void InitializeOAPH()
25+
{
26+
_test4PropertyHelper = Test4!.ToProperty(this, nameof(Test4Property));
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
2+
// Copyright (c) 2024 .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+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
19+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
20+
internal sealed class ObservableAsPropertyAttribute : Attribute
21+
{
22+
/// <summary>
23+
/// Gets the name of the property.
24+
/// </summary>
25+
/// <value>
26+
/// The name of the property.
27+
/// </value>
28+
public string? PropertyName { get; init; }
29+
30+
/// <summary>
31+
/// Gets the Readonly state of the OAPH property.
32+
/// </summary>
33+
/// <value>
34+
/// The is read only of the OAPH property.
35+
/// </value>
36+
public bool ReadOnly { get; init; } = true;
37+
}
38+
#nullable restore
39+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//HintName: TestNs.TestVM.ObservableAsProperties.g.cs
2+
// <auto-generated/>
3+
#pragma warning disable
4+
#nullable enable
5+
namespace TestNs
6+
{
7+
/// <inheritdoc/>
8+
partial class TestVM
9+
{
10+
/// <inheritdoc cref="_test1Helper"/>
11+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
12+
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _test1Helper;
13+
/// <inheritdoc cref="_test1"/>
14+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
15+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
16+
public int Test1 { get => _test1 = _test1Helper?.Value ?? _test1; }
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
2+
// Copyright (c) 2024 .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+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
19+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
20+
internal sealed class ObservableAsPropertyAttribute : Attribute
21+
{
22+
/// <summary>
23+
/// Gets the name of the property.
24+
/// </summary>
25+
/// <value>
26+
/// The name of the property.
27+
/// </value>
28+
public string? PropertyName { get; init; }
29+
30+
/// <summary>
31+
/// Gets the Readonly state of the OAPH property.
32+
/// </summary>
33+
/// <value>
34+
/// The is read only of the OAPH property.
35+
/// </value>
36+
public bool ReadOnly { get; init; } = true;
37+
}
38+
#nullable restore
39+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//HintName: TestNs.TestVM.ObservableAsProperties.g.cs
2+
// <auto-generated/>
3+
#pragma warning disable
4+
#nullable enable
5+
namespace TestNs
6+
{
7+
/// <inheritdoc/>
8+
partial class TestVM
9+
{
10+
/// <inheritdoc cref="_test2Helper"/>
11+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
12+
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _test2Helper;
13+
/// <inheritdoc cref="_test2"/>
14+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
15+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
16+
public int Test2 { get => _test2 = _test2Helper?.Value ?? _test2; }
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
2+
// Copyright (c) 2024 .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+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
19+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
20+
internal sealed class ObservableAsPropertyAttribute : Attribute
21+
{
22+
/// <summary>
23+
/// Gets the name of the property.
24+
/// </summary>
25+
/// <value>
26+
/// The name of the property.
27+
/// </value>
28+
public string? PropertyName { get; init; }
29+
30+
/// <summary>
31+
/// Gets the Readonly state of the OAPH property.
32+
/// </summary>
33+
/// <value>
34+
/// The is read only of the OAPH property.
35+
/// </value>
36+
public bool ReadOnly { get; init; } = true;
37+
}
38+
#nullable restore
39+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//HintName: TestNs.TestVM.ObservableAsProperties.g.cs
2+
// <auto-generated/>
3+
#pragma warning disable
4+
#nullable enable
5+
namespace TestNs
6+
{
7+
/// <inheritdoc/>
8+
partial class TestVM
9+
{
10+
/// <inheritdoc cref="_test2Helper"/>
11+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
12+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test2Helper;
13+
/// <inheritdoc cref="_test2"/>
14+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
15+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
16+
public int Test2 { get => _test2 = _test2Helper?.Value ?? _test2; }
17+
}
18+
}

0 commit comments

Comments
 (0)