@@ -92,6 +92,8 @@ internal class TripleSlashSyntaxRewriter : CSharpSyntaxRewriter
9292 {
9393 #region Private members
9494
95+ private static readonly string UnixNewLine = "\n " ;
96+
9597 private static readonly string [ ] ReservedKeywords = new [ ] { "abstract" , "async" , "await" , "false" , "null" , "sealed" , "static" , "true" , "virtual" } ;
9698
9799 private static readonly string [ ] MarkdownUnconvertableStrings = new [ ] { "](~/includes" , "[!INCLUDE" } ;
@@ -437,7 +439,7 @@ private static SyntaxNode GetNodeWithTrivia(SyntaxTriviaList leadingWhitespace,
437439 if ( leadingTrivia [ 0 ] . IsKind ( SyntaxKind . EndOfLineTrivia ) )
438440 {
439441 // Ensure the endline that separates nodes is respected
440- finalTrivia = new SyntaxTriviaList ( SyntaxFactory . ElasticCarriageReturnLineFeed )
442+ finalTrivia = new SyntaxTriviaList ( SyntaxFactory . ElasticLineFeed )
441443 . AddRange ( finalTrivia ) ;
442444 }
443445 }
@@ -476,7 +478,7 @@ private static SyntaxTriviaList GetLeadingDoubleSlashComments(SyntaxNode node, S
476478 doubleSlashComments = doubleSlashComments
477479 . AddRange ( leadingWhitespace )
478480 . Add ( trivia )
479- . Add ( SyntaxFactory . CarriageReturnLineFeed ) ;
481+ . Add ( SyntaxFactory . LineFeed ) ;
480482 }
481483 }
482484
@@ -697,12 +699,12 @@ private static XmlTextSyntax GetTextAsCommentedTokens(string text, SyntaxTriviaL
697699
698700 // collapse newlines to a single one
699701 string whitespace = Regex . Replace ( leadingWhitespace . ToFullString ( ) , @"(\r?\n)+" , "" ) ;
700- SyntaxToken whitespaceToken = SyntaxFactory . XmlTextNewLine ( Environment . NewLine + whitespace ) ;
702+ SyntaxToken whitespaceToken = SyntaxFactory . XmlTextNewLine ( UnixNewLine + whitespace ) ;
701703
702704 SyntaxTrivia leadingTrivia = SyntaxFactory . SyntaxTrivia ( SyntaxKind . DocumentationCommentExteriorTrivia , string . Empty ) ;
703705 SyntaxTriviaList leading = SyntaxTriviaList . Create ( leadingTrivia ) ;
704706
705- string [ ] lines = text . Split ( Environment . NewLine , StringSplitOptions . RemoveEmptyEntries | StringSplitOptions . TrimEntries ) ;
707+ string [ ] lines = text . Split ( new char [ ] { ' \r ' , ' \n ' } , StringSplitOptions . RemoveEmptyEntries | StringSplitOptions . TrimEntries ) ;
706708
707709 var tokens = new List < SyntaxToken > ( ) ;
708710
@@ -740,7 +742,7 @@ private static SyntaxTriviaList GetXmlTrivia(XmlNodeSyntax node, SyntaxTriviaLis
740742
741743 return leadingWhitespace
742744 . Add ( docCommentTrivia )
743- . Add ( SyntaxFactory . CarriageReturnLineFeed ) ;
745+ . Add ( SyntaxFactory . LineFeed ) ;
744746 }
745747
746748 // Generates a custom SyntaxTrivia object containing a triple slashed xml element with optional attributes.
@@ -765,9 +767,9 @@ private static SyntaxTriviaList GetXmlTrivia(string name, SyntaxList<XmlAttribut
765767
766768 private static string WrapInRemarks ( string acum )
767769 {
768- string wrapped = Environment . NewLine + "<format type=\" text/markdown\" ><![CDATA[" + Environment . NewLine ;
770+ string wrapped = UnixNewLine + "<format type=\" text/markdown\" ><![CDATA[" + UnixNewLine ;
769771 wrapped += acum ;
770- wrapped += Environment . NewLine + "]]></format>" + Environment . NewLine ;
772+ wrapped += UnixNewLine + "]]></format>" + UnixNewLine ;
771773 return wrapped ;
772774 }
773775
@@ -776,7 +778,7 @@ private static string WrapCodeIncludes(string[] splitted, ref int n)
776778 string acum = string . Empty ;
777779 while ( n < splitted . Length && splitted [ n ] . ContainsStrings ( MarkdownCodeIncludes ) )
778780 {
779- acum += Environment . NewLine + splitted [ n ] ;
781+ acum += UnixNewLine + splitted [ n ] ;
780782 if ( ( n + 1 ) < splitted . Length && splitted [ n + 1 ] . ContainsStrings ( MarkdownCodeIncludes ) )
781783 {
782784 n ++ ;
@@ -802,7 +804,7 @@ private static SyntaxTriviaList GetFormattedRemarks(IDocsAPI api, SyntaxTriviaLi
802804 }
803805 else
804806 {
805- string [ ] splitted = remarks . Split ( Environment . NewLine , StringSplitOptions . RemoveEmptyEntries ) ;
807+ string [ ] splitted = remarks . Split ( new char [ ] { ' \r ' , ' \n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
806808 string updatedRemarks = string . Empty ;
807809 for ( int n = 0 ; n < splitted . Length ; n ++ )
808810 {
@@ -814,7 +816,7 @@ private static SyntaxTriviaList GetFormattedRemarks(IDocsAPI api, SyntaxTriviaLi
814816 n ++ ;
815817 while ( n < splitted . Length && splitted [ n ] . StartsWith ( ">" ) )
816818 {
817- acum += Environment . NewLine + splitted [ n ] ;
819+ acum += UnixNewLine + splitted [ n ] ;
818820 if ( ( n + 1 ) < splitted . Length && splitted [ n + 1 ] . StartsWith ( ">" ) )
819821 {
820822 n ++ ;
@@ -843,14 +845,14 @@ private static SyntaxTriviaList GetFormattedRemarks(IDocsAPI api, SyntaxTriviaLi
843845 }
844846 else
845847 {
846- example += Environment . NewLine + line ;
848+ example += UnixNewLine + line ;
847849 }
848850 n ++ ;
849851 }
850852 }
851853 else
852854 {
853- updatedRemarks += ReplaceMarkdownWithXmlElements ( Environment . NewLine + line , api . Params , api . TypeParams ) ;
855+ updatedRemarks += ReplaceMarkdownWithXmlElements ( UnixNewLine + line , api . Params , api . TypeParams ) ;
854856 }
855857 }
856858
0 commit comments