Controlling CodeModel's code output formatting: putting lines between namespace declarations

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-05-16T22:33:35Z Indexed on 2010/05/16 22:40 UTC
Read the original article Hit count: 209

I'm making some experiments with Visual Studio's CodeModel. I tried creating a file with two namespaces in there through VS's Code Model:

CodeModel codeModel = projItem.ContainingProject.CodeModel;
codeModel.AddNamespace("Namespaces.FirstNamespace", "namespacestest.cs");
codeModel.AddNamespace("Namespaces.SecondNamespace", "namespacestest.cs");

the output of such code is:

//file namespacestest.cs
namespace Namespaces.FirstNamespace {
}
namespace Namespaces.SecondNamespace {
}

Which is almost what I'm looking for. The only catch here is that I'd like to control the spacing: having at least one line between the first and the second namespace. Does by chance anyone know of a way of achieving this?

This is what I want:

//file namespacestest.cs
namespace Namespaces.FirstNamespace {
}

namespace Namespaces.SecondNamespace {
}

Thanks

© Stack Overflow or respective owner

Related posts about code-model

Related posts about visual-studio-2010