Closed hamarb123 closed 1 year ago
Thanks for the report! It's most definitely a bug, but I need to investigate this a bit more to understand what's going on.
In the meantime, you can work around the issue by not filtering on the return type:
IL.Emit.Call(MethodRef.Method(typeof(Span<int>), nameof(Span<int>.ToArray)));
Thank you for the work around, let me know how the investigating goes
I understood and fixed the problem, but your example also made another unit test fail (oops), so I'll need to fix that as well before I release the next version. 😅
Thank you for fixing the issue! Let me know when you've released it so I can update to it.
I was wondering if it would be possible for you to also add an overload to MethodRef.Method
that accepts a bool isInstance
so we can have full control over which method it selects.
Would it also be possible to have a mechanism that tells the weaver to not check if the method exists at all so you can target methods which may not exist? This could just be a part of how the overload with bool isInstance
works since it wouldn't need to resolve, but it could also just be a method on a MethodRef
that returns a new MethodRef
that the weaver interprets as 'just emit it without searching for it'.
Edit: should I make a new issue for the above feature requests?
I was wondering if it would be possible for you to also add an overload to
MethodRef.Method
that accepts abool isInstance
so we can have full control over which method it selects.
I suppose I could, but:
static
is just one of many flags a method can have, should it be considered more interesting than the others?Why would you need to have this degree of control? You'll get an error if a selector is ambiguous or no method is found.
Would it also be possible to have a mechanism that tells the weaver to not check if the method exists at all so you can target methods which may not exist?
Theoretically yes, but it could be complicated in practice and could require a lot of work. Currently, the metadata comes from the resolved type. Without this metadata, the full method signature blob would need to be manually reconstructed, and that's not exactly straightforward: see ECMA-335 II.23.2.
May I ask why you'd like to have such a feature?
May I ask why you'd like to have such a feature?
I've thought about it more, and I probably don't really need this currently, I was thinking in the case of having some funky method I wanted to call.
The fix is released in v1.7.4.
The following code produces an error that indicates there's an issue with either this library or Mono.Cecil (or I've severly misunderstood the error):
(This should generate something very similar to)
It's this line that seems to cause the issue:
Stack trace in a more readable form