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

Hot design missing when appBuilder (on linux) #2655

Closed
sarosigy opened this issue Dec 12, 2024 · 10 comments · Fixed by #2673
Closed

Hot design missing when appBuilder (on linux) #2655

sarosigy opened this issue Dec 12, 2024 · 10 comments · Fixed by #2673
Assignees
Labels
kind/bug Something isn't working

Comments

@sarosigy
Copy link

Current behavior

I just created a brand new Uno desktop app, it runs as it should.

I wanted to leverage the Localization which means using Hosting, also. I did exactly what is written in Uno Howto Hosting Setup

But even adding the single line var appBuilder = this.CreateBuilder(args); causes two things:

  1. The Hot Design toolbar won't show on the Main Window
  2. The application would not exit by closing with the Close button, it must be stopped in debugger (or its process killed)

Expected behavior

It should work as expected.

How to reproduce it (as minimally and precisely as possible)

  1. dotnet new unoapp --platforms desktop -o unoinout
  2. Add Hosting to <UnoFeatures>
  3. Add the line var appBuilder = this.CreateBuilder(args); in the first line of App.xaml.cs protected override void OnLaunched(LaunchActivatedEventArgs args)

Workaround

Not using appBuilder.

Which tool(s) are affected?

Hot Design™

Affected platforms

Desktop (Skia)

Uno.Sdk version

5.5.54

IDE used

Visual Studio Code on Linux

IDE version

1.96.0

Uno Platform Extension version

0.18.5

Relevant plugins

No response

Anything else we need to know?

No response

@sarosigy sarosigy added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Dec 12, 2024
@nickrandolph
Copy link
Contributor

@sarosigy thanks for raising this, we'll investigate this

@nickrandolph nickrandolph removed the triage/untriaged Indicates an issue requires triaging or verification. label Dec 17, 2024
@nickrandolph
Copy link
Contributor

@sarosigy which version of the uno.sdk are you using (look in global.json)?

When I follow the steps you provided, I also adjusted the next two lines of the code:

  • use the Window property on the builder to retrieve the Window instance used by hosting
  • call UseStudio (in some older templates this was EnableHotReload)
    image

Let me know if this helps

@sarosigy
Copy link
Author

sarosigy commented Jan 7, 2025

At that time the SDK was the latest,
"Uno.Sdk": "5.5.54"

I have the UseStudio line, it came with the template.

However, the

MainWindow = appBuilder.Window;

line helped. Now it works, the toolbar is in place.

So, it seems it is a documentation issue, because at the Hosting (Hosting) it gives this as an example:

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    var appBuilder = this.CreateBuilder(args)
    .Configure(host => {
        // Configure the host builder
    });

    Host = appBuilder.Build();
    ...
}

And at the Localization (Localization):

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    var appBuilder = this.CreateBuilder(args)
        .Configure(host =>
        {
            host.UseLocalization()
        });
    ...
}

Unfortunately the

MainWindow = appBuilder.Window;

part is missing from both places, and while the application works (or it seems to be working at least), it breaks the Hot Design.

If you don't need this issue remain open (to fix documentation) you may close it.

@nickrandolph
Copy link
Contributor

nickrandolph commented Jan 8, 2025

@sarosigy thanks for following up - I'll transfer this across to extensions so that we can amend the documentation.
cc @eriklimakc can we review the docs to make sure that when adding Hosting to existing apps, the MainWindow is set to the Window property on the builder.

@nickrandolph nickrandolph transferred this issue from unoplatform/studio Jan 8, 2025
@eriklimakc
Copy link
Contributor

@sarosigy @nickrandolph The details about changing how the MainWindow is assigned can be found here:
Installing Extensions in an Existing Project.

I've submitted a PR with some improvements to the docs to enhance clarity and add more details.

@sarosigy
Copy link
Author

@sarosigy @nickrandolph The details about changing how the MainWindow is assigned can be found here: Installing Extensions in an Existing Project.

I've submitted a PR with some improvements to the docs to enhance clarity and add more details.

Thank you @eriklimakc, it will add more clarity.

I maybe would add that MainWindow = appBuilder.Window; line to the HostingOverview.md, too, because that Hosting feature requires to change the default generated line, and not everyone (including myself) would read the general overview when adding a single feature. Maybe it is our limitation but it would be nice to handle this behavior.

@eriklimakc
Copy link
Contributor

Thank you @eriklimakc, it will add more clarity.

I maybe would add that MainWindow = appBuilder.Window; line to the HostingOverview.md, too, because that Hosting feature requires to change the default generated line, and not everyone (including myself) would read the general overview when adding a single feature. Maybe it is our limitation but it would be nice to handle this behavior.

@sarosigy Thanks for the thoughtful feedback! I’ve updated the PR to include your suggestion.

@Darsh0307
Copy link

@eriklimakc With 5.6.17 as the Uno.sdk i was easily able to test it on a blank app.
And there wasnt any such problem occuring.

@sarosigy
Copy link
Author

@Darsh0307 I believe that you have the MainWindow = appBuilder.Window; line in your code.
If you create your App without hosting, that line will not be there, instead it will be MainWindow = new Window();

We agreed that it is a documentation issue because if it would be in the documentation in the first place the whole issue would be nonexistent.

This is why this case is closed already.

@Darsh0307
Copy link

@sarosigy

You are correct , I have MainWindow = appBuilder.Window in my code as you said.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants