Skip to main content

RxSourceGenerator by Ivan Zalutskii

NuGet / site data​

Nuget GitHub last commit GitHub Repo stars

Details​

Info​

info

Name: RxSourceGenerator

This package generates extension methods in the style of Reactive Extensions.

Author: Ivan Zalutskii

NuGet: https://www.nuget.org/packages/RxSourceGenerator/

You can find more details at https://github.com/Zalutskii/Reactive-Extensions-event-generator

Source: https://github.com/Zalutskii/Reactive-Extensions-event-generator

Author​

note

Ivan Zalutskii Alt text

Original Readme​

note

RxSourceGenerator

License NuGet

What is this?

This source code generator generates Reactive Extensions methods for class events. For example, there is some class with an event:

public partial class Example
{
public event Action<int, string, bool> ActionEvent;
}

If you enter the code:

Example example = new  Example();
example.RxActionEvent()

The generator will create a file with extension methods:

using System;
using System.Reactive.Linq;
namespace RxMethodGenerator{
public static class RxGeneratedMethods{
public static IObservable<(System.Int32 Item1Int32, System.String Item2String, System.Boolean Item3Boolean)> RxActionEvent(this TestConsoleApp.Example obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
return Observable.FromEvent<System.Action<System.Int32, System.String, System.Boolean>, (System.Int32 Item1Int32, System.String Item2String, System.Boolean Item3Boolean)>(
conversion => (obj0, obj1, obj2) => conversion((obj0, obj1, obj2)),
h => obj.ActionEvent += h,
h => obj.ActionEvent -= h);
}
}
}

What does it look like in Visual Studio?

About​

note

Generates RX Extensions for events

How to use​

Example (source csproj, source files)​

This is the CSharp Project that references RxSourceGenerator

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="RxSourceGenerator" Version="2.0.1" />
<PackageReference Include="System.Reactive" Version="6.0.2" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>

Generated Files​

Those are taken from $(BaseIntermediateOutputPath)\GX

// <auto-generated/>
using System;
using System.Reactive;
using System.Reactive.Linq;

namespace RxMethodGenerator
{
public static partial class RxGeneratedMethods
{
public static IObservable<(int Item1Int32, string Item2String, bool Item3Boolean)> RxActionEvent(this global::RxDemo.Person obj)
{
if (obj == null) throw new ArgumentNullException(nameof(obj));
return Observable.FromEvent<global::System.Action<int, string, bool>, (int Item1Int32, string Item2String, bool Item3Boolean)>(
conversion => (arg0, arg1, arg2) => conversion((arg0, arg1, arg2)),
h => obj.ActionEvent += h,
h => obj.ActionEvent -= h);
}

}
}

Useful​

Download Example (.NET C#)​

Share RxSourceGenerator​

https://ignatandrei.github.io/RSCG_Examples/v2/docs/RxSourceGenerator

aaa

Category "RX" has the following generators:​

1 RxSourceGenerator Nuget GitHub Repo stars 2025-08-09

See category​

RX