diff --git a/src/Conventions.Abstractions/ConventionContextBuilder.cs b/src/Conventions.Abstractions/ConventionContextBuilder.cs index d3d34f6672..2fadc84fbc 100644 --- a/src/Conventions.Abstractions/ConventionContextBuilder.cs +++ b/src/Conventions.Abstractions/ConventionContextBuilder.cs @@ -6,6 +6,7 @@ using PropertiesDictionary = System.Collections.Generic.Dictionary; #endif using System.Reflection; +using System.Runtime.Loader; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -70,6 +71,7 @@ public ConventionContextBuilder EnableConventionAttributes() /// public ConventionContextBuilder WithConventionsFrom(IConventionFactory conventionFactory) { + this.AddIfMissing(AssemblyLoadContext.Default); _conventionProviderFactory = conventionFactory; return this; } @@ -379,4 +381,4 @@ public ConventionContextBuilder IncludeConvention(Assembly assembly, params Asse _includeAssemblyConventions.AddRange(assemblies); return this; } -} \ No newline at end of file +} diff --git a/src/Conventions/Testing/TestConventionContextBuilderExtensions.cs b/src/Conventions/Testing/TestConventionContextBuilderExtensions.cs index afb61637c2..23df0a50a8 100644 --- a/src/Conventions/Testing/TestConventionContextBuilderExtensions.cs +++ b/src/Conventions/Testing/TestConventionContextBuilderExtensions.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.Loader; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; @@ -58,6 +59,7 @@ public static ConventionContextBuilder ForTesting( var logger = loggerFactory.CreateLogger("TestContext"); return builder + .AddIfMissing(AssemblyLoadContext.Default) .Set(HostType.UnitTest) .WithConventionsFrom(factory) .WithLoggerFactory(loggerFactory) @@ -306,4 +308,4 @@ private static void EnsureConfigured(ConventionContextBuilder builder) // // return builder; // } -} \ No newline at end of file +}