Code in <code> blocks not keeping indentation spacing

Topics: User Forum
May 10, 2013 at 6:40 PM
I have tried several different variations in my code block to try to get the output help documentation to have formatted C# code, but they all end up with the entire code block left aligned. Is there a way to get the spacing to persist to the generated help file?

e.g.
/// <code lang="C#">
/// using MyClass.ServiceContracts;
/// class Program
/// {
///     static void Main(string[] args)
///     {
///         MyClient _myClient = new MyClient();
///         MyRequest _myRequest = new MyRequest();
///         _myClient.performRequest(_myRequest);
///     }
/// }
/// </code>
comes out as:

using MyClass.ServiceContracts;
class Program
{
static void Main(string[] args)
{
MyClient _myClient = new MyClient();
MyRequest _myRequest = new MyRequest();
_myClient.performRequest(_myRequest);
}
}
Coordinator
May 10, 2013 at 7:24 PM
As long as it's nested within an example element, it should render just fine. If you've got the Indent HTML project option enabled, turn it off as it will cause problems with the format, though it usually only affects the first line. That option is for debugging the output and should be typically left disabled.

Eric
May 10, 2013 at 8:02 PM
Thank you so much for your quick response!

I have discovered that this is an issue because I am using WCFExtras+ to pull the comments into a generated service contract, and that tool is eliminating all my formatting. I apologize for wasting your time with my question.

Thanks again!