Skip to content

FromExecutingAssembly and FromCallingAssembly are misleading #92

@justinbhopper

Description

@justinbhopper

FromExecutingAssembly 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)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions