Skip to content

Commit

Permalink
Fix ReflectionTypeLoadException
Browse files Browse the repository at this point in the history
* Fix ReflectionTypeLoadException when Microsoft.NET.Test.Sdk 16.9.1
  • Loading branch information
gojanpaolo authored Feb 28, 2021
1 parent aa97acc commit fbc95ed
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Snapshooter.Json.Tests/Snapshooter.Json.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 1 addition & 1 deletion src/Snapshooter.NUnit.Tests/Snapshooter.NUnit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Snapshooter.Tests/Snapshooter.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 1 addition & 1 deletion src/Snapshooter.Xunit.Tests/Snapshooter.Xunit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Snapshooter.Core.Serialization
{
Expand All @@ -11,10 +12,20 @@ public IEnumerable<SnapshotSerializerSettings> GetConfiguration()
Type type = typeof(SnapshotSerializerSettings);

var typesExtendingSettings = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p =>
type.IsAssignableFrom(p) &&
p.IsClass &&
.SelectMany(s =>
{
try
{
return s.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types;
}
})
.Where(p =>
type.IsAssignableFrom(p) &&
p.IsClass &&
p.GetConstructor(Type.EmptyTypes) != null)
.ToList();

Expand Down

0 comments on commit fbc95ed

Please sign in to comment.