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

Designer doesn't show some errors while loading its view #316

Open
Ehrode opened this issue Dec 9, 2023 · 4 comments
Open

Designer doesn't show some errors while loading its view #316

Ehrode opened this issue Dec 9, 2023 · 4 comments
Assignees
Labels
kind:bug Something isn't working

Comments

@Ehrode
Copy link

Ehrode commented Dec 9, 2023

I have some code that compiles but crashes at runtime.

From visual studio when I try to load any page of the Designer I get this:
image

From error list I can then see this
image

Perfect this is expected behavior.

The exact same project with the exact same code on Rider using Avalonia plugin.
The designer doesn't display any error:

image
No errors shown on the designer but my view doesn't shows up.

image
Also from the designer console, no errors are shown.

I actually need to swap to VS when the designer stops working to actually see what's going on.

Could be great to be able to see those errors directly from Rider.

Maybe I'm missing a special IDE window where errors are displayed?

Regards, Jasone.

@ForNeVeR
Copy link
Owner

ForNeVeR commented Dec 9, 2023

Hm, could you please clarify the nature of this error? What is it exactly? Is it a compile-time error?

Also, what is this "error list" exactly? What does it show?

@ForNeVeR ForNeVeR added the status:waiting-for-info The maintainers are waiting for the additional information from the issue reporter label Dec 9, 2023
@Ehrode
Copy link
Author

Ehrode commented Dec 10, 2023

No its runtime error. This works for multiple runtime errors. In the presented sample, the error comes from DI. I had an interface that had no implementation registered and one of my viewmodel was using this interface. So when the viewmodel was instantiated, he ask the IOC container to provide the service implementation which was null and crashed to app later on when using this interface.

The "error list" is just the standard visual studio view that normal displays compile time errors / warning. As avalonia builds the app in design mode and runs it to get the previewer working, the "runtime" errors of this design mode run are redirect to this window which is usually filled with "compile time" errors,

@ForNeVeR
Copy link
Owner

Okay, I still don't understand. What exactly is "a runtime error"? Is it an exception? Where's it thrown? How's it detected? Could you please provide an example?

@Ehrode
Copy link
Author

Ehrode commented Dec 11, 2023

Here you go, zip of project that exactly reproduce the issue. This is the base avalonia MVVM template project.
The only code I added is a constructor to the MainWindowViewModel:

image

The code compiles, this is all valid C#, but when the previewer will try to bind the MainWindow to the MainWindowViewModel, an uncaught exception is raised.

In Rider as told before, I will end up with an empty previewer and no errors displayed anywhere (or I didn't find the window indicating the issue).

If I open the exact same project on Visual Studio and display the MainWindow previewer I have this:

image

Now if I go to visual studio error list tab:

image

I can see the exception that I raised from the view model constructor which helps me understand why the previewer fails to render the view. (In my example this is really obvious because I just threw an exception myself from constructor but when you start to have really complicated ViewModels with exceptions that you can't see until the application is effectively running, the visual studio ability to indicates what will happen when you run the app becomes really handy).

Please find the attached project zip, you can open the solutions from both Visual Studio (I'm using community 2022 with the Avalonia extension) and Rider using your plugin and I'm sure you will understand what I'm missing.

SampleRiderMarkupException.zip

@ForNeVeR ForNeVeR removed the status:waiting-for-info The maintainers are waiting for the additional information from the issue reporter label Dec 11, 2023
@ForNeVeR ForNeVeR added the kind:bug Something isn't working label Dec 11, 2023
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

No branches or pull requests

2 participants