[Mono-devel-list] ICodeParser && Mono
jonpryor at vt.edu
Wed Feb 4 20:59:55 EST 2004
On Wed, 2004-02-04 at 13:21, Christian Birkl wrote:
> Hi all,
> Is there something equivalent to Microsoft.CSharp namespace in Mono? I
> can't find any in the current class/ directory in recent cvs. I'm
> specifically interested in Microsoft.CSharp.CSharpProvider. I'd like to
> do some code analysing stuff via ICodeProvider, which can create a
> CodeCompileUnit via .CreateParser().Parse(). This would be a much nicer
> way than doing the parsing on my own. But unfortuntly .CreateParser() is
> defined to *always* return null. It would be nice if Mono would break
> this MS behaviour (or somehow provide a second .CreateParser() method.).
Are you sure it's not CSharpCodeProvider? There's one in
There's also a Microsoft.CSharp namespace in class/Cscompgd.
I don't know if Mono would be willing to break compatibility, but I
> My second question is wether mcs (mono c# compiler) internally actually
> uses System.CodeDom for its code creation or not. And if yes, how can i
> access the CodeDom created by the parser?
I believe this is a misunderstanding of what CodeDom is for. CodeDom
isn't for *parsing* code. It's for *generating* code. Not CIL code.
CodeDom would be used by e.g. VisualStudio for generating templates: you
would describe, via CodeDom, that you want a class (MyClass), with a
method (Main), and some comments ("Do something here"). This CodeDom
description could then be used to generate the template code in VB.NET,
generate *human readable* source code.
This was discussed -- in excruciating depth because of perceived GPL
"backdoor" -- in May 2002, when miguel noted:
The System.CodeDOM API is a mechanism to "build" source code
through an API. It is just an abstraction so that ASP.NET can
"create" pages built on a number of languages.
Once you have constructed your "CodeDOM", it is written into a
file, and an external compiler is invoked. So there are no
To generate IL, System.Reflection.Emit is used. This is what mcs does.
You can also use PEAPI (in mcs CVS), or just directly emit the opcodes
(if you're writing in a non-managed environment).
I think PEAPI can also be used to parse existing IL code, but I'm not
More information about the Mono-devel-list