public static ReadOnlyCollection <TypeSlim> GetGenericArguments(this MethodInfoSlim method) { return(method switch { GenericMethodInfoSlim gen => gen.GenericArguments, GenericDefinitionMethodInfoSlim def => def.GenericParameterTypes, _ => throw new InvalidOperationException(), });
public static string GetName(this MemberInfoSlim m) { return(m switch { SimpleMethodInfoSlimBase smtd => smtd.Name, GenericMethodInfoSlim gmtd => gmtd.GenericMethodDefinition.GetName(), PropertyInfoSlim prp => prp.Name, FieldInfoSlim fld => fld.Name, _ => "<unknown>", });
protected override int MakeGenericMethod(GenericMethodInfoSlim method, int methodDefinition) => Combine((int)method.MemberType, methodDefinition, Visit(method.GenericArguments));
protected override int MakeGenericMethod(GenericMethodInfoSlim method, int methodDefinition) => methodDefinition + 2;
private static void AssertAreSameGenericMethod(MethodInfo methodInfo, GenericMethodInfoSlim genericMethodInfoSlim) { AssertAreSameMethod(methodInfo.GetGenericMethodDefinition(), genericMethodInfoSlim.GenericMethodDefinition); Assert.IsTrue(genericMethodInfoSlim.GenericArguments.SequenceEqual(methodInfo.GetGenericArguments().Select(t => t.ToTypeSlim()))); }