How to override base classes\structs such as int, string?

To reduce downvotes: (Skippable at first)

I am aware that this question sounds pointless and\or weird. I am creating JIT that takes C# code compiles it with csc.exe, extracts the IL and parallize it into CUDA, and I want to override some of the things in C#.

How override base things such as int\ string? I tried:

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) { }
}

But when I tried:

Test.f( new string( ) );

It error'd Cannot implicitly convert type 'System.String' to 'string'. I tried moving my System.String to just string in the global scope and it error'd on the class itself. Any ideas how? I think somehow it could help if I can compile my .cs files without that mscorlib.dll, but I can't find a way to do it.

Even a way to reach to csc.exe source code may help. (This is critical.)

Jon Skeet
people
quotationmark

Even a way to reach to csc.exe source code may help. (This is critical.)

Judging by your comments, this is actually the bit you really need. (Trying to change int and string themselves would involve changing mscorlib and almost certainly the CLR as well. Ouch.)

Fortunately, you're in luck: Microsoft has open-sourced Roslyn, the next generation C# compiler that will ship with Visual Studio 2015.

If you want to change how the compiler behaves, you can fork the code and modify it appropriately. If you really just need to get at the abstract syntax tree (and the like) then you can do that without changing the compiler at all - Roslyn is design to be a "compiler API" rather than just a black-box which takes in source code and spits out IL. (As a mark of how rich the API is, Visual Studio 2015 uses the public API for everything - Intellisense, refactoring, etc.)

people

See more on this question at Stackoverflow