R3Extensions.ObservableEvents.SourceGenerator 1.3.3

dotnet add package R3Extensions.ObservableEvents.SourceGenerator --version 1.3.3
                    
NuGet\Install-Package R3Extensions.ObservableEvents.SourceGenerator -Version 1.3.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="R3Extensions.ObservableEvents.SourceGenerator" Version="1.3.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="R3Extensions.ObservableEvents.SourceGenerator" Version="1.3.3" />
                    
Directory.Packages.props
<PackageReference Include="R3Extensions.ObservableEvents.SourceGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add R3Extensions.ObservableEvents.SourceGenerator --version 1.3.3
                    
#r "nuget: R3Extensions.ObservableEvents.SourceGenerator, 1.3.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=R3Extensions.ObservableEvents.SourceGenerator&version=1.3.3
                    
Install R3Extensions.ObservableEvents.SourceGenerator as a Cake Addin
#tool nuget:?package=R3Extensions.ObservableEvents.SourceGenerator&version=1.3.3
                    
Install R3Extensions.ObservableEvents.SourceGenerator as a Cake Tool

<a href="https://github.com/reactivemarbles/observableevents"> <img width="150" src="./images/logo.png"/> </a>

Observable Event Generator for R3

This repository's implementation is identical to the upstream, with only structural adjustments. Icon from icon8

This project is a .NET source generator which produces Observable<T> for events contained within a object including all base classes. ObservableEvents generator will convert events within an assembly and create observable wrappers for them, it is based on Pharmacist and uses .NET Source Generator technology.

NuGet Packages

Make sure your project is using the newer PackageReference inside your CSPROJ. The older style is buggy and should be moved away from regardless. See here for discussions how to upgrade.

Install the following packages to start using Observable Events.

Name Platform NuGet
R3Extensions.ObservableEvents.SourceGenerator Core - Libary CoreBadge

Manual Installation

Include the following in your .csproj file

<PackageReference
    Include="R3.ObservableEvents.SourceGenerator"
    Version="1.3.0"
    PrivateAssets="all" />

The PrivateAssets will prevent the ObservableEvents source generator from being inherited by other projects.

How to use

Instance Based

It injects a class for instance based events into your source code which will expose a extension method called Events(). You need to include the namespace R3.ObservableEvents to access to the extension method. You can then use this to get Observable<T> instances from your events.

using R3.ObservableEvents;

public void MyClass : INotifyPropertyChanged
{
  // Assumes this belong in a class with a event called PropertyChanged.
  public void RunEvents()
  {
      this.Events().PropertyChanged.Subscribe(x => Console.WriteLine($"The {x} property has changed"));
  }

  public event PropertyChangedEventHandler PropertyChanged;
}

Static Events

You must use include a attribute GenerateStaticEventObservables on the assembly level for a particular class. This will generate a class RxEvents in the same namespace as the specified class.

[assembly: GenerateStaticEventObservablesAttribute(typeof(StaticTest))]
public static class StaticTest
{
    public static event EventHandler? TestChanged;
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.3 94 2/15/2025
1.3.0 106 2/14/2025
1.1.1 96 2/14/2025
1.1.0 99 2/14/2025
1.0.0 96 2/14/2025