-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Reflection.MetadataLoadContext doesn't support function pointer types #43791
Comments
Hmm how is Roslyn reading such metadata? |
This looks like a bug in System.Reflection.MetadataLoadContext. It's a library built on top of System.Reflection.Metadata that provides additional abstractions over the metadata. Roslyn only uses S.R.Metadata, not this extra layer with the missing implementation. |
It is apparently by design since it throws an explicit This overlaps with #11354 where we don't return function pointer type from standard reflection either and need a way to represent that. Doing a |
@vargaz @CoffeeFlux can you add more detail including the workaround you use, and the "blocking" label if you consider it blocking. Thanks |
We just hardcode the method names which have these types in our code, it's not currently a blocker for us. |
@steveharter the current workaround is here
|
This is a feature that will be a important addition for libraries like SkiaSharp running on WebAssembly. |
Yes it will be required for #44636 if we continue to use MLC |
This will be an ongoing issue for blazor/webassembly. |
@krwq why was it moved to 7.0 when #43791 (comment) explained that this is needed for P1 .NET user story? |
My 5 cents: I'm not sure this can be implemented in MetadataLoadContext without first defining how function pointers are supposed to look like within the runtime/reflection stack (#11354 tracks parts of that), like @steveharter pointed out. Function pointer behavior is currently pretty arbitrary within the runtime reflection stack: https://twitter.com/MStrehovsky/status/1311247635756412928 I don't know if it's good use of time to make I would suggest looking into a technology that is more suitable to build compiler components - System.Reflection.Metadata directly, or even Cecil. |
Maybe we can fix our wasm tooling to work around this, but function pointer types are increasing in usage, so other users will run into this problem. |
@marek-safar we've moved most of the issues marked as |
@steveharter Will the #69273 MetadataLoadContext work also happen in 7? Will that include also the .NET Framework version of MLC? If so, that will help us with this issue with the wasm tooling. |
@lambdageek yes MetadataLoadContext will be updated along with the CoreClr runtime. The active PR is #71516. It should be possible to use .NET framework with MetadataLoadContext function pointers although reflection will necessary to call the new APIs on Type. I'll provide an example once that PR is in. |
We may want to provide extension methods so that it is not necessary to use reflection. |
Moving to 8.0; we need to update the API and design based on feedback from #71516. |
To reproduce: run the attached project
Version: master
Expected result: works
Actual result:
The text was updated successfully, but these errors were encountered: