Merge remote-tracking branch 'origin/v10/dev' into v11/dev

This commit is contained in:
Bjarke Berg
2023-08-15 10:15:28 +02:00
3 changed files with 16 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ public class TypeFinder : ITypeFinder
/// its an exact name match
/// NOTE this means that "foo." will NOT exclude "foo.dll" but only "foo.*.dll"
/// </remarks>
internal static readonly string[] KnownAssemblyExclusionFilter =
internal static string[] KnownAssemblyExclusionFilter =
{
"mscorlib,", "netstandard,", "System,", "Antlr3.", "AutoMapper,", "AutoMapper.", "Autofac,", // DI
"Autofac.", "AzureDirectory,", "Castle.", // DI, tests
@@ -49,11 +49,20 @@ public class TypeFinder : ITypeFinder
private string[]? _assembliesAcceptingLoadExceptions;
private volatile HashSet<Assembly>? _localFilteredAssemblyCache;
[Obsolete("Please use the constructor taking all parameters. This constructor will be removed in V14.")]
public TypeFinder(ILogger<TypeFinder> logger, IAssemblyProvider assemblyProvider, ITypeFinderConfig? typeFinderConfig = null)
: this(logger, assemblyProvider, null, typeFinderConfig)
{ }
public TypeFinder(ILogger<TypeFinder> logger, IAssemblyProvider assemblyProvider, string[]? additionalExlusionAssemblies, ITypeFinderConfig? typeFinderConfig = null)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_assemblyProvider = assemblyProvider;
_typeFinderConfig = typeFinderConfig;
if (additionalExlusionAssemblies is not null)
{
KnownAssemblyExclusionFilter = KnownAssemblyExclusionFilter.Union(additionalExlusionAssemblies).ToArray();
}
}
/// <inheritdoc />

View File

@@ -22,4 +22,9 @@ public class TypeFinderSettings
/// scanning for plugins based on different root referenced assemblies you can add the assembly name to this list.
/// </summary>
public IEnumerable<string>? AdditionalEntryAssemblies { get; set; }
/// <summary>
/// Gets or sets a value for the assemblies that will be excluded from scanning.
/// </summary>
public string[] AdditionalAssemblyExclusionEntries { get; set; } = Array.Empty<string>();
}

View File

@@ -208,6 +208,7 @@ public static class ServiceCollectionExtensions
var typeFinder = new TypeFinder(
loggerFactory.CreateLogger<TypeFinder>(),
assemblyProvider,
typeFinderSettings.AdditionalAssemblyExclusionEntries,
typeFinderConfig);
var typeLoader = new TypeLoader(typeFinder, loggerFactory.CreateLogger<TypeLoader>());