I am considering porting a third-party library to .NET for Windows Store apps. The library makes excessive use of System.Reflection.Emit.OpCodes via calls to the ILGenerator.Emit method overloads.
In the .NET for Windows Store Apps API, the OpCode
structure and OpCodes
class are included, but there is no ILGenerator
class, and as far as I have been able to find out no replacement either.
I am obviously missing something, but: without the ILGenerator
class, what is the purpose of including System.Reflection.Emit.OpCode
and OpCodes
in the .NET for Windows Store apps API?
Good question. While I cannot say for sure, there are only two reasons I can think of that use OpCode / Opcodes (and I cannot really imagine it's used for something else):
Since it's not the former, I guess they're using the latter. The application for this is static code analysis; I myself use it f.ex. to implement some Mocking behavior and figuring out what the lambda expression was that was passed to it (in this case Expressions couldn't be used). Another applications of code analysis that might be more likely in this scenario is checking if certain classes/methods/constructs are used which are disallowed (I can imagine that they don't want you to use certain functionality).
You may find Mono Cecil useful to replace some of the functions of System.Reflection, officially there is no port of it for WinRT, but unofficially, there is a port available here, just note that is based in the Silverlight version of Mono Cecil.
Also be aware that you can't modify dlls and exes outside your app package, this is a security measure of the WinRT sandbox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With