Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,207 changes: 2,689 additions & 518 deletions .editorconfig

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cs text eol=lf
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ dotnet add package ReactiveUI.SourceGenerators

Ensure the package is loaded with `PrivateAssets="all"` to avoid issues with generated code in consuming projects.

ReactiveUI V24.x.x consumers can reference either `ReactiveUI` for the primitives-based API without
System.Reactive, or `ReactiveUI.Reactive` for the System.Reactive-based API. The generators detect
the referenced API surface automatically. ReactiveUI releases from 23.2.28 remain supported.

## Overview

ReactiveUI Source Generators automatically generate ReactiveUI objects to streamline your code. These Source Generators are designed to work with ReactiveUI V23.2.28+ and support the following features:
Expand Down
7 changes: 3 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@

<ItemGroup>
<PackageReference Include="MinVer" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" PrivateAssets="all" />
<PackageReference Include="StyleSharp.Analyzers" PrivateAssets="all"/>
<PackageReference Include="PerformanceSharp.Analyzers" PrivateAssets="all"/>
<PackageReference Include="SecuritySharp.Analyzers" PrivateAssets="all"/>
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
<!--SyntaxFactory helper https://roslynquoter.azurewebsites.net/-->
13 changes: 9 additions & 4 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<Project>
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<CodeAnalysisVersion>4.14.0</CodeAnalysisVersion>
<RoslynCommonAnalyzersVersion>3.40.0</RoslynCommonAnalyzersVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.301" />
<PackageVersion Include="MinVer" Version="7.0.0" />
<PackageVersion Include="stylecop.analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="StyleSharp.Analyzers" Version="$(RoslynCommonAnalyzersVersion)"/>
<PackageVersion Include="PerformanceSharp.Analyzers" Version="$(RoslynCommonAnalyzersVersion)"/>
<PackageVersion Include="SecuritySharp.Analyzers" Version="$(RoslynCommonAnalyzersVersion)"/>
<PackageVersion Include="Roslynator.Analyzers" Version="4.15.0" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
Expand All @@ -25,12 +28,14 @@
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.18" />
<PackageVersion Include="Avalonia.Desktop" Version="12.1.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="10.0.10" />
<PackageVersion Include="DynamicData" Version="9.4.33" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.7.0" />
<PackageVersion Include="System.Formats.Asn1" Version="10.0.10" />
<PackageVersion Include="PublicApiGenerator" Version="11.5.4" />
<PackageVersion Include="Splat" Version="20.2.0" />
<PackageVersion Include="ReactiveUI" Version="23.2.28" />
<PackageVersion Include="ReactiveUI.Maui" Version="23.2.28" />
<PackageVersion Include="ReactiveUI" Version="24.0.0" />
<PackageVersion Include="ReactiveUI.Reactive" Version="24.0.0" />
<PackageVersion Include="ReactiveUI.Maui" Version="24.0.0" />
<PackageVersion Include="System.Reactive" Version="7.0.0" />
<PackageVersion Include="TUnit" Version="1.61.38" />
<PackageVersion Include="Verify.TUnit" Version="31.20.0" />
Expand Down
15 changes: 6 additions & 9 deletions src/ReactiveUI.SourceGenerator.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// Copyright (c) 2026 ReactiveUI and contributors. All rights reserved.
// Licensed to the ReactiveUI and contributors under one or more agreements.
// The ReactiveUI and contributors licenses this file to you under the MIT license.
// Copyright (c) 2019-2026 ReactiveUI Association Incorporated. All rights reserved.
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

/// <summary>
/// Initializes the source generator verifiers.
/// </summary>
namespace ReactiveUI.SourceGenerator.Tests;

/// <summary>Initializes the source generator verifiers.</summary>
public static class ModuleInitializer
{
/// <summary>
/// Initializes the source generators.
/// </summary>
/// <summary>Initializes the source generators.</summary>
[ModuleInitializer]
public static void Init() => VerifySourceGenerators.Initialize();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TestVM
/// <inheritdoc cref="value"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public string Value
{
{
get => value;
[global::System.Diagnostics.CodeAnalysis.MemberNotNull("this.value")]
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TestVM
/// <inheritdoc cref="_mustBeSet"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public required string MustBeSet
{
{
get => _mustBeSet;
[global::System.Diagnostics.CodeAnalysis.MemberNotNull("_mustBeSet")]
init
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class TestVM
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _test1Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _test1Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
internal global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
internal global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class TestVM
{
private global::ReactiveUI.ReactiveCommand<string, global::System.Reactive.Unit>? _test3Command;
private global::ReactiveUI.ReactiveCommand<string, global::ReactiveUI.Primitives.RxVoid>? _test3Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<string, global::System.Reactive.Unit> Test3Command { get => _test3Command ??= global::ReactiveUI.ReactiveCommand.CreateFromTask<string>(Test3); }
public global::ReactiveUI.ReactiveCommand<string, global::ReactiveUI.Primitives.RxVoid> Test3Command { get => _test3Command ??= global::ReactiveUI.ReactiveCommand.CreateFromTask<string>(Test3); }
}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class TestVM
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _test1Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _test1Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class TestVM
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _test1Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid>? _test1Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.CreateFromTask(Test1); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.CreateFromTask(Test1); }
}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestViewModel3+TestInnerClass1.ReactiveCommands.g.cs
//HintName: TestNs.TestViewModel3+TestInnerClass1.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -11,11 +11,11 @@ public partial class TestViewModel3

public partial class TestInnerClass1
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _testI1Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _testI1Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> TestI1Command { get => _testI1Command ??= global::ReactiveUI.ReactiveCommand.Create(TestI1); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> TestI1Command { get => _testI1Command ??= global::ReactiveUI.ReactiveCommand.Create(TestI1); }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestViewModel3+TestInnerClass2+TestInnerClass3.ReactiveCommands.g.cs
//HintName: TestNs.TestViewModel3+TestInnerClass2+TestInnerClass3.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -13,11 +13,11 @@ public partial class TestInnerClass2

public partial class TestInnerClass3
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _testI3Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _testI3Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> TestI3Command { get => _testI3Command ??= global::ReactiveUI.ReactiveCommand.Create(TestI3); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> TestI3Command { get => _testI3Command ??= global::ReactiveUI.ReactiveCommand.Create(TestI3); }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestViewModel3+TestInnerClass2.ReactiveCommands.g.cs
//HintName: TestNs.TestViewModel3+TestInnerClass2.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -11,11 +11,11 @@ public partial class TestViewModel3

public partial class TestInnerClass2
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _testI2Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _testI2Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> TestI2Command { get => _testI2Command ??= global::ReactiveUI.ReactiveCommand.Create(TestI2); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> TestI2Command { get => _testI2Command ??= global::ReactiveUI.ReactiveCommand.Create(TestI2); }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestViewModel3.ReactiveCommands.g.cs
//HintName: TestNs.TestViewModel3.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class TestViewModel3
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _test1Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _test1Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class TestVM
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _test1Command;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _test1Command;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> Test1Command { get => _test1Command ??= global::ReactiveUI.ReactiveCommand.Create(Test1); }
}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
//HintName: TestNs.TestVM.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,21 +9,21 @@ namespace TestNs

public partial class TestVM
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _createCommand;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid>? _createCommand;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> CreateCommand { get => _createCommand ??= global::ReactiveUI.ReactiveCommand.Create(Create); }
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _saveCommand;
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid> CreateCommand { get => _createCommand ??= global::ReactiveUI.ReactiveCommand.Create(Create); }
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid>? _saveCommand;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> SaveCommand { get => _saveCommand ??= global::ReactiveUI.ReactiveCommand.CreateFromTask(Save, CanExecuteSave); }
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _deleteCommand;
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid> SaveCommand { get => _saveCommand ??= global::ReactiveUI.ReactiveCommand.CreateFromTask(Save, CanExecuteSave); }
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid>? _deleteCommand;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> DeleteCommand { get => _deleteCommand ??= global::ReactiveUI.ReactiveCommand.Create(Delete, CanExecuteDelete); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid> DeleteCommand { get => _deleteCommand ??= global::ReactiveUI.ReactiveCommand.Create(Delete, CanExecuteDelete); }
private global::ReactiveUI.ReactiveCommand<int, int>? _calculateCommand;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.Outer+Middle+Inner.ReactiveCommands.g.cs
//HintName: TestNs.Outer+Middle+Inner.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -13,11 +13,11 @@ public partial class Middle

public partial class Inner
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int>? _innerCommandCommand;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int>? _innerCommandCommand;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, int> InnerCommandCommand { get => _innerCommandCommand ??= global::ReactiveUI.ReactiveCommand.Create(InnerCommand); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, int> InnerCommandCommand { get => _innerCommandCommand ??= global::ReactiveUI.ReactiveCommand.Create(InnerCommand); }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.Outer+Middle.ReactiveCommands.g.cs
//HintName: TestNs.Outer+Middle.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -11,11 +11,11 @@ public partial class Outer

public partial class Middle
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _middleCommandCommand;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid>? _middleCommandCommand;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> MiddleCommandCommand { get => _middleCommandCommand ??= global::ReactiveUI.ReactiveCommand.CreateFromTask(MiddleCommand); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid> MiddleCommandCommand { get => _middleCommandCommand ??= global::ReactiveUI.ReactiveCommand.CreateFromTask(MiddleCommand); }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: TestNs.Outer.ReactiveCommands.g.cs
//HintName: TestNs.Outer.ReactiveCommands.g.cs
// <auto-generated/>

#pragma warning disable
Expand All @@ -9,11 +9,11 @@ namespace TestNs

public partial class Outer
{
private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _outerCommandCommand;
private global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid>? _outerCommandCommand;


[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> OuterCommandCommand { get => _outerCommandCommand ??= global::ReactiveUI.ReactiveCommand.Create(OuterCommand); }
public global::ReactiveUI.ReactiveCommand<global::ReactiveUI.Primitives.RxVoid, global::ReactiveUI.Primitives.RxVoid> OuterCommandCommand { get => _outerCommandCommand ??= global::ReactiveUI.ReactiveCommand.Create(OuterCommand); }
}
}
#nullable restore
Expand Down
Loading
Loading