Open Ehrode opened 11 months ago
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?
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,
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?
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:
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:
Now if I go to visual studio error list tab:
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.
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:
From error list I can then see this
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:
No errors shown on the designer but my view doesn't shows up.
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.