Skip to content

Commit ccc17fc

Browse files
authored
Add ReactiveCollection source generator and tests (#271)
* merge * Add ReactiveCollection source generator and tests Introduces the [ReactiveCollection] Attribute and its source generator, enabling automatic property generation for ObservableCollection OnChanged fields. Adds corresponding unit tests and verified outputs, updates test helpers, and includes usage in InternalTestViewModel. * Revert tests
1 parent 4bda916 commit ccc17fc

File tree

79 files changed

+549
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+549
-83
lines changed

src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/BindableDerivedListGeneratorTests.FromReactiveProperties#ReactiveUI.SourceGenerators.BindableDerivedListAttribute.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace ReactiveUI.SourceGenerators;
1313
/// ReactiveAttribute.
1414
/// </summary>
1515
/// <seealso cref="Attribute" />
16-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveGenerator", "2.3.0.0")]
1716
[global::System.AttributeUsage(global::System.AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
1817
internal sealed class BindableDerivedListAttribute : global::System.Attribute;
1918
#nullable restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//HintName: ReactiveUI.SourceGenerators.BindableDerivedListAttribute.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+
/// ReactiveAttribute.
16+
/// </summary>
17+
/// <seealso cref="Attribute" />
18+
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
19+
internal sealed class BindableDerivedListAttribute : Attribute;
20+
#nullable restore
21+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//HintName: ReactiveUI.SourceGenerators.IViewForAttribute.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+
// <auto-generated/>
8+
#pragma warning disable
9+
#nullable enable
10+
namespace ReactiveUI.SourceGenerators;
11+
12+
/// <summary>
13+
/// IViewForAttribute.
14+
/// </summary>
15+
/// <seealso cref="System.Attribute" />
16+
/// <remarks>
17+
/// Initializes a new instance of the <see cref="IViewForAttribute"/> class.
18+
/// </remarks>
19+
/// <param name="viewModelType">Type of the view model.</param>
20+
[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
21+
internal sealed class IViewForAttribute<T> : global::System.Attribute;
22+
23+
/// <summary>
24+
/// IViewForAttribute.
25+
/// </summary>
26+
/// <seealso cref="System.Attribute" />
27+
/// <remarks>
28+
/// Initializes a new instance of the <see cref="IViewForAttribute"/> class.
29+
/// </remarks>
30+
/// <param name="viewModelType">Type of the view model.</param>
31+
[global::System.AttributeUsage(global::System.AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
32+
internal sealed class IViewForAttribute(string? viewModelType) : global::System.Attribute;
33+
#nullable restore
34+
#pragma warning restore

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromField#ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace ReactiveUI.SourceGenerators;
1313
/// ObservableAsPropertyAttribute.
1414
/// </summary>
1515
/// <seealso cref="Attribute" />
16-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1716
[global::System.AttributeUsage(global::System.AttributeTargets.Field | global::System.AttributeTargets.Property | global::System.AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
1817
internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
1918
{

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromField#TestNs.TestVM.ObservableAsProperties.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public partial class TestVM
1111
private readonly ReactiveUI.ObservableAsPropertyHelper<double?> _testPropertyHelper;
1212

1313
/// <inheritdoc cref="_testProperty"/>
14-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "2.3.0.0")]
1514
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
1615
[global::System.Runtime.Serialization.DataMemberAttribute()]
1716
[global::System.Text.Json.Serialization.JsonIncludeAttribute()]

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservableMethods#ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace ReactiveUI.SourceGenerators;
1313
/// ObservableAsPropertyAttribute.
1414
/// </summary>
1515
/// <seealso cref="Attribute" />
16-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1716
[global::System.AttributeUsage(global::System.AttributeTargets.Field | global::System.AttributeTargets.Property | global::System.AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
1817
internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
1918
{

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public partial class TestVM
1717
private ReactiveUI.ObservableAsPropertyHelper<int>? _test2PropertyHelper;
1818

1919
/// <inheritdoc cref="_test2Property"/>
20-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "2.3.0.0")]
2120
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
2221
public int Test2Property { get => _test2Property = _test2PropertyHelper?.Value ?? _test2Property; }
2322

24-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "2.3.0.0")]
2523
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
2624
protected void InitializeOAPH()
2725
{

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservableMethodsWithName#ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace ReactiveUI.SourceGenerators;
1313
/// ObservableAsPropertyAttribute.
1414
/// </summary>
1515
/// <seealso cref="Attribute" />
16-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1716
[global::System.AttributeUsage(global::System.AttributeTargets.Field | global::System.AttributeTargets.Property | global::System.AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
1817
internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
1918
{

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public partial class TestVM
1717
private ReactiveUI.ObservableAsPropertyHelper<int>? _test3PropertyHelper;
1818

1919
/// <inheritdoc cref="_test3Property"/>
20-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "2.3.0.0")]
2120
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
2221
public int Test3Property { get => _test3Property = _test3PropertyHelper?.Value ?? _test3Property; }
2322

24-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "2.3.0.0")]
2523
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
2624
protected void InitializeOAPH()
2725
{

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPFromObservableGeneratorTests.FromObservableProp#ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace ReactiveUI.SourceGenerators;
1313
/// ObservableAsPropertyAttribute.
1414
/// </summary>
1515
/// <seealso cref="Attribute" />
16-
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1716
[global::System.AttributeUsage(global::System.AttributeTargets.Field | global::System.AttributeTargets.Property | global::System.AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
1817
internal sealed class ObservableAsPropertyAttribute : global::System.Attribute
1918
{

0 commit comments

Comments
 (0)