reactiveui / Pharmacist

Builds observables from events.
MIT License
239 stars 15 forks source link

[BUG] Not Generate PropertyChanged event on .NET Standard 2.1 #205

Closed dimonovdd closed 3 years ago

dimonovdd commented 3 years ago

Describe the bug If I use .NET Standard 2.1 project, no code generation occurs only for PropertyChanged. Everything's fine with .NET Standard 2.0

Expected behavior The following code should be generated:

public global::System.IObservable<global::System.ComponentModel.PropertyChangedEventArgs> PropertyChanged => global::System.Reactive.Linq.Observable.FromEvent<global::System.ComponentModel.PropertyChangedEventHandler, global::System.ComponentModel.PropertyChangedEventArgs>(eventHandler =>
{
    void Handler(object sender, global::System.ComponentModel.PropertyChangedEventArgs e) => eventHandler(e);
    return Handler;
}, x => _data.PropertyChanged += x, x => _data.PropertyChanged -= x);

Screenshots image

Additional context

// Generated with Pharmacist version: 2.0.6+357b54abbd
// Package included: Autofac.6.1.0
// Package included: ImageFromXamarinUI.1.0.0-pre1
// Package included: Microsoft.AppCenter.Analytics.4.1.0
// Package included: Microsoft.AppCenter.Crashes.4.1.0
// Package included: Newtonsoft.Json.12.0.3
// Package included: Newtonsoft.Json.Bson.1.0.2
// Package included: Polly.7.2.1
// Package included: ReactiveUI.Fody.13.1.1
// Package included: ReactiveUI.XamForms.13.1.1
// Package included: Rg.Plugins.Popup.2.0.0.9
// Package included: SkiaSharp.Views.Forms.2.80.2
// Package included: sqlite-net-pcl.1.8.0-beta
// Package included: System.Reactive.5.0.0
// Package included: TouchView.4.1.99
// Package included: Xamanimation.1.3.0
// Package included: Xamarin.Forms.5.0.0.1905
// Package included: Xamarin.Essentials.1.6.0
// Package included: Xamarin.Forms.PancakeView.2.3.0.759
dimonovdd commented 3 years ago

I thought it might be because of dependencies. I created an empty Xamarin.Forms project with .NET Standard 2.1 and got the same behavior Pharmacist.NuGet.g.cs

glennawatson commented 3 years ago

See https://www.nuget.org/packages/ReactiveMarbles.ObservableEvents.SourceGenerator/ and https://github.com/reactivemarbles/ObservableEventsSourceGenerator

This will handle netstandard2.1 packages.

ReactiveMarbles.ObservableEvents.SourceGenerator 1.0.2
Allows to get an observables for property changed events.
GitHub
reactivemarbles/ObservableEventsSourceGenerator
Contribute to reactivemarbles/ObservableEventsSourceGenerator development by creating an account on GitHub.
github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.