I would like to replace a class at the assembly level so all references call a new implementation. Lets say I have common class used in assemblies throughout my project such as
System.Generic.Collections.List
My project references other assemblies who rely on List
as well.
Now lets say I want to use my version of List
Where ever this is called.
var values = new List<int> { 1, 2, 3, 4, 5 }
How can replace a class on the assembly level so I don't have to update any references in my code or so that it can be done in a single location.
I remember there are metadata buddy classes and things like that is it possible to override using a global pragma? I vaguely remember using syntax like this for something: System.Generic.Collections.List::MyAssembly.List
I would like to replace this in a duck-typed
way where the underly class doesn't nessecarily have to inherit from the original but I should have all the methods exposed in the same manner
Note: I need to resolve this in a global manner, a single entry point via reflection or configuration.
I've already done things in the past to dynamically replace methods, see: Dynamically Append Code to a method .Net-Core