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 preview6 #178

Merged
merged 9 commits into from
Apr 3, 2023
Merged

Update to preview6 #178

merged 9 commits into from
Apr 3, 2023

Conversation

Mrxx99
Copy link
Contributor

@Mrxx99 Mrxx99 commented Mar 23, 2023

This updates the templates to preview 6.

Browser template for C# works fine, but the F# one leads to a blank screen, not sure what's wrong there.

Comment on lines 22 to 23
.StartBrowserAppAsync("out")
.Result
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to return Task here without awaiting or blocking anything?
Blocking async calls isn't supported on WASM backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, a better way is needed here, will take another look later (I am not to familiar with F#) or someone with better F# knowledge can give some hint

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there is needed for better way. It just needs return a Task produced by StartBrowserAppAsync.
This code is executed by WASM interop layer, so it is expected to either return int/void or return a Task.

Copy link
Contributor Author

@Mrxx99 Mrxx99 Mar 24, 2023

Choose a reason for hiding this comment

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

but StartBrowserAppAsync does not return Task<int> and F# does need an int return of main

/AvaloniaXplatfnet70.Browser/Program.fs(20,9): error FS0193: Type constraint mismatch. The type 'Task' is not compatible with type 'int'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks to ChatGPT I found out how to do it in F#. It would be a bit nicer though if StartBrowserAppAsync would return Task<int> instead of Task

@Mrxx99 Mrxx99 marked this pull request as ready for review March 30, 2023 10:09
@Mrxx99 Mrxx99 changed the title started update to preview6 Update to preview6 Mar 30, 2023
@Mrxx99 Mrxx99 marked this pull request as draft March 30, 2023 13:43
@Mrxx99
Copy link
Contributor Author

Mrxx99 commented Mar 30, 2023

I am also not sure which parts of this properties set here are also required for the template: https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog.Browser/ControlCatalog.Browser.csproj

@Mrxx99
Copy link
Contributor Author

Mrxx99 commented Apr 2, 2023

The F# Browser problem seems to be in the dotnet.js, it breaks in the first line of it, but I don't see any error message.
Can maybe someone take a look I don't know how to solve this?

@maxkatz6 Should I maybe split the C# and F# update to 2 PRs so C# can at least already be updated while F# is investigated?

@maxkatz6
Copy link
Member

maxkatz6 commented Apr 2, 2023

The F# Browser problem seems to be in the dotnet.js, it breaks in the first line of it, but I don't see any error message.

As I mentioned above, WASM doesn't support sync awaitl, so operations like RunSynchronously don't make sense there.
It should be a Main method (or any other method) that returns Task. In fact, browser template doesn't really care about entry point in c#, as it's not really used as an entry point. Real entry point is in JS code. Though, F# compiler might not expect that.

"dotnet.js" can be modified to execute a different method too.

It would be a bit nicer though if StartBrowserAppAsync would return Task instead of Task

I think we can do it.

Should I maybe split the C# and F# update to 2 PRs so C# can at least already be updated while F# is investigated?

Yeah, let's do it.

@Numpsy
Copy link

Numpsy commented Apr 2, 2023

fwiw, I've had the Avalonia.FuncUI web assembly control catalog app running with Avalonia 11 preview 6 by doing

    let main argv =
        task {
            do! buildAvaloniaApp().StartBrowserAppAsync("out")
        }
        |> ignore

        0

Though I don't know if this is actually the 'correct' way to do it

@Mrxx99
Copy link
Contributor Author

Mrxx99 commented Apr 2, 2023

@maxkatz6 I have done a new PR for C# only here: #181

I also made the proposed change from @Numpsy here, I think the way it's done is fine, as the result was also ignored before and it seems to work.

So you can decide if you first want to merge C# only or directly this one.

@Mrxx99 Mrxx99 marked this pull request as ready for review April 2, 2023 20:57
@Mrxx99
Copy link
Contributor Author

Mrxx99 commented Apr 2, 2023

Also this is not yet answered:

I am also not sure which parts of this properties set here are also required for the template: https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog.Browser/ControlCatalog.Browser.csproj

E.g. should that <EmccFlags>-sVERBOSE -sERROR_ON_UNDEFINED_SYMBOLS=0</EmccFlags> also be set? I guess it would suppress the build warnings that currently occur. Or should these be fixed in the Avalonia repo?

@maxkatz6 maxkatz6 merged commit 0f67af7 into AvaloniaUI:master Apr 3, 2023
@Mrxx99 Mrxx99 deleted the feature/11preview6 branch April 3, 2023 19:05
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