Lyi*_*Sky 5 c# reflection il decompiling
减少downvotes :(起初可跳过)
我知道这个问题听起来毫无意义和/或奇怪.我正在创建JIT,它使用C#代码用csc.exe编译它,提取IL并将其平行化为CUDA,我想覆盖C#中的一些东西.
如何覆盖基础的东西,如int\ string?我试过了:
class String { /* In namespace System of course */
BasicString wrap_to;
public String( ) {
wrap_to = new BasicString( 32 ); // capacity
}
public String( int Count ) {
wrap_to = new BasicString( Count );
}
public char this[ int index ] {
get { return wrap_to[ index ]; }
set {
if ( wrap_to.Handlers != 1 )
wrap_to = new BasicString( wrap_to );
wrap_to[ index ] = value;
}
}
...
}
... // not in namespace System now
class Test {
public static void f(string s) { }
}
Run Code Online (Sandbox Code Playgroud)
但当我尝试时:
Test.f( new string( ) );
Run Code Online (Sandbox Code Playgroud)
它错了Cannot implicitly convert type 'System.String' to 'string'.我尝试将我System.String移到string全局范围内,并且它在类本身上出错了.有什么想法?我想如果.cs没有它我可以编译我的文件,它会有所帮助mscorlib.dll,但我找不到办法.
即使是访问csc.exe源代码的方法也许有帮助.(这很关键.)
是的,您必须不引用mscorlib.dll. 否则将会有两个System.String类,并且显然预定义的(给定的 C# 规范)类型string不能同时是它们两个。
请参阅/nostdlibC# 编译器选项。该页面还描述了如何使用 Visual Studio IDE 中的设置来执行此操作。
当您不引用时,您需要编写许多其他必需的类型(或复制粘贴它们)mscorlib.dll!
| 归档时间: |
|
| 查看次数: |
1061 次 |
| 最近记录: |