Open hahn-kev opened 3 years ago
@hahn-kev, I don't think there's anything actionable here. If in doubt, explicitly specify the assembly by using a type, then saying "type.Assembly".
I'm just not enthusiastic about getting into this kind of inheritance with service registries.
I just ran into an issue when using the assembly scanner where
scan.TheCallingAssembly()
worked differently depending on how the registry was used. Unfortunately it's hard to provide a simple reproduction since it requires 2 different projects to reproduce. But I'll provide an example of the issue.Example:
Assembly.Core
contains the following classesBaseRegistry : ServiceRegistry
which which scansTheCallingAssembly
andWithDefaultConventions
Service : IService
both declared in this assemblyAssembly.App
contains the following:AppRegistryInherit : BaseRegistry
doesn't scan anythingAppRegistryInclude : ServiceRegistry
which just callsIncludeRegistry<BaseRegistry>()
my expectation is that both of the app registries work the same, however it turns out they don't because of how assembly scanning is implemented. When the inherit registry scanner runs it will only scan
Assembly.App
and notAssembly.Core
where as when the Include registry uses theBaseRegistry
directly then the scanner will scanAssembly.Core
.I ran into this issue when doing some refactoring of how we use registries, in some cases we were inheriting from a base registry and in others we were just calling include registry. I'd like to keep it consistent so I refactored our code to use include across the board, at that point I started getting weird errors as the scanner was now adding different services than it was before.
Taking a look at the code it looks like
TheCallingAssembly
has 2 paths implemented, one case it will determine the assembly based on the type of the registry, this means that the assembly will change if the registry is inherited from.