Skip to content

Commit bcf2fc3

Browse files
committed
Fix framework subresolver to not throw NRE if no dependency type available
Fixes castleproject#478
1 parent 4fb67a8 commit bcf2fc3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
Bugfixes:
6+
- ASP.NET Core Facility: FrameworkDependencyResolver must not throw NRE if dependency has no type (eg. depending on a named component)
67
- ASP.NET Core Facility: Register ViewComponents and TagHelpers correctly
78
- ASP.NET Core Facility: Allow crosswiring multiple implementations of the same service
89
- ASP.NET Core Facility: Count TagHelper classes with __Generated__ in the name (eg. TagHelpers generated for ViewComponents) as Framework classes

src/Castle.Facilities.AspNetCore/Resolvers/FrameworkDependencyResolver.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public object Resolve(CreationContext context, ISubDependencyResolver contextHan
5151

5252
public bool HasMatchingType(Type dependencyType)
5353
{
54-
return serviceCollection.Any(x => x.ServiceType.MatchesType(dependencyType));
54+
return dependencyType != null &&
55+
serviceCollection.Any(x => x.ServiceType.MatchesType(dependencyType));
5556
}
5657

5758
private void ThrowIfServiceProviderIsNull()
@@ -69,7 +70,7 @@ public static bool MatchesType(this Type type, Type otherType)
6970
{
7071
var genericType = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
7172
var genericOtherType = otherType.IsGenericType ? otherType.GetGenericTypeDefinition() : otherType;
72-
return genericType == genericOtherType || genericOtherType == genericType;
73+
return genericType == genericOtherType;
7374
}
7475
}
7576
}

0 commit comments

Comments
 (0)