Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Tools unusable with a couple of Events() #204

Open
LTa2022 opened this issue Jan 21, 2024 · 2 comments
Open

Refactoring Tools unusable with a couple of Events() #204

LTa2022 opened this issue Jan 21, 2024 · 2 comments

Comments

@LTa2022
Copy link

LTa2022 commented Jan 21, 2024

Hi,
I create a fresh project, add referenes to ReactiveUI.WPF, System.Reactive, Fody and ReactiveMarbles.ObservableEvents.SourceGenerator.
Then I create a new ViewModel and View.
I add this.WhenActivated(d => and fill it up with 50x empty
btnTest.Events().Click.Do((a) =>
{

            }).Subscribe().DisposeWith(d);

I create a new class in an own namespace, with ctor, and a var asdf = "";
When I now rightlick > rename the variable and confirm, the refactoring times is multiplied by the Events() in all my Views.
(takes around 20 sec in this example), same for the ctrl+. menu for finding namespaces, exporting methods, craeting events from xaml,
I am basically already used to work without these features, took me half a year to troubleshoot my projects.. : )

Is there anythnig I can do about it ?

I am all up to date, PC is last year gaming top.

Thanks!

@glennawatson
Copy link
Member

Thanks, this is related to #196 and something I'm actively working on.

Basically source generators were upgraded to allow the IDE to take advantage of parallelism and registrations of interested items and stuff etc. I just need to change to take advantage of it.

@LTa2022
Copy link
Author

LTa2022 commented Jan 22, 2024

Thanks a lot!
Sticking to some manual FromEventPattern for now,

  public static class UserControlEventsHelpers
{


    public static IObservable<EventPattern<TArgs>> OnEvent<T, TArgs>(
       this T btn,
       string nameofevent)
    {
        return Observable.FromEventPattern<TArgs>(btn, nameofevent);
    }

    public static IObservable<MouseButtonEventArgs> OnClickEx(this ButtonBase btn)
    {
        return btn.OnEvent<ButtonBase, MouseButtonEventArgs>(nameof(ButtonBase.Click)).Select(x=>x.EventArgs);
    }

    public static IObservable<RoutedEventArgs> OnCheckedEx(this CheckBox control)
    {
        
        return control.OnEvent<CheckBox, RoutedEventArgs>(nameof(CheckBox.CheckedEvent)).Select(x => x.EventArgs);
    }
    public static IObservable<RoutedEventArgs> OnCheckedEx(this ToggleButton control)
    {

        return control.OnEvent<ToggleButton, RoutedEventArgs>(nameof(ToggleButton.CheckedEvent)).Select(x => x.EventArgs);
    }
    public static IObservable<RoutedEventArgs> OnUncheckedEx(this CheckBox control)
    {

        return control.OnEvent<CheckBox, RoutedEventArgs>(nameof(CheckBox.Unchecked)).Select(x => x.EventArgs);
    }
    public static IObservable<RoutedEventArgs> OnUncheckedEx(this ToggleButton control)
    {

        return control.OnEvent<ToggleButton, RoutedEventArgs>(nameof(ToggleButton.Unchecked)).Select(x => x.EventArgs);
    }

    public static IObservable<DragEventArgs> OnDropEx(this UIElement control)
    {

        return control.OnEvent<UIElement, DragEventArgs>(nameof(UIElement.DropEvent)).Select(x => x.EventArgs);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants