Skip to content

Commit b958f8c

Browse files
author
Darius Leo-Fidgett
committed
Fix framework subresolver to not throw NRE if no dependency type available
Fixes castleproject#478
1 parent 1754c0e commit b958f8c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Unreleased
44

55
Bugfixes:
6+
- FrameworkDependencyResolver must not throw NRE if dependency has no type (eg. depending on a named component)
7+
- Register ViewComponents and TagHelpers correctly
68
- Allow crosswiring multiple implementations of the same service
79
- Count TagHelper classes with __Generated__ in the name (eg. TagHelpers generated for ViewComponents) as Framework classes
810
- Finding the controller should be made in a case insensitive way for Castle.Facilities.AspNet.Mvc facility (@yitzchok, #480)

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)