@@ -92,6 +92,8 @@ internal class TripleSlashSyntaxRewriter : CSharpSyntaxRewriter
92
92
{
93
93
#region Private members
94
94
95
+ private static readonly string UnixNewLine = "\n " ;
96
+
95
97
private static readonly string [ ] ReservedKeywords = new [ ] { "abstract" , "async" , "await" , "false" , "null" , "sealed" , "static" , "true" , "virtual" } ;
96
98
97
99
private static readonly string [ ] MarkdownUnconvertableStrings = new [ ] { "](~/includes" , "[!INCLUDE" } ;
@@ -437,7 +439,7 @@ private static SyntaxNode GetNodeWithTrivia(SyntaxTriviaList leadingWhitespace,
437
439
if ( leadingTrivia [ 0 ] . IsKind ( SyntaxKind . EndOfLineTrivia ) )
438
440
{
439
441
// Ensure the endline that separates nodes is respected
440
- finalTrivia = new SyntaxTriviaList ( SyntaxFactory . ElasticCarriageReturnLineFeed )
442
+ finalTrivia = new SyntaxTriviaList ( SyntaxFactory . ElasticLineFeed )
441
443
. AddRange ( finalTrivia ) ;
442
444
}
443
445
}
@@ -476,7 +478,7 @@ private static SyntaxTriviaList GetLeadingDoubleSlashComments(SyntaxNode node, S
476
478
doubleSlashComments = doubleSlashComments
477
479
. AddRange ( leadingWhitespace )
478
480
. Add ( trivia )
479
- . Add ( SyntaxFactory . CarriageReturnLineFeed ) ;
481
+ . Add ( SyntaxFactory . LineFeed ) ;
480
482
}
481
483
}
482
484
@@ -697,12 +699,12 @@ private static XmlTextSyntax GetTextAsCommentedTokens(string text, SyntaxTriviaL
697
699
698
700
// collapse newlines to a single one
699
701
string whitespace = Regex . Replace ( leadingWhitespace . ToFullString ( ) , @"(\r?\n)+" , "" ) ;
700
- SyntaxToken whitespaceToken = SyntaxFactory . XmlTextNewLine ( Environment . NewLine + whitespace ) ;
702
+ SyntaxToken whitespaceToken = SyntaxFactory . XmlTextNewLine ( UnixNewLine + whitespace ) ;
701
703
702
704
SyntaxTrivia leadingTrivia = SyntaxFactory . SyntaxTrivia ( SyntaxKind . DocumentationCommentExteriorTrivia , string . Empty ) ;
703
705
SyntaxTriviaList leading = SyntaxTriviaList . Create ( leadingTrivia ) ;
704
706
705
- string [ ] lines = text . Split ( Environment . NewLine , StringSplitOptions . RemoveEmptyEntries | StringSplitOptions . TrimEntries ) ;
707
+ string [ ] lines = text . Split ( new char [ ] { ' \r ' , ' \n ' } , StringSplitOptions . RemoveEmptyEntries | StringSplitOptions . TrimEntries ) ;
706
708
707
709
var tokens = new List < SyntaxToken > ( ) ;
708
710
@@ -740,7 +742,7 @@ private static SyntaxTriviaList GetXmlTrivia(XmlNodeSyntax node, SyntaxTriviaLis
740
742
741
743
return leadingWhitespace
742
744
. Add ( docCommentTrivia )
743
- . Add ( SyntaxFactory . CarriageReturnLineFeed ) ;
745
+ . Add ( SyntaxFactory . LineFeed ) ;
744
746
}
745
747
746
748
// 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
765
767
766
768
private static string WrapInRemarks ( string acum )
767
769
{
768
- string wrapped = Environment . NewLine + "<format type=\" text/markdown\" ><![CDATA[" + Environment . NewLine ;
770
+ string wrapped = UnixNewLine + "<format type=\" text/markdown\" ><![CDATA[" + UnixNewLine ;
769
771
wrapped += acum ;
770
- wrapped += Environment . NewLine + "]]></format>" + Environment . NewLine ;
772
+ wrapped += UnixNewLine + "]]></format>" + UnixNewLine ;
771
773
return wrapped ;
772
774
}
773
775
@@ -776,7 +778,7 @@ private static string WrapCodeIncludes(string[] splitted, ref int n)
776
778
string acum = string . Empty ;
777
779
while ( n < splitted . Length && splitted [ n ] . ContainsStrings ( MarkdownCodeIncludes ) )
778
780
{
779
- acum += Environment . NewLine + splitted [ n ] ;
781
+ acum += UnixNewLine + splitted [ n ] ;
780
782
if ( ( n + 1 ) < splitted . Length && splitted [ n + 1 ] . ContainsStrings ( MarkdownCodeIncludes ) )
781
783
{
782
784
n ++ ;
@@ -802,7 +804,7 @@ private static SyntaxTriviaList GetFormattedRemarks(IDocsAPI api, SyntaxTriviaLi
802
804
}
803
805
else
804
806
{
805
- string [ ] splitted = remarks . Split ( Environment . NewLine , StringSplitOptions . RemoveEmptyEntries ) ;
807
+ string [ ] splitted = remarks . Split ( new char [ ] { ' \r ' , ' \n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
806
808
string updatedRemarks = string . Empty ;
807
809
for ( int n = 0 ; n < splitted . Length ; n ++ )
808
810
{
@@ -814,7 +816,7 @@ private static SyntaxTriviaList GetFormattedRemarks(IDocsAPI api, SyntaxTriviaLi
814
816
n ++ ;
815
817
while ( n < splitted . Length && splitted [ n ] . StartsWith ( ">" ) )
816
818
{
817
- acum += Environment . NewLine + splitted [ n ] ;
819
+ acum += UnixNewLine + splitted [ n ] ;
818
820
if ( ( n + 1 ) < splitted . Length && splitted [ n + 1 ] . StartsWith ( ">" ) )
819
821
{
820
822
n ++ ;
@@ -843,14 +845,14 @@ private static SyntaxTriviaList GetFormattedRemarks(IDocsAPI api, SyntaxTriviaLi
843
845
}
844
846
else
845
847
{
846
- example += Environment . NewLine + line ;
848
+ example += UnixNewLine + line ;
847
849
}
848
850
n ++ ;
849
851
}
850
852
}
851
853
else
852
854
{
853
- updatedRemarks += ReplaceMarkdownWithXmlElements ( Environment . NewLine + line , api . Params , api . TypeParams ) ;
855
+ updatedRemarks += ReplaceMarkdownWithXmlElements ( UnixNewLine + line , api . Params , api . TypeParams ) ;
854
856
}
855
857
}
856
858
0 commit comments