Skip to content

Commit a9e032d

Browse files
authored
Merge pull request #859 from jvandertil/remove-typeinfo-call
Remove unnecessary usage of GetTypeInfo
2 parents 89025ea + a3e0d4e commit a9e032d

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/MediatR/Registration/ServiceRegistrar.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ private static bool CanBeCastTo(this Type pluggedType, Type pluginType)
157157

158158
if (pluggedType == pluginType) return true;
159159

160-
return pluginType.GetTypeInfo().IsAssignableFrom(pluggedType.GetTypeInfo());
160+
return pluginType.IsAssignableFrom(pluggedType);
161161
}
162162

163163
private static bool IsOpenGeneric(this Type type)
164164
{
165-
return type.GetTypeInfo().IsGenericTypeDefinition || type.GetTypeInfo().ContainsGenericParameters;
165+
return type.IsGenericTypeDefinition || type.ContainsGenericParameters;
166166
}
167167

168168
private static IEnumerable<Type> FindInterfacesThatClose(this Type pluggedType, Type templateType)
@@ -176,33 +176,33 @@ private static IEnumerable<Type> FindInterfacesThatClosesCore(Type pluggedType,
176176

177177
if (!pluggedType.IsConcrete()) yield break;
178178

179-
if (templateType.GetTypeInfo().IsInterface)
179+
if (templateType.IsInterface)
180180
{
181181
foreach (
182182
var interfaceType in
183183
pluggedType.GetInterfaces()
184-
.Where(type => type.GetTypeInfo().IsGenericType && (type.GetGenericTypeDefinition() == templateType)))
184+
.Where(type => type.IsGenericType && (type.GetGenericTypeDefinition() == templateType)))
185185
{
186186
yield return interfaceType;
187187
}
188188
}
189-
else if (pluggedType.GetTypeInfo().BaseType!.GetTypeInfo().IsGenericType &&
190-
(pluggedType.GetTypeInfo().BaseType!.GetGenericTypeDefinition() == templateType))
189+
else if (pluggedType.BaseType!.IsGenericType &&
190+
(pluggedType.BaseType!.GetGenericTypeDefinition() == templateType))
191191
{
192-
yield return pluggedType.GetTypeInfo().BaseType!;
192+
yield return pluggedType.BaseType!;
193193
}
194194

195-
if (pluggedType.GetTypeInfo().BaseType == typeof(object)) yield break;
195+
if (pluggedType.BaseType == typeof(object)) yield break;
196196

197-
foreach (var interfaceType in FindInterfacesThatClosesCore(pluggedType.GetTypeInfo().BaseType!, templateType))
197+
foreach (var interfaceType in FindInterfacesThatClosesCore(pluggedType.BaseType!, templateType))
198198
{
199199
yield return interfaceType;
200200
}
201201
}
202202

203203
private static bool IsConcrete(this Type type)
204204
{
205-
return !type.GetTypeInfo().IsAbstract && !type.GetTypeInfo().IsInterface;
205+
return !type.IsAbstract && !type.IsInterface;
206206
}
207207

208208
private static void Fill<T>(this IList<T> list, T value)

0 commit comments

Comments
 (0)