codedom

Using .NET CodeDOM to declare and initialize a field in one statement

I want to use CodeDOM to both declare and initialize my static field in one statement. How can I do this? // for example public static int MyField = 5; I can seem to figure out how to declare a static field, and I can set its value later, but I can't seem to get the above effect. @lomaxx, Naw, I just want static. I don't want const...

Unable to load System.Data.Linq.dll for CodeDom

I am trying to dynamicaly compile code using CodeDom. I can load other assemblies, but I cannot load System.Data.Linq.dll. I get an error: Metadata file 'System.Data.Linq.dll' could not be found My code looks like: CompilerParameters compilerParams = new CompilerParameters(); compilerParams.CompilerOptions = "/target:library /optimiz...

Execute JavaScript from within a C# assembly

I'd like to execute JavaScript code from within a C# assembly and have the results of the JavaScript code returned to the calling C# code. It's easier to define things that I'm not trying to do: I'm not trying to call a JavaScript function on a web page from my code behind. I'm not trying to load a WebBrowser control. I don't want to ...

.NET CodeDom - compile and invoke a generated method

I managed to create a class using CodeDom and add a single method to that class. Now, is there a way to, having constructed the CodeCompileUnit instance, compile the code and invoke the generated method? The method invocation has to be done in the same context as the code generation. ...

CodeDOM & .Net Modules

How do I programmatically embed a .Net module to the assembly generated by CodeDOM? ...

How can I get the current CodeDomProvider in an MSBuild Task

I have a task and I want to generate some code using the CodeDom. How can I get either the current "language" or the CodeDomProvider for the current project calling my task? ...

CodeDom - Call a generic method

Hi, does anyone know a way to call a generic method of a base class with CodeDom? I have no problem calling a standard method, but I can't find a solution to call the generic. The code I use to call the standard base class method GetInstance: CodeAssignStatement assignStatement = new CodeAssignStatement( new CodeVariableReferenc...

What is the codedom that I need to write to generate this code?

I need to do this. public class MyClass{ private static IDictionary<String, Type> databaseAccessClasses = new Dictionary<String, Type>(); private static IDictionary<String, Type> DatabaseAccessClasses { get { return DataAccessFactory.databaseAccessClasses; } set { DataAccessFac...

CodeDom generic type constraint

Is there a way to generate a class constraint with CodeDom. Because when I use something like var method = new CodeMemberMethod(); var genericParam = new CodeTypeParameter("InterfaceType"); genericParam.Constraints.Add("class"); method.TypeParameters.Add(genericParam); the generated code is like private InterfaceType GetImpl<Interfa...

T4 vs CodeDom vs Oslo

In an application scaffolding project on which I'm working, I'm trying to decide whether to use Oslo, T4 or CodeDom for generating code. Our goals are to keep dependencies to a minimum and drive code generation for a domain driven design from user stories. The first step will be to create the tests from the user stories, but we want the ...

C# CodeDom variable declaration not resolving as expected

Using CodeDom in C#, I am trying to generate the following for loop: for (int i = 0; i < ds.Tables[0].Rows.Count; i = (i + 1)) Except that my code is generating this: for (int i; (i < ds.Tables[0].Rows.Count); i = (i + 1)) Note that this does not initialize i to zero, which does not compile in C#. (VB does accept this). So I have ...

Code Generation for All CLR supported language using a CodeDomSerializer

Hi All, I am implementing Code Generation for WindowsForm control at Design-Time, using a Custom CodeDomSerializer. Here is what I have. A user control i.e. MyControl written in C#. MyControl has a property MyControlProperty of type ObjectXXX that is accessible publicly.(like myControl.MyControlProperty). The type ObjectYYY has a...

C# CodeDom Automatic Property

I have a property created with CodeDom. How can I set it to being an automatic property instead of adding CodeFieldReferenceExpressions against a private member? ...

Setting file version for a codeDOM file

I'm looking for ANY means of setting the file version for an exe file generated using codeDOM. Mine always comes out as 0.0.0.0. Programatically would obviously be preferred, but at this point anything would be better than nothing. ...

C# to Delphi Prism code converter

I know CodeGear made BabelCode that uses the Code DOM to convert C# to Delphi for .NET. I am curious if there are any other similar tools to convert C# to Delphi Prism? If not, what is involved in using the Code DOM to create one (yeah, that is open ended!) Update: This is now built into Delphi Prism. Just paste or import your C# and...

programaticaly code generation in c# using codedom

I want to generate code for creating a hash table object and assigning it with a key and a value programmatic . it should be similar to Hashtable ht = new Hashtable(); ht.Add( "key1", "value1" ); ht.Add( "key2", "value2" ); ht.Add( "key3", "value3" ); for eg CodeMemberMethod testMethod = new CodeMemberMethod(); testMethod...

How to add #pragma warning disable 1591 using CodeDom

A portion of our app uses code generated using CodeDom. This code does not need Xml Comments and so we would like to add a #pragma warning disable 1591 to those generated files. Is this possible with CodeDom and if not, then are there other suggestions on how to accomplish this? ...

Using Codedom to write VB.Net Properties

Looking at the example code on MSDN: This ' Declares a type. Dim type1 As New CodeTypeDeclaration("Type1") ' Declares a constructor. Dim constructor1 As New CodeConstructor constructor1.Attributes = MemberAttributes.Public type1.Members.Add(constructor1) ' Declares an integer field. Dim field1 As New ...

CodeDom - can I generate an anonymous method?

I can't find any way to generate an anonymous method. any ideas? ...

Does IronRuby have a CodeDomProvider?

If not is one scheduled? ...