Skip to content

Commit 470416d

Browse files
author
Kapil Borle
committed
Update GetLines extension method
1 parent 17510d9 commit 470416d

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

Engine/Extensions.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
3+
using System.Linq;
44
using System.Management.Automation.Language;
55

66
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Extensions
@@ -10,17 +10,7 @@ public static class Extensions
1010
{
1111
public static IEnumerable<string> GetLines(this string text)
1212
{
13-
var lines = new List<string>();
14-
using (var stringReader = new StringReader(text))
15-
{
16-
string line;
17-
line = stringReader.ReadLine();
18-
while (line != null)
19-
{
20-
yield return line;
21-
line = stringReader.ReadLine();
22-
}
23-
}
13+
return text.Split('\n').Select(line => line.TrimEnd('\r'));
2414
}
2515

2616
public static IScriptExtent Translate(this IScriptExtent extent, int lineDelta, int columnDelta)

0 commit comments

Comments
 (0)