Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a custom .NET base class library (BCL) aka mscorlib replacement?

Does anybody know how to make a custom BCL work with the stock CLR? How to discover existing the most essential ties between CLR and BCL and reuse them?

Here is what I have so far: http://lightnet.codeplex.com

like image 759
Konstantin Tarkus Avatar asked Feb 04 '23 02:02

Konstantin Tarkus


1 Answers

  • Check out Script#, a toolchain for compiling C# to Javascript that was written by someone working at Microsoft and is used internally for some of their webapps. The guy does it by making you compile with /nostdlib and reference his minimally reimplemented BCL. After an assembly is produced, a tool reflects through it and turns it into Javascript. He uses the reimplemented BCL to enable accurate debugging and to prevent you from using features of the BCL that don't make sense in a Javascript context. It looks strikingly like your code does now, including the fact that most of the classes are either empty themselves or only have a few empty methods. This is because the implementation of the BCL's classes/methods are in Javascript, instead.

  • This could be a patent minefield. I learned this with the recent Oracle lawsuit: you're only covered under the community promise if you implement the BCL to spec (though, unlike Java, you do not have to implement the CLR alongside of it. Yes, Microsoft's patent exemption is more liberal than Java's). I think this is a fantastic idea that could be useful in many situations; I can imagine myself using this instead of a DSL, or instead of embedding a scripting language, or instead of pedantically worrying about code security in my plugin architecture. But think about it from Microsoft's perspective- if they allowed patent exemptions for non-compliant BCLs, what's to stop somebody from calling their proprietary product a "non-compliant BCL implementation" and reaping the exemptions?

like image 109
Alex Forster Avatar answered Feb 05 '23 17:02

Alex Forster