Skip to content

Commit

Permalink
FromExecutingAssembly and FromCallingAssembly are misleading #92
Browse files Browse the repository at this point in the history
  • Loading branch information
savornicesei authored and khellang committed Sep 25, 2024
1 parent ade33df commit a55d056
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/Scrutor/TypeSourceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,46 @@ public IImplementationTypeSelector FromAssemblyOf<T>()
return InternalFromAssembliesOf(new[] { typeof(T) });
}

/// <summary>
/// Uses the assembly that called Scrutor.
/// </summary>
/// <remarks>
/// <para>
/// Returned <see cref="Assembly"/> might not be the one expected do to (lack of) inlining.
/// To ensure proper assembly is resolved, use:
/// <code>
/// services.Scan(s => s.FromAssemblies(Assembly.GetExecutingAssembly())
/// </code>
/// or
/// <code>
/// var assembly = Assembly.GetCallingAssembly();
/// services.Scan(s => s.FromAssemblies(assembly));
/// </code>
/// </para>
/// </remarks>
[Obsolete("Misleading, as it might not always determine the correct assembly that called Scrutor. Will be removed in a future release")]
public IImplementationTypeSelector FromCallingAssembly()
{
return FromAssemblies(Assembly.GetCallingAssembly());
}


/// <summary>
/// Always uses the Scrutor assembly.
/// </summary>
/// <remarks>
/// <para>
/// To ensure proper assembly is resolved, use:
/// <code>
/// services.Scan(s => s.FromAssemblies(Assembly.GetExecutingAssembly())
/// </code>
/// or
/// <code>
/// var assembly = Assembly.GetCallingAssembly();
/// services.Scan(s => s.FromAssemblies(assembly));
/// </code>
/// </para>
/// </remarks>
[Obsolete("Misleading, as it always uses Scrutor's assembly. Will be removed in a future release")]
public IImplementationTypeSelector FromExecutingAssembly()
{
return FromAssemblies(Assembly.GetExecutingAssembly());
Expand Down

0 comments on commit a55d056

Please sign in to comment.