Search:
Namespaces
Discussions
.NET v1.1
Feedback
Comments with CodeDom
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.languages.csharp
.
Post a new message to this list...
Pierre Greborio
Hello,
when I generate C# code from CodeDom, i.e.:
CodeDomProvider
dom = new CSharpCodeProvider();
ICodeGenerator
gen = dom.CreateGenerator(
Console
.Out);
CodeCompileUnit
ccu = new
CodeCompileUnit
();
gen.GenerateCodeFromCompileUnit(ccu,
Console
.Out, null);
I get the following result:
//--------------------------------------------------------------------------
----
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.0.3705.288
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//--------------------------------------------------------------------------
----
How can I make my own comments instead of defaults ?
Thanks,
Pierre
Reply to this message...
Visual C# Team
With this code you can add your own comments to the 'root' namespace, but
you cannot remove the default comments added by the CSharpCodeProvider.
CodeDomProvider
dom = new CSharpCodeProvider();
ICodeGenerator
gen = dom.CreateGenerator(
Console
.Out);
CodeCompileUnit
ccu = new
CodeCompileUnit
();
CodeNamespace
cn = new
CodeNamespace
();
cn.Comments.Add( new
CodeCommentStatement
("My own comments"));
ccu.Namespaces.Add(cn);
gen.GenerateCodeFromCompileUnit(ccu,
Console
.Out, null);
We get this output:
//--------------------------------------------------------------------------
----
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.0.3705.288
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//--------------------------------------------------------------------------
----
// My own comments
--
Grant & Subash
-----------------------
This posting is provided "AS IS" with no warranties, and confers no rights
"Pierre Greborio" <
Click here to reveal e-mail address
> wrote in message
news:OjOKTXR0CHA.1936@TK2MSFTNGP10...
[Original message clipped]
Reply to this message...
Pierre Greborio
Is it possible to override this behavior ? Maybe inheriting from some class.
Thanks
Pierre
--
-----------------------------------------------------------
Pierre Greborio
http://www.ugidotnet.org
-----------------------------------------------------------
"Visual C# Team" <
Click here to reveal e-mail address
> wrote in message
news:OxbdiMV0CHA.1812@TK2MSFTNGP11...
[Original message clipped]
Reply to this message...
Visual C# Team
Not that I'm aware of.
--
Grant
-----------------------
This posting is provided "AS IS" with no warranties, and confers no rights
"Pierre Greborio" <
Click here to reveal e-mail address
> wrote in message
news:u5TQ1ya0CHA.2564@TK2MSFTNGP12...
> Is it possible to override this behavior ? Maybe inheriting from some
class.
[Original message clipped]
Reply to this message...
System.CodeDom.CodeCommentStatement
System.CodeDom.CodeCompileUnit
System.CodeDom.CodeNamespace
System.CodeDom.Compiler.CodeDomProvider
System.CodeDom.Compiler.ICodeGenerator
System.Console
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com