FromExecutingAssembly and FromCallingAssembly are misleading
See original GitHub issueFromExecutingAssembly
and FromCallingAssembly
are misleading. The naming suggests that it will use the assemblies from the perspective of where it is being called, but actually uses scrutor’s perspective.
https://github.com/khellang/Scrutor/blob/master/src/Scrutor/TypeSourceSelector.cs#L20
public IImplementationTypeSelector FromCallingAssembly()
{
return FromAssemblies(Assembly.GetCallingAssembly());
}
public IImplementationTypeSelector FromExecutingAssembly()
{
return FromAssemblies(Assembly.GetExecutingAssembly());
}
Because these methods are defined in Scrutor, the resulting assemblies will be:
- FromCallingAssembly will use the assembly that called Scrutor, rather than the actual calling assembly.
- FromExecutingAssembly will use Scrutor’s assembly. Always.
In other words,
scan.FromCallingAssembly === scan.FromAssemblies(Assembly.GetExecutingAssembly())
scan.FromExecutingAssembly === scan.FromAssemblies(typeof(Scrutor).Assembly)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:9 (5 by maintainers)
Top Results From Across the Web
ImplementationTypeSelector.cs - khellang/Scrutor
Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection - Scrutor/src/Scrutor/ImplementationTypeSelector.cs at master ...
Read more >Using Scrutor to automatically register your services with ...
In this post I describe how to use the open source library Scrutor to add assembly scanning capabilities to the ASP.NET Core DI...
Read more >Scrutor - Bountysource
FromExecutingAssembly and FromCallingAssembly are misleading. The naming suggests that it will use the assemblies from the perspective of where it is being ...
Read more >Why I don't use MediatR for CQRS
Looks like the naming of Scrutor methods is a little bit misleading. The problem is well-known and described here https://github.com/khellang...
Read more >Using snake case column names with Dapper and PostgreSQL
In this post I'll discuss a technique I use occasionally to ensure that an ASP.NET Core app is able to start correctly, as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s my simple workaround:
Got stuck on this again. For CallingAssembly, I needed to do
Otherwise, the calling assembly ends up being Scrutor.