Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Expose a capability API for Reflection Emit #832

Closed
terrajobst opened this issue Jul 16, 2018 · 3 comments · Fixed by #952
Closed

Expose a capability API for Reflection Emit #832

terrajobst opened this issue Jul 16, 2018 · 3 comments · Fixed by #952
Assignees
Labels
netstandard-api This tracks requests for standardizing APIs.

Comments

@terrajobst
Copy link
Member

terrajobst commented Jul 16, 2018

Assuming #829 goes in, we should consider adding a a capability API. This allows implementations that cannot support runtime code generation to expose up-front that they will fail at runtime with PlatformNotSupportedException. This allows consumers to write code like this:

if (IsRefEmitAvailable())
{
    EmitAndRun();    
}
else
{
    Interpret();
}

Strictly speaking, this is violating our inclusion principles but it seems the opportunity loss seems high for what amounts to be a simple API.

@terrajobst terrajobst added the netstandard-api This tracks requests for standardizing APIs. label Jul 16, 2018
@terrajobst terrajobst added this to the .NET Standard vNext milestone Jul 16, 2018
@morganbr
Copy link

It would be great to be able to ask two questions:

  1. Does reflection emit work at all on this platform? (Will it just throw PlatformNotSupportedException if I try?)
  2. Is reflection emit more performant than regular reflection? (Will it really compile code or will it use a slow interpreter that I'm better off not using?)

@JamesNK
Copy link
Member

JamesNK commented Oct 11, 2018

I think this is needed. Without a flag to test I think library authors would end up in the situation of wrapping IL gen in a try/catch and falling back on exception. Gross.

@terrajobst
Copy link
Member Author

We now have a design for this API. Modulo other feedback form our API review experts, I expect the API to be approved early next week.

https://github.com/dotnet/corefx/issues/29258

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
netstandard-api This tracks requests for standardizing APIs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants