reactivemarbles / ObservableEvents

MIT License
120 stars 10 forks source link

ObservableEvents significantly slows down build times #134

Open Xerxes004 opened 1 year ago

Xerxes004 commented 1 year ago

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.

glennawatson commented 1 year ago

What IDE are you using including version number?

What Target framework?

New or old csproj format?

Thanks

glennawatson commented 1 year ago

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

Xerxes004 commented 1 year ago

What IDE are you using including version number?

What Target framework?

New or old csproj format?

Thanks

Rider 2022.2.1 Net6 Winders New

MisinformedDNA commented 1 year ago

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

glennawatson commented 1 year ago

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

Source generators do have slowness with intellisense in general though.