Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.79k stars 776 forks source link

Change hardcoded assembly name to reflected assembly name #841

Open foldax opened 1 year ago

foldax commented 1 year ago

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

vb2ae commented 1 year ago

what platform are you using caliburn.micro with?

foldax commented 1 year ago

.net 4.8 WPF, so for my scenario changing \src\Caliburn.Micro.Platform\ConventionManager.cs is enough, but it's better to change both

KasperSK commented 1 year ago

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

foldax commented 1 year ago

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

eeevans commented 1 year ago

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

a44281071 commented 1 year ago

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