AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.42k stars 2.2k forks source link

UI designer incompatible with System.CommandLine.DragonFruit #6145

Open ThadHouse opened 3 years ago

ThadHouse commented 3 years ago

I was attempting to write a project where if I passed no arguments it would start a UI app, but if passed with arguments it would act like a command line app. To do the command line part and make it easy, I was using System.CommandLine.DragonFruit. That package rewrites an apps main program class into a class called AutoGeneratedProgram. However, the UI designer doesn't seem to like this, and fails with "AutoGeneratedProgram doesn't have a method named BuildAvaloniaApp". I know compatibility with things like this is hard, but I wonder if an attribute on the class containing BuildAvaloniaApp would be better, as anything that would rewrite Main() would still work just fine.

maxkatz6 commented 3 years ago

Ideally, I would expect AutoGeneratedProgram to be partial: https://github.com/dotnet/command-line-api/blob/72e86ec7615c0c8ecb6a13e34a5c0a97e9309909/src/System.CommandLine.DragonFruit/targets/System.CommandLine.DragonFruit.targets#L31

But having an attribute to find designer builder method also sounds good to me. I believe this piece of code should be modified for that.

ThadHouse commented 3 years ago

I'll work on doing that this weekend. Its an easy change that can be done as a way that wouldn't change behavior of existing apps. Just need to finish cleaning it up and testing.

https://github.com/ThadHouse/Avalonia/commit/c96f5f86dec8107cc68e7cbe864f8725270e240e

rstm-sf commented 3 years ago

Hello, @ThadHouse. Feel free to suggest your changes by PR :)