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

Update to build with Avalonia 11 Preview 5 #246

Merged
merged 10 commits into from
Feb 15, 2023

Conversation

Numpsy
Copy link
Collaborator

@Numpsy Numpsy commented Jan 15, 2023

A WIP change, to try to make it build against the latest Avalonia 11 nightly build.

Most of the changes are to replace uses of interfaces with their base classes to make it work with the Avalonia changes from AvaloniaUI/Avalonia#9553

Note: I've had the control catalog working with thest changes, except that horizontally resizing the window corrupts some of the contents. That may or may not be down to the issue described at AvaloniaUI/Avalonia#9975

@@ -33,7 +33,7 @@ module internal Extensions =
member this.SubscribeWeakly(callback: 'a -> unit, target) =
Observable.subscribeWeakly(this, callback, target)

type IInteractive with
type Interactive with
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another change that effects this bit is that the Avalonia change at AvaloniaUI/Avalonia#9749 has removed its usage of System.Reactive and replaced it with a bunch of (mostly internal) things.

I added a local reference to System.Reactive to make it build, but i'm not sure of the 'best' approach (still learing how all this hangs together) - e.g. Avalonia now seems to have an internal implementation of Observable.Create that uses a minimal local class, so I wondered if doing something like

{ new IObservable<'args>
  with member this.Subscribe(observer: IObserver<'args>) = sub.Invoke(observer) }

would work instead of importing Reactive just for Observable.Create?

There are also 3 references to Observable.Subscribe that require Reactive, but the comment at AvaloniaUI/Avalonia#9749 (comment) suggests there might be more changes coming on the Avalonia side there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general bit about System.Reactive, or the local object expression suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not having a reference to 'System.Reactive'. So the object expression seems good to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be any value in breaking bits like this into separate PRs (in cases where they can be done without updating the Avalonia version)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two cases where breaking this PR into smaller bits might make sense:

  1. if the change could be released as a new preview version that would provide immediate value for end users.
  2. if the change is big enough (touches enough files) that it will become harder to merge the longer it sits.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question was mainly that you don't have to do it all in one go (as you could leave the FuncUI code using a local System.Reactive reference to begin with and fix it later, or you could try removing local dependencies on System.Reactive without updating Avalonia, e.g. #261 ).
The value is probably more that it'd be more self contained to test.

@Numpsy
Copy link
Collaborator Author

Numpsy commented Jan 15, 2023

There is also a break in the web assembly playground project due to Avalonia.Web.Blazor having been renamed to Avalonia.Browser.Blazor, but that doesn't doesn't seem to currently be attached to the solution?

@JaggerJo
Copy link
Member

There is also a break in the web assembly playground project due to Avalonia.Web.Blazor having been renamed to Avalonia.Browser.Blazor, but that doesn't doesn't seem to currently be attached to the solution?

No, The WASM Example even had runtime errors last time I tried it with v11.

@Numpsy Numpsy force-pushed the users/rw/avalon_nights branch from 395c347 to 72759ee Compare January 15, 2023 20:33
@Numpsy
Copy link
Collaborator Author

Numpsy commented Jan 15, 2023

Ok, I've updated the project anyway, something else to test with the new versions

This was referenced Jan 17, 2023
@Numpsy Numpsy force-pushed the users/rw/avalon_nights branch from 3ed5ec6 to 9db7e66 Compare January 21, 2023 10:22
@Numpsy
Copy link
Collaborator Author

Numpsy commented Jan 21, 2023

Another breaking change has appeared in the Avalonia 11 nightlys - the change at AvaloniaUI/Avalonia#9677 has changed some virtualization related things, which causes a number if build breaks due to properties having been removed or renamed

@Numpsy Numpsy force-pushed the users/rw/avalon_nights branch 3 times, most recently from 597baa6 to f181f7d Compare January 26, 2023 18:56
@Numpsy Numpsy force-pushed the users/rw/avalon_nights branch 2 times, most recently from f33e0d9 to 24104c6 Compare January 31, 2023 18:32
@Numpsy
Copy link
Collaborator Author

Numpsy commented Jan 31, 2023

I was holding off on trying to make a couple of other System.Reactive uses (Subscribe calls using callbacks and cancellation tokens) self contained in case other Avalonia changes avoid the need (e.g. AvaloniaUI/Avalonia#10105), but looking at what Reactive actually does I wonder if something using the built in Observable.subscribe along the lines of

type IObservable<'a> with
        member this.Subscribe (callback: 'a -> unit, token: CancellationToken) =
            let disposable = Observable.subscribe callback this
            token.Register(fun () -> disposable.Dispose())

might work?

@Numpsy
Copy link
Collaborator Author

Numpsy commented Feb 1, 2023

Updated with a couple more breaking API changes in Avalonia (this time just in the sample apps though)

AvaloniaUI/Avalonia#8166
AvaloniaUI/Avalonia#10141

@Numpsy
Copy link
Collaborator Author

Numpsy commented Feb 2, 2023

Removed the ItemsRepeater bindings after AvaloniaUI/Avalonia#10112

@Numpsy Numpsy force-pushed the users/rw/avalon_nights branch from a5c13bd to 1a4e129 Compare February 3, 2023 14:54
@Numpsy
Copy link
Collaborator Author

Numpsy commented Feb 3, 2023

Ok, updated to Avalonia 11 preview 5.

Seems to be working ok, but still has a System.Reactive reference to get a couple of uses of Subscribe (see previous Q about if a simple local extension method will work instead)

@JaggerJo
Copy link
Member

JaggerJo commented Feb 3, 2023

Wonder when all of this great stuff will land in a new public avalonia preview 😀

@Numpsy
Copy link
Collaborator Author

Numpsy commented Feb 3, 2023

Wonder when all of this great stuff will land in a new public avalonia preview 😀

Looks like it just did:
image

@JaggerJo
Copy link
Member

JaggerJo commented Feb 3, 2023

Nice! Looking forward to merging your changes and also releasing a preview version.

@Numpsy Numpsy changed the title [WIP] Update to build with the latest Avalonia 11 changes Update to build with Avalonia 11 Preview 5 Feb 4, 2023
@Numpsy Numpsy marked this pull request as ready for review February 4, 2023 09:56
@Numpsy
Copy link
Collaborator Author

Numpsy commented Feb 4, 2023

hmm, forgot about the web assembly playground project, might need more tweaks there (although, it could maybe also be simplified to use the new self-hosted WASM support rather than needing Blazor?)

@JaggerJo
Copy link
Member

JaggerJo commented Feb 4, 2023

Whatever works 😉

@Numpsy
Copy link
Collaborator Author

Numpsy commented Feb 4, 2023

I've updated the playground project so it builds with Preview 5, but I got a javascript error when running it - so that bit needs another look later

@JaggerJo
Copy link
Member

JaggerJo commented Feb 4, 2023

I doesn't work currently, so we can definitely fix it after merging. 👍

@JaggerJo JaggerJo merged commit 4dee185 into fsprojects:master Feb 15, 2023
@JaggerJo
Copy link
Member

Merged! Great work 🔥

@Numpsy Numpsy deleted the users/rw/avalon_nights branch February 15, 2023 22:58
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

Successfully merging this pull request may close these issues.

3 participants