25 votes
SA1644 triggered in example code blocks

Description

 
SA1644 should not be triggered inside a <code/> comment block. In the attached example file there are 2 methods in the <code/> block separated by a single line, which triggers SA1644.

File Attachments


Comments

most recent at top (show oldest at top)
hanscf wrote May 18 at 1:48 PM
Same thing for <pre> blocks, for those of us embedding some HTML here...

/// <remarks>
/// <para>The algorithm works as follows:</para>
/// <pre>
/// PseudoCode(x):
/// ...
///
/// MorePseudoCode(y):
/// ...
/// </pre>
/// </remarks>

MikeRosenblum wrote May 7 at 11:52 PM
I, too, find that it makes sense for SA1644 to not apply to XML comments between 'code' tags. Here is a portion from a recent example from my code:

/// <code>
/// System.Globalization.CultureInfo enUsCulture = new CultureInfo("en-US");
/// System.Globalization.CultureInfo frFrCulture = new CultureInfo("fr-FR");
///
/// // Save original Culture (to be restored at the end).
/// System.Globalization.CultureInfo originalCulture =
/// System.Threading.Thread.CurrentThread.CurrentCulture;
///
/// // Set current culture to "fr-FR" for this test.
/// Thread.CurrentThread.CurrentCulture = frFrCulture;
///
/// // The following reports "fr-FR".
/// MessageBox.Show(System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
///
/// // Etc...
/// </code>

Restricting this to not have spaces makes for an ugly grouping that is very hard to read. :-(

I respectfully urge that this rule be modified to not flag spaces between code tags.

Thanks for your consideration,
Mike Rosenblum

btjdotnet wrote Mar 26 at 5:56 PM
Has anyone found a work-around to this? I tried adding <para> tags as the warning suggested, but then they showed up in my documentation. If there is no work-around other than disabling the whole rule, then the impact seems a bit more than "low" to me.

jasonall wrote Feb 19 at 4:51 PM
Another example:

/// <summary>
/// Gets or sets a value indicating whether counters are available.
/// </summary>
/// <value>
/// <c>true</c> if counters are available; otherwise, <c>false</c>.
/// </value>
private static Boolean CountersAreAvailable
{
get;
set;
}

jasonall wrote Oct 7 2008 at 5:16 PM
/// <summary>
/// Removed this for clarity.
/// </summary>
/// <example>
/// Removed this for clarity.
/// <code>
/// <![CDATA[
/// public class ClassA : ClassBase
/// {
/// public ClassA(int identifier)
/// : base(identifier)
/// {
/// }
/// }
///
/// public class ClassB : ClassBase
/// {
/// public ClassB(int identifier)
/// : base(identifier)
/// {
/// }
/// }
/// ]]>
/// </code>
/// </example>

In here I think the empty line is fine.


Updating...
Page view tracker