Skip to content

Commit

Permalink
fix fortesting to add assembyloadcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed Apr 16, 2024
1 parent 4399594 commit 7ade770
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Conventions.Abstractions/ConventionContextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using PropertiesDictionary = System.Collections.Generic.Dictionary<object, object?>;
#endif
using System.Reflection;
using System.Runtime.Loader;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -70,6 +71,7 @@ public ConventionContextBuilder EnableConventionAttributes()
/// <returns></returns>
public ConventionContextBuilder WithConventionsFrom(IConventionFactory conventionFactory)
{
this.AddIfMissing(AssemblyLoadContext.Default);
_conventionProviderFactory = conventionFactory;
return this;
}
Expand Down Expand Up @@ -379,4 +381,4 @@ public ConventionContextBuilder IncludeConvention(Assembly assembly, params Asse
_includeAssemblyConventions.AddRange(assemblies);
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.Loader;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -306,4 +308,4 @@ private static void EnsureConfigured(ConventionContextBuilder builder)
//
// return builder;
// }
}
}

0 comments on commit 7ade770

Please sign in to comment.