How to use XML comments with #if !SYMBOL

708 views Asked by At

I'm trying to use C# XML comments in conjunction with conditional directive.

With #if SYMBOL it works:

    /// <summary>Some summary.</summary>
    #if SYMBOL
    /// <remarks>Conditional remark</remarks>
    #endif
    public bool IsSupported { get; set; }

With negative preprocessor directive #if !SYMBOL it does not work:

    /// <summary>Some summary.</summary>
    #if !SYMBOL
    /// <remarks>Conditional remark</remarks>
    #endif
    public bool IsSupported { get; set; }

It produces following warning: XML comment is not placed on a valid language element. Moreover it includes the remarks element, but removes the summary element from the resulting XML documentation.

Update

With #if and #else blocks results are similar to #if !SYMBOL. Same warning produced by a summary element and no summary in the output.

    /// <summary>Some summary.</summary>
    #if SYMBOL
    /// <remarks>SYMBOL defined</remarks>
    #else
    /// <remarks>SYMBOL not defined</remarks>
    #endif
    public bool IsSupported { get; set; }

Any workaround for this? I'm using VS 2010 and C# 4.0.

0

There are 0 answers