For my brilliant friend Steve.
AOT-Safe, Source-Generated, ViewLocation for Avalonia
===========================
- Assembly-Setup 1.1) The Source-Gen assembly is netstandard2.0 and requires:
==========================
=========================
[ It's only v3.8.0 because Avalonia requires exactly that version. ]
1.2) Keep in mind there can be problems when trying to change the roslyn- assemblies' versions due to the Avaloniaan dependency.
++++++++++++++++++++++++++
- Usage
2.1) Set the import-usings via the
AddNamesspaceUsings()-method [markedA)] 2.2) Set the namespace-name via the fields_Setting_Namespace[markedB)] 2.3) InApp.xaml.csat invocationstart ofOnFrameworkInitialized()init the ViewLocator and call theViewLocator.PopulateViewModelViewMappings()-method [markedC)] 2.4) ViewLocator-class needs to bepartial2.5) In the class that references the SourceGen, modify the reference, addingOutputItemType="Analyzer" ReferenceOutputAssembly="false"to the end of the Project-Ref.
==========================
==========================
2.6) Make sure the ViewLocator.cs class provides the same functionality like (or is) the ViewLocator.cs in this project. It needs the Locator-Dictionary and has to use the factories.
-
Testing / Debugging I'd like to see what the Source-Gen generates...
In the .csproj that references the Source-Generator add these settings to the main Propertygroup:
=========================
true $(ProjectDir)GeneratedFiles
=========================
In the Main-Solution-Directory will spawn a GeneratedFiles-dir which hosts the generated sources.
In order to be able to run the project again, you will have to delete these files quite certainly.
[since Avalonia's source-generated files will also spawn there, and create duplicate Type-Errors]