By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

CodeDom and @

P: n/a
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>


Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.