-
Notifications
You must be signed in to change notification settings - Fork 424
Conversation
@joshpeterson Will this pose problems for Unity developers, where most platforms do not support Reflection.Emit? |
That's a great question. Our thinking was that we should consider this as an API that might throw if the runtime environment doesn't support runtime code gen. And for this we should offer a capability APIs so that developers can write code like this: if (IsRefEmitAvailable())
{
EmitAndRun();
}
else
{
Interpret();
} |
@terrajobst Would |
I have some concerns about adding types from Unity supports a number of AOT-only platforms, including iOS, consoles, some VR devices. For these platforms,
We are providing the following guidance to Unity users about which profile to choose: Library authors: Use .NET Standard 2.0, since all of it is supported on all Unity platforms. Your library code can run everywhere. Game developers: You have two options, get errors about unsupported API usage at compile time or at run time.
This pull request would require Unity to throw a So minimally, I would like to see something like [1] For this discussion, let's ignore Unity's WebGL platform (effectively IL -> C++ -> asm.js/Wasm), since it is pretty restricted and does not support threads or sockets. [2] If I'm being entirely honest, users don't really have this nice distinction now, because even .NET Standard 2.0 on WebGL has unsupported APIs. Since this is a single platform with well-known restrictions which might be lifted in the future, I think it is acceptable to ignore it as an outlier that does not impact the general principle. |
Few things:
|
It reduces netstandard value for environments without JIT, as @joshpeterson explained. This is the first example of where adding API helps some, but hurts others. I do not have a strong opinion either way. I agree that there has to be the capability API if this were to be added. |
I personally think it helps more than it hurts. AOT has always had these warts and all that is needed to make this viable is a capability API that allows libraries to pick a different code generation strategy. Many systems have varying code generation techniques and .NET’s 15+ year legacy has reflection emit at the heart of a certain class of library (serialization etc). Do an API scan of on nuget.org and see how many libraries use it transitively or non transitively. |
I agree, with a capability API, I think this will be fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine in general - just one question that probably affects lots of PRs.
public override System.RuntimeMethodHandle MethodHandle { get { throw null; } } | ||
public override string Name { get { throw null; } } | ||
public override System.Type ReflectedType { get { throw null; } } | ||
public override System.Reflection.ParameterInfo ReturnParameter { get { throw null; } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReturnParameter is virtual in MethodInfo - why do we need to specify here that it's overridden?
(This is just an example I happened upon due to being puzzled by the name. I suspect there are others.)
It feels reasonable to specify an override for abstract members (e.g. the Attributes property) but if it's just a virtual member and we're not specifying any additional attributes, does the fact that it's overridden need to be part of the standard? That feels like an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Unless this is to signify that any conformant implementation must override it because the specified behavior of the base implementation is different to the specified behavior of the derived implementation? Do we have a document listing rules for this sort of thing?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving assuming #832 will be addressed as well.
Given we have a commitment to do https://github.com/dotnet/corefx/issues/29258 and subsequently #832, we can remove the |
This adds reflection emit APIs. We should consider also adding a capability API. This fixes #712.
@dotnet/nsboard