You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 classes
BaseRegistry : ServiceRegistry which which scans TheCallingAssembly and WithDefaultConventions
AppRegistryInclude : ServiceRegistry which just calls IncludeRegistry<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 not Assembly.Core where as when the Include registry uses the BaseRegistry directly then the scanner will scan Assembly.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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: