Skip to content

Commit

Permalink
Don't scan System.Data.SqlClient by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrzesniewski committed Nov 20, 2023
1 parent cb72758 commit 335b3e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Abc.Zebus/Core/BusFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,18 @@ public ScanTarget(Assembly? assembly, Type? type)
}

public bool Matches(Assembly assembly)
=> _assembly == null || _assembly == assembly;
{
if (_assembly is null)
{
// Ignore this assembly by default, since GetTypes() fails there in net8.0: https://github.com/dotnet/SqlClient/issues/1930
if (assembly.GetName().Name == "System.Data.SqlClient")
return false;

return true;
}

return _assembly == assembly;
}

public bool Matches(Type type)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Abc.Zebus/Scan/TypeSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ public class TypeSource

public virtual IEnumerable<Type> GetTypes()
{
return AppDomain.CurrentDomain.GetAssemblies().Where(AssemblyFilter).SelectMany(x => x.GetTypes()).Where(TypeFilter);
return AppDomain.CurrentDomain
.GetAssemblies()
.Where(AssemblyFilter)
.SelectMany(a => a.GetTypes())
.Where(TypeFilter);
}

public static implicit operator TypeSource(Type type)
Expand Down

0 comments on commit 335b3e9

Please sign in to comment.