It should be possible to avoid calling ResourceDictionary.SetAndLoadSource when all XAML resources are compiled. It should be possible to generate IL that creates an instance of the ResourceDictionary subclass corresponding to the path directly. Besides from minor perf improvement, the code should be more trimming friendly (we wouldn't even need to use a feature flag to avoid XAML parsing at runtime in this codepath).
/cc @StephaneDelcroix