[Mono-list] Embedded API: Method signature not found with generic parameter
mugginsoft
jonathan at mugginsoft.com
Thu Jul 11 19:08:33 UTC 2013
Robert Jordan wrote
> Oops, my test actually passes with:
>
> ":ToList(System.Collections.Generic.IEnumerable`1
> <TSource>
> )"
Thanks. I thought I had tried all the combinations - I should have been more
methodical! I wonder why the method name querying functions provide a
different sig?
However (one last however):
Calling the method results in:
* Assertion at method-to-ir.c:6281, condition `!sig->has_type_parameters'
not met
My argument to the above method is an instance of
System.Data.Objects.ObjectSet<TEntity> which conforms to
IEnumerable<TEntity>.
mono_class_get_interfaces reports that the argument supports:
Interface name: IObjectSet`1
Interface name: IQueryable`1
Interface name: IEnumerable`1
Interface name: IQueryable
Interface name: IEnumerable
// get a reference to the System.Core assembly
MonoAssemblyName *monoAssemblyName =
mono_assembly_name_new("System.Core");
MonoAssembly *monoSystemCoreAssembly =
mono_assembly_loaded(monoAssemblyName);
mono_assembly_name_free(monoAssemblyName);
MonoType *monoType =
mono_reflection_type_from_name("System.Linq.Enumerable", (MonoImage
*)mono_assembly_get_image(monoSystemCoreAssembly));
MonoClass *monoClass = mono_class_from_mono_type(monoType);
if (!monoClass) abort;
const char *className = mono_class_get_name(monoClass);
[DBMonoObjectRepresentation logMonoClassInfo:monoClass];
// mono_class_get_method_from_name takes a simple method name
const char *methodName = "ToList";
MonoMethod *method = mono_class_get_method_from_name(monoClass,
methodName, 1);
if (!method) {
abort(); // passes
}
// get the method by descriptor
method = nil;
methodName =
":ToList(System.Collections.Generic.IEnumerable`1<TSource>)";
MonoMethodDesc *methodDesc = mono_method_desc_new(methodName, YES);
while (monoClass != NULL) {
method = mono_method_desc_search_in_class(methodDesc, monoClass);
if (method != NULL) {
break;
}
monoClass = mono_class_get_parent(monoClass);
}
if (!method) {
abort(); // passes
}
MonoObject *monoException = NULL;
MonoObject *retval = NULL;
void *args [1];
args [0] = [self monoObject]; // Obj-C method supplies the MonoObject
handle
retval = mono_runtime_invoke(method, NULL, args, &monoException); //
fails
Jonathan
--
View this message in context: http://mono.1490590.n4.nabble.com/Embedded-API-Method-signature-not-found-with-generic-parameter-tp4660157p4660168.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list