Swashbuckle.Core/Swagger/XmlComments/XmlTextHelper.cs
/// <summary>
/// Messages text from an XML node produced by Visual Studio into a plainer plain text (leading whitespace normalized)
/// </summary>
/// <param name="xmlText">The content of an XML node - could contain other XML elements within the string</param>
/// <returns></returns>
Messages text from an XML node produced by Visual Studio into a plainer plain text (leading whitespace normalized)
Messages text from an XML node produced by Visual Studio into a plainer plain text ( leading whitespace normalized )
public static string NormalizeIndentation(string xmlText)
        {
            if (null == xmlText)
                throw new ArgumentNullException("xmlText");
            string[] lines = xmlText.Split('\n');
            string padding = GetCommonLeadingWhitespace(lines);
            int padLen = padding == null ? 0 : padding.Length;
            for (int i = 0, l = lines.Length; i < l; ++i)
            {
                string line = lines[i].TrimEnd('\r'); 
                if (padLen != 0 && line.Length >= padLen && line.Substring(0, padLen) == padding)
                    line = line.Substring(padLen);
                lines[i] = line;
            }
            return string.Join("\r\n", lines.SkipWhile(x => string.IsNullOrWhiteSpace(x))).TrimEnd();
        }
public static string NormalizeIndentation ( string xmlText ) { if ( null == xmlText ) throw new ArgumentNullException ( " " ) ; string [ ] lines = xmlText . Split ( ' \n ' ) ; string padding = GetCommonLeadingWhitespace ( lines ) ; int padLen = padding == null ? 0 : padding . Length ; for ( int i = 0 , l = lines . Length ; i < l ; ++ i ) { string line = lines [ i ] . TrimEnd ( ' \r ' ) ; if ( padLen != 0 && line . Length >= padLen && line . Substring ( 0 , padLen ) == padding ) line = line . Substring ( padLen ) ; lines [ i ] = line ; } return string . Join ( " \r \n " , lines . SkipWhile ( x => string . IsNullOrWhiteSpace ( x ) ) ) . TrimEnd ( ) ; }
Messages text from an XML node produced by Visual Studio into a plainer plain text (leading whitespace normalized)
Messages text from an XML node produced by Visual Studio into a plainer plain text ( leading whitespace normalized )
// remove leading padding from each line // remove trailing '\r' // remove leading empty lines, but not all leading padding // remove all trailing whitespace, regardless
None
xmlText
string
The content of an XML node - could contain other XML elements within the string
The content of an XML node - could contain other XML elements within the string