ObservableEvents icon indicating copy to clipboard operation
ObservableEvents copied to clipboard

ObservableEvents significantly slows down build times

Open Xerxes004 opened this issue 3 years ago • 5 comments

I'm working on a proprietary project which utilizes ObservableEvents for all event handling. In one of my views, I use .Events() 22 times. These 22 times cause an additional 3 minutes of build time for the project. If I comment them out, the slowness goes away.

It's hard to characterize exactly why this view slows down the build so dramatically, but it is directly correlated with the number of .Events() calls I have in the codebehind.

I made a test app with a single view, and codebehind that has 200 copies of this line: this.Events().PropertyChanged.Subscribe(_ => ViewModel.MyValue = "fdsa");

The view implements INotifyPropertyChanged.

The constructor looks something like:

public SimpleControl()
{
    InitializeComponent();

    this.WhenActivated(d =>
    {
        ViewModel = new SimpleControlViewModel();

        this.Events().PropertyChanged.Subscribe(_ => ViewModel.MyValue = "fdsa");
        // repeat 199 more times
    }
}

And building this single-view app takes 50 seconds. Without these 200 lines, it takes less than 3 seconds.

This is how I include this package in my project:

<PackageReference Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="1.1.4">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

Let me know if you need more info.

Xerxes004 avatar Aug 11 '22 16:08 Xerxes004

What IDE are you using including version number?

What Target framework?

New or old csproj format?

Thanks

glennawatson avatar Aug 11 '22 16:08 glennawatson

https://github.com/reactivemarbles/ObservableEvents/pull/133 could have a impact on this one also.

glennawatson avatar Aug 11 '22 17:08 glennawatson

What IDE are you using including version number?

What Target framework?

New or old csproj format?

Thanks

Rider 2022.2.1 Net6 Winders New

Xerxes004 avatar Aug 11 '22 17:08 Xerxes004

I'm new to this library, but the intellisense took so long to load, that I thought I was doing something wrong or that it was broken.

VS 2022: 17.3.0 .NET 6 WinForms

MisinformedDNA avatar Aug 27 '22 01:08 MisinformedDNA

#133 will help a lot with this. Roslyn 4 has a lot of optimisations.

Source generators do have slowness with intellisense in general though.

glennawatson avatar Aug 27 '22 01:08 glennawatson