Skip to content

Commit 21c1557

Browse files
authored
feature: Update Reactive Generator for performance (#94)
* Update TestHelper to use a single Generic Type Use Code Analysis 4.6.0 * Update Reactive Generator to be more performant * Refactor to consider ReactiveCommand Move shared functions into Core
1 parent c924597 commit 21c1557

File tree

50 files changed

+875
-749
lines changed

Some content is hidden

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

50 files changed

+875
-749
lines changed

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5-
<CodeAnalysisVersion>4.0.1</CodeAnalysisVersion>
5+
<CodeAnalysisVersion>4.6.0</CodeAnalysisVersion>
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ namespace TestNs
88
/// <inheritdoc/>
99
partial class TestVM
1010
{
11-
/// <inheritdoc cref="MyNamedProperty"/>
11+
/// <inheritdoc cref="Test3Property"/>
1212
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
13-
private int _myNamedProperty;
14-
/// <inheritdoc cref="_myNamedPropertyHelper"/>
13+
private int _test3Property;
14+
/// <inheritdoc cref="_test3PropertyHelper"/>
1515
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
16-
private ReactiveUI.ObservableAsPropertyHelper<int>? _myNamedPropertyHelper;
17-
/// <inheritdoc cref="_myNamedProperty"/>
16+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test3PropertyHelper;
17+
/// <inheritdoc cref="_test3Property"/>
1818
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1919
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
20-
public int MyNamedProperty { get => _myNamedProperty = _myNamedPropertyHelper?.Value ?? _myNamedProperty; }
20+
public int Test3Property { get => _test3Property = _test3PropertyHelper?.Value ?? _test3Property; }
2121

2222
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
2323
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
2424
protected void InitializeOAPH()
2525
{
26-
_myNamedPropertyHelper = Test3()!.ToProperty(this, nameof(MyNamedProperty));
26+
_test3PropertyHelper = Test3()!.ToProperty(this, nameof(Test3Property));
2727
}
2828
}
2929
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ namespace TestNs
88
/// <inheritdoc/>
99
partial class TestVM
1010
{
11-
/// <inheritdoc cref="MyNamedProperty"/>
11+
/// <inheritdoc cref="Test4Property"/>
1212
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
13-
private int _myNamedProperty;
14-
/// <inheritdoc cref="_myNamedPropertyHelper"/>
13+
private int _test4Property;
14+
/// <inheritdoc cref="_test4PropertyHelper"/>
1515
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
16-
private ReactiveUI.ObservableAsPropertyHelper<int>? _myNamedPropertyHelper;
17-
/// <inheritdoc cref="_myNamedProperty"/>
16+
private ReactiveUI.ObservableAsPropertyHelper<int>? _test4PropertyHelper;
17+
/// <inheritdoc cref="_test4Property"/>
1818
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1919
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
20-
public int MyNamedProperty { get => _myNamedProperty = _myNamedPropertyHelper?.Value ?? _myNamedProperty; }
20+
public int Test4Property { get => _test4Property = _test4PropertyHelper?.Value ?? _test4Property; }
2121

2222
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
2323
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
2424
protected void InitializeOAPH()
2525
{
26-
_myNamedPropertyHelper = Test4!.ToProperty(this, nameof(MyNamedProperty));
26+
_test4PropertyHelper = Test4!.ToProperty(this, nameof(Test4Property));
2727
}
2828
}
2929
}

src/ReactiveUI.SourceGenerator.Tests/OAPH/OAPGeneratorTests.NonReadOnlyFromField#TestNs.TestVM.ObservableAsProperties.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ partial class TestVM
99
{
1010
/// <inheritdoc cref="_test2Helper"/>
1111
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
12-
private ReactiveUI.ObservableAsPropertyHelper<int>? _test2Helper;
12+
private readonly ReactiveUI.ObservableAsPropertyHelper<int> _test2Helper;
1313
/// <inheritdoc cref="_test2"/>
1414
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator", "1.1.0.0")]
1515
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//HintName: ReactiveUI.SourceGenerators.AccessModifier.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+
// <auto-generated/>
8+
#pragma warning disable
9+
#nullable enable
10+
namespace ReactiveUI.SourceGenerators;
11+
12+
/// <summary>
13+
/// AccessModifier.
14+
/// </summary>
15+
internal enum AccessModifier
16+
{
17+
Public,
18+
Protected,
19+
Internal,
20+
Private,
21+
InternalProtected,
22+
PrivateProtected,
23+
}
24+
#nullable restore
25+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.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+
/// ReactiveAttribute.
16+
/// </summary>
17+
/// <seealso cref="Attribute" />
18+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveGenerator", "1.1.0.0")]
19+
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
20+
internal sealed class ReactiveAttribute : Attribute
21+
{
22+
/// <summary>
23+
/// Gets the AccessModifier of the set property.
24+
/// </summary>
25+
/// <value>
26+
/// The AccessModifier of the set property.
27+
/// </value>
28+
public AccessModifier SetModifier { get; init; }
29+
}
30+
#nullable restore
31+
#pragma warning restore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//HintName: TestVM.Properties.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 Reactive property initialization.
12+
/// </summary>
13+
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveGenerator", "1.1.0.0")]
14+
public partial class TestVM
15+
{
16+
/// <inheritdoc cref="_test3"/>
17+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
18+
[System.Text.Json.Serialization.JsonInclude]
19+
[System.Runtime.Serialization.DataMember]
20+
public int Test3
21+
{
22+
get => _test3;
23+
[global::System.Diagnostics.CodeAnalysis.MemberNotNull("_test3")]
24+
set => this.RaiseAndSetIfChanged(ref _test3, value);
25+
}
26+
}
27+
}
28+
#nullable restore
29+
#pragma warning restore

src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#ReactiveUI.SourceGenerators.AccessModifier.g.verified.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ internal enum AccessModifier
2020
Private,
2121
InternalProtected,
2222
PrivateProtected,
23-
}
23+
}
24+
#nullable restore
25+
#pragma warning restore

src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#System.Runtime.CompilerServices.IsExternalInit.g.verified.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#TestNs.TestVM.Properties.g.verified.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)