Skip to content

Commit

Permalink
Merge pull request #35 from allegro/feature/ImproveAssemblyScanning
Browse files Browse the repository at this point in the history
Feature/improve assembly scanning
  • Loading branch information
cugoszi authored Feb 5, 2024
2 parents 486fa5d + 222cfa4 commit be8be41
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public static IServiceCollection AddDependencyCall(
s => s
.FromAssemblies(
applicationAssemblies ??
AppDomain.CurrentDomain.GetAssemblies()
// Filter microsoft assemblies due to reflection problems in Microsoft.Data.SqlClient
.Where(a => a.FullName?.StartsWith("Microsoft", StringComparison.Ordinal) != true))
AppDomain.CurrentDomain.GetAssemblies())
.AddClasses(c => c.AssignableTo(typeof(IDependencyCall<,>)))
.AsImplementedInterfaces()// TODO: remove scrutor and register by own util
.WithTransientLifetime());
Expand Down
2 changes: 1 addition & 1 deletion src/Allegro.Extensions.DependencyCall/version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>1.1.1</VersionPrefix>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using Allegro.Extensions.Identifiers.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Any;
Expand All @@ -14,12 +15,13 @@ public static class StronglyTypedIdsSwaggerExtensions
/// <summary>
/// Add swagger support for strongly typed identifiers
/// </summary>
public static IServiceCollection AddStronglyTypedIds(this IServiceCollection services)
public static IServiceCollection AddStronglyTypedIds(
this IServiceCollection services,
IReadOnlyCollection<Assembly>? applicationAssemblies = null)
{
services.Configure<SwaggerGenOptions>(options =>
{
var types = AppDomain.CurrentDomain.GetAssemblies()
.Where(a => a.FullName?.StartsWith("Microsoft", StringComparison.Ordinal) != true)
var types = (applicationAssemblies ?? AppDomain.CurrentDomain.GetAssemblies())
.SelectMany(x => x.GetTypes())
.Where(x => IsAssignableToGenericType(x, typeof(IStronglyTypedId<>)) && !x.IsInterface && !x.IsAbstract)
.ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/Allegro.Extensions.Identifiers/version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.3.0</VersionPrefix>
<VersionPrefix>1.4.0</VersionPrefix>
</PropertyGroup>
</Project>

0 comments on commit be8be41

Please sign in to comment.