From a5f0ea72372f2a0000983b32ed2f9c26ef328942 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 16 Mar 2018 18:47:33 +0100 Subject: [PATCH] Fix #1098: System.IO.EndOfStreamException in XmlDocumentationProvider --- .../Documentation/XmlDocumentationProvider.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs index 89285a320..d55b836bb 100644 --- a/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs +++ b/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs @@ -246,6 +246,7 @@ namespace ICSharpCode.Decompiler.Documentation public int GetPositionForLine(int line) { Debug.Assert(line >= currentLine); + char prevChar = '\0'; while (line > currentLine) { int b = fs.ReadByte(); if (b < 0) @@ -255,8 +256,12 @@ namespace ICSharpCode.Decompiler.Documentation input[0] = (byte)b; decoder.Convert(input, 0, 1, output, 0, 1, false, out bytesUsed, out charsUsed, out completed); Debug.Assert(bytesUsed == 1); - if (charsUsed == 1 && output[0] == '\n') { - currentLine++; + if (charsUsed == 1) { + if ((prevChar != '\r' && output[0] == '\n') || output[0] == '\r') + currentLine++; + prevChar = output[0]; + } else { + prevChar = '\0'; } } return checked((int)fs.Position);