Caliburn.Micro icon indicating copy to clipboard operation
Caliburn.Micro copied to clipboard

Change hardcoded assembly name to reflected assembly name

Open foldax opened this issue 3 years ago • 6 comments

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

foldax avatar Jan 02 '23 09:01 foldax

what platform are you using caliburn.micro with?

vb2ae avatar Jan 02 '23 11:01 vb2ae

.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 avatar Jan 02 '23 11:01 foldax

@foldax what is the issue with having the assembly name hardcoded?

KasperSK avatar Jan 12 '23 08:01 KasperSK

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: @.***>

foldax avatar Jan 12 '23 12:01 foldax

This doesn't seem like a common scenario. What is the performance impact? Should this be cached in a static?

eeevans avatar Mar 21 '23 03:03 eeevans

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

a44281071 avatar Jun 07 '23 02:06 a44281071