CodeDom and @


R

Ron Bullman

Hi,

I havent been able to find any documentation about @ in the CodeDom context.
The problem is when generating C# code from CodeDom it will associate a
@-tag with all C# specific types. Why? And how to configure the CodeDom to
generate code without @-tags?


Ron
A short example follows whic produces following kind of output:
<code>

namespace tst.CodeDom {



public class TstType {


private TstType(String validString, @string oddString) {

}

}

}

</code>

And the generating program

<code>

namespace tst.CodeDom {

using System;

using System.CodeDom;

using System.CodeDom.Compiler;

using Microsoft.CSharp;

using System.IO;

using System.Text;

public class Generator {

[STAThread]

public static void Main(string[] args) {

create();

generate();

}

private static CodeNamespace module;

private static void generate() {

CSharpCodeProvider provider= new CSharpCodeProvider();

ICodeGenerator generator= provider.CreateGenerator();

CodeGeneratorOptions options= new CodeGeneratorOptions();

options.BlankLinesBetweenMembers= true;

options.IndentString= "\t";

//

StreamWriter writer= new StreamWriter("odd.cs", false);

generator.GenerateCodeFromNamespace(module, writer, options);

writer.Close();

}

private static void create() {

module= new CodeNamespace("tst.CodeDom");

//

CodeTypeDeclaration type=

new CodeTypeDeclaration("TstType");

module.Types.Add(type);

//

CodeConstructor constructor= new CodeConstructor();

type.Members.Add(constructor);

//

CodeParameterDeclarationExpression expression=

new CodeParameterDeclarationExpression("String", "validString");

constructor.Parameters.Add(expression);

expression=

new CodeParameterDeclarationExpression("string", "oddString");

constructor.Parameters.Add(expression);

}

}

}

</code>
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

slow CodeDom 0
EnvDTE of CodeDom 1
CodeDom Question 3
CodeDom and enums 0
CodeDOM question 0
CodeDOM question 0
Doing "&&" in codeDOM 2
Missing CodeDom Expressions? 1

Top