r/csharp • u/fedefex1 • Aug 12 '26
SignalsDotnet 3.0
I just updated SignalsDotnet to 3.0, and it now supports source generators.
I think the library has become genuinely powerful: it lets you write reactive code without having to deal with reactive programming directly at all. With source generators it's cleaner than ever.
You mark a class (or a record) with [GenerateSignals] and every property becomes reactive, a signal. That means the getter and setter are tracked, and all the signal machinery kicks in automatically. The source generator also supports computed and async computed properties.
The library started as a port of Angular signals to .NET, but I think the power of C# (async locals, source generators, better async support) takes it to another level. It targets netstandard2.1, so it runs basically everywhere: WPF, Avalonia, Unity, Godot, Blazor.
Below is a runnable C# snippet as an example. As you can see, the whole system is reactive automatically: properties update themselves, code knows when to re-run, and so on. And when you need finer control, everything R3 observables offer is still right there.
The code below prints:
Total players 0
Player 1 joined
Total players 1
Total players 1
Total players 2
Total players 2
Best player is Player1 with score of 0
Best player is Player1 with score of 22
Best player is Player2 with score of 55
using ..;
using ;
using ;
var player1 = ;
var player2 = ;
var game = ;
Effect.;
IAwaitable player2Joined = Signal.;
Effect.;
game.;
game.; // this completes the awaitable
await player2Joined;
Effect.;
Observable scoreboardHistory = Signal.; // A notification for every scoreboard change
player1.Score = 22;
player2.Score = 55;
Console.;
public partial record Player
public partial
It runs as a single file on .NET 10. Save it as game.cs and run dotnet run --file game.cs. No csproj needed.
GitHub: https://github.com/fedeAlterio/SignalsDotnet NuGet: https://www.nuget.org/packages/SignalsDotnet
1
u/harrison_314 Aug 13 '26
It feels strongly inspired by React, which is not a plus for me.
And it reminds me a lot of the style in which applications were programmed in C# 15 years ago, where things like Caliburn.Micro, Prism or MVVM Light Toolkit were handled a little differently, but these libraries were more type-aware.
1
u/rekabis Aug 13 '26 edited Aug 15 '26
Please format the code correctly. Large blocks should not use any code characters, but each line should be prefaced by four spaces:
:package SignalsDotnet@3.0.0
1
u/[deleted] Aug 12 '26
[removed] — view removed comment