codedom

Creating CodeMemberMethod from string

I am trying to generate some code using CodeDom. I wanted to know if there is any way to create CodeMemberMethod from a string. I found a method, but it generates assembly from string. I wanted to generate some methods from string. Is there any way? ...

How to parse simple statement into CodeDom object

I need to parse a simple statement (essentially a chain of function calls on some object) represented as a string variable into a CodeDom object (probably a subclass of CodeStatement). I would also like to provide some default imports of namespaces to be able to use less verbose statements. I have looked around SO and the Internet to fi...

CodeDOM: Adding DebuggerStepThroughAttribute to property

I know how to add a DebuggerStepThroughAttribute to a method or a constructor, usually you add it to the CustomAttributes collection of a code member. But I don't see a way to do this for the setter and getter of a C# property, because neither of them provides this collection where you add the attributes. Does anyone have a clue? ...

CSharpCodeProvider: Why is a result of compilation out of context when debugging

I have following code snippet that i use to compile class at the run time. //now compile the runner var codeProvider = new CSharpCodeProvider( new Dictionary<string, string>() { { "CompilerVersion", "v3.5" } }); string[] references = new string[] { "System.dll", "System.Core.dll", "System.Core.dll" }; CompilerParameters para...

Is it possible to call C# lexical/syntactic analyzers without compilation?

Considering this question of SO, where whole C# in-memory compiler is being called. When only lexical and syntactic analyzing is required: parse text as a stream of lexemes, check them and exit. Is it possible in current version of System.CodeDom.Compiler, if not - will it be? ...

Java Code Generation (Metaprogramming, Reflection, wtv)

Does anyone knows a tool for Java (something like codedom for C#) that provides a way to generate Java code to a .java file? EDIT: I'm building a plataform that its main objective his to automate an operation. Giving some input, i want to generate code for an external tool. So it isn't generation on runtime. I want to generate and outpu...

creating enumeration using .NET's CodeDom

Hi, I want to create an Enumeration using CodeDom API. I have searched enough on the internet and I get results which are hardly of any use. What I want to generate is public enum bug_tracker_type { [Description("Bugzilla")] Bugzilla, [Description("Debbugs")] Debbugs, [Description("PHP Project Bugtracker")] PHP...

CSharp Compiler and Windows.Forms

Hi All I've just created a little app that programmatically compiles code using the C# Compiler, and it works brilliantly. But, one thing that I need it to do is compile Windows.Forms code. Like, I can create a console app with it, but I can't create a GUI-based form. Here's the link that got me started: http://support.microsoft.com/kb...

C# and Metadata File Errors

Hi All I've created my own little c# compiler using the tutorial on MSDN, and it's not working properly. I get a few errors, then I fix them, then I get new, different errors, then I fix them, etc etc. The latest error is really confusing me. --------------------------- --------------------------- Line number: 0, Error number: CS0006...

Hiding Command Prompt with CodeDomProvider

Hi All I've just got my own little custom c# compiler made, using the article from MSDN. But, when I create a new Windows Forms application using my sample compiler, the MSDOS window also appears, and if I close the DOS window, my WinForms app closes too. How can I tell the Compiler? not to show the MSDOS window at all? Thank you :) ...

Hiding Command Prompt with CodeDomProvider

Hi All I've just got my own little custom c# compiler made, using the article from MSDN. But, when I create a new Windows Forms application using my sample compiler, the MSDOS window also appears, and if I close the DOS window, my WinForms app closes too. How can I tell the Compiler? not to show the MSDOS window at all? Thank you :) ...

CodeDom : compile partial class

I'm attempting to compile code in a text file to change a value in a TextBox on the main form of a WinForms application. Ie. add another partial class with method to the calling form. The form has one button (button1) and one TextBox (textBox1). The code in the text file is: this.textBox1.Text = "Hello World!!"; And the code: nam...

Is there a way to have CodeDom put using statements before the namespace.

The msdn documentation says add namespaces imports to the CodeNamespace.Imports collection. This puts them inside the namespace (which makes sense, since your adding them to the namespace) namespace Foo { using Bar; //Code } However the rest of our code base has using statements outside the namespace: using Bar; namespace Foo {...

Where is System.CodeDom.Compiler.CompilerParameters in Silverlight ?

Dear All, I want to create Mathematics Expression Evaluator in Silverlight. To do that easily, I need compilation on the fly using System.Reflection, System.Reflection.Emit, System.CodeDom.Compiler, and other related assemblies. However, I cannot find this class available in Silverlight. Give me some suggestion please. Thank you in a...

C# CodeDom - making project's forms accessible for scripts.

Hi, I'm learning CodeDom scripting, I started with http://www.c-sharpcorner.com/uploadfile/mgold/codedomcalculator08082005003253am/codedomcalculator.aspx Now I'd like to allow script modify the project's form (for learning purposes only). I suppose I need to create new field for a class I'm generating which refers "this". However I have...

How to use CodeDomSerializer to serialize an object in .Net?

I have a class, which is defined as the following: [ToolboxItem(false)] [DesignTimeVisible(false)] [DesignerSerializer("DevExpress.XtraEditors.Design.RepositoryItemCodeDomSerializer, DevExpress.XtraEditors.v10.1.Design", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")] [Designer("DevExpress.XtraEditors.Des...

FSharp.Compiler.CodeDom for VS2008 and VS2010 side-by-side

I'm using FSharp.Compiler.CodeDom (from the PowerPack) to dynamically create F# classes. The problem is, that I have both VS2008 and VS2010 on my computer side-by-side (they works fine), and using F# in this configuration is buggy at best: If I don't install InstallFSharp.msi, then under VS2008 the built classes complain about not find...

From Source to AST to CodeDom

I am reading the book Language Implementation Patterns (http://tiny.cc/235xs) amongst a few others mixed in to clarify concepts as well as the occasional website. I am trying to make a tool that reads a trivial programming language and performs some basic analysis on it. I am getting stuck in the design phase of this tool. I have constr...

Is any simple way to create method and set its body dynamically in C#?

I hold body of method in string. I want to create method dynamically. But I don't know, how to set its body. I saw very tedious way using CodeDom. And I saw using Emit with OpCodes. Is any way to use ready code from string variable? string method_body = "return \"Hello, world!\";"; //there is method body DynamicMethod dm = new System.Re...

Convert user input into ToString() method inside FlowDocument in Workflow 4.0

I have a Workflow 4.0 app that generates emails. In a dialog for creating the email body the user needs to be able to input some string value representing an existing wf instance variable to be inserted as a string at runtime. So they input something like: Email body text including <>. (say ExistingVariable is an int or something like...