Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Carter/CarterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

foreach (var carterModuleInterface in builder.ServiceProvider.GetServices<ICarterModule>())
{
if (carterModuleInterface is CarterModule carterModule)

Check warning on line 33 in src/Carter/CarterExtensions.cs

View workflow job for this annotation

GitHub Actions / Github Actions Build

'CarterModule' is obsolete: 'CarterModule will be removed in the next version. Please migrate to ICarterModule.'

Check warning on line 33 in src/Carter/CarterExtensions.cs

View workflow job for this annotation

GitHub Actions / Github Actions Build

'CarterModule' is obsolete: 'CarterModule will be removed in the next version. Please migrate to ICarterModule.'
{
var group = builder.MapGroup(carterModule.basePath);

Expand Down Expand Up @@ -281,7 +281,9 @@
{
validators = assemblies.SelectMany(ass => ass.GetTypes())
.Where(typeof(IValidator).IsAssignableFrom)
.Where(t => !t.GetTypeInfo().IsAbstract);
.Where(t =>
!t.GetTypeInfo().IsAbstract &&
!t.ContainsGenericParameters); // skip open generic validators

carterConfigurator.ValidatorTypes.AddRange(validators);
}
Expand Down
26 changes: 19 additions & 7 deletions src/Carter/DependencyContextAssemblyCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,29 @@ public virtual IReadOnlyCollection<Assembly> GetAssemblies()
{
results.Add(overriddenAssembly);
}

return results;
}

// DependencyContext is unavailable in single-file published apps.
// In that case, return the assemblies already loaded into the AppDomain.
if (this.dependencyContext is null)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
results.Add(assembly);
}

return results;
}
else

foreach (var library in this.dependencyContext.RuntimeLibraries)
{
foreach (var library in this.dependencyContext.RuntimeLibraries)
if (IsReferencingCarter(library) || IsReferencingFluentValidation(library))
{
if (IsReferencingCarter(library) || IsReferencingFluentValidation(library))
foreach (var assemblyName in library.GetDefaultAssemblyNames(this.dependencyContext))
{
foreach (var assemblyName in library.GetDefaultAssemblyNames(this.dependencyContext))
{
results.Add(SafeLoadAssembly(assemblyName));
}
results.Add(SafeLoadAssembly(assemblyName));
}
}
}
Expand Down
Loading