Change hardcoded assembly name to reflected assembly name
There are two places in solution with hardcoded assembly name:
\src\Caliburn.Micro.Platform\ConventionManager.cs line 66
\src\Caliburn.Micro.Platform\ActionMessage.cs line 206
This:
"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' " +
"xmlns:cal='clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform'> " +
"<ContentControl cal:View.Model=\"{Binding}\" VerticalContentAlignment=\"Stretch\" HorizontalContentAlignment=\"Stretch\" IsTabStop=\"False\" />" +
"</DataTemplate>"
should be changed to this:
"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' " +
$"xmlns:cal='clr-namespace:Caliburn.Micro;assembly={Assembly.GetExecutingAssembly().GetName().Name}'> " +
"<ContentControl cal:View.Model=\"{Binding}\" VerticalContentAlignment=\"Stretch\" HorizontalContentAlignment=\"Stretch\" IsTabStop=\"False\" />" +
"</DataTemplate>"
I know it's generally not a mistake, but for some scenarios, second code is much better and currently I'm working on such
what platform are you using caliburn.micro with?
.net 4.8 WPF, so for my scenario changing \src\Caliburn.Micro.Platform\ConventionManager.cs is enough, but it's better to change both
@foldax what is the issue with having the assembly name hardcoded?
Well, I had to resolve conflicts between addins loaded into single AppDomain. These addins come from different vendors. Caliburn uses static classes like IoC or ViewLocator. This is where conflicts occur. So, what i do, is assembly renaming, Caliburn is changed to something like Caliburn1 for addin1. It resolves my problem. I had to change this hardcoded value in IL, so i think it's better for future development to change it to Reflected value. It's more flexible i think.
czw., 12 sty 2023 o 09:08 KasperSK @.***> napisał(a):
@foldax https://github.com/foldax what is the issue with having the assembly name hardcoded?
— Reply to this email directly, view it on GitHub https://github.com/Caliburn-Micro/Caliburn.Micro/issues/841#issuecomment-1379950798, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEYCMN6UTA3LKIRGN7BLBLWR63ZRANCNFSM6AAAAAATOURTQY . You are receiving this because you were mentioned.Message ID: @.***>
This doesn't seem like a common scenario. What is the performance impact? Should this be cached in a static?
This is a string template? We can use c# 11 'Raw string literals;'; https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11#raw-string-literals