如何引用与C#美元符号标识? [英] How to reference identifiers with dollar signs from C#?

查看:2364
本文介绍了如何引用与C#美元符号标识?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用从Scala代码编译的jar文件ikvmc生成的DLL(是我的一天是伟大的)。 Scala编译器似乎生成包含运算符重载美元符号标识和iKVM采用那些在生成的DLL(我可以看到它在反射镜)。问题是,美元符号在C#代码违法的,所以我不能引用这些方法。

I'm trying to use a DLL generated by ikvmc from a jar file compiled from Scala code (yeah my day is THAT great). The Scala compiler seems to generate identifiers containing dollar signs for operator overloads, and IKVM uses those in the generated DLL (I can see it in Reflector). The problem is, dollar signs are illegal in C# code, and so I can't reference those methods.

什么办法来解决这个问题呢?

Any way to work around this problem?

推荐答案

您应该能够访问使用反射时髦的方法。没有一个很好的解决方案,但至少它应该工作。取决于在DLL API的结构也可能是可行的周围创建方法的包装本地化反射代码。然后从你的代码的其余部分就叫漂亮的包装。

You should be able to access the funky methods using reflection. Not a nice solution, but at least it should work. Depending on the structure of the API in the DLL it may be feasible to create a wrapper around the methods to localise the reflection code. Then from the rest of your code just call the nice wrapper.

另一种选择将是对IL黑客在目标DLL和改变的标识符。或者做一些后期建立在你自己的代码IL-黑客。

The alternative would be to hack on the IL in the target DLL and change the identifiers. Or do some post-build IL-hacking on your own code.

这篇关于如何引用与C#美元符号标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆