Skip to content

Commit 847ac16

Browse files
author
Kapil Borle
committed
Localize error strings in Range class
1 parent 413a6ef commit 847ac16

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Engine/Range.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
2+
using System.Globalization;
23

34
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer
45
{
6+
// TODO doc
57
public class Range
68
{
79
public Position Start { get; }
@@ -10,7 +12,9 @@ public Range(Position start, Position end)
1012
{
1113
if (start > end)
1214
{
13-
throw new ArgumentException("start position cannot be before end position.");
15+
throw new ArgumentException(String.Format(
16+
CultureInfo.CurrentCulture,
17+
Strings.RangeStartPosGreaterThanEndPos));
1418
}
1519

1620
Start = new Position(start);
@@ -57,7 +61,9 @@ public static Range Normalize(Position refPosition, Range range)
5761

5862
if (refPosition > range.Start)
5963
{
60-
throw new ArgumentException("reference range should start before range");
64+
throw new ArgumentException(String.Format(
65+
CultureInfo.CurrentCulture,
66+
Strings.RangeRefPosShouldStartBeforeRangeStartPos));
6167
}
6268

6369
return range.Shift(

Engine/Strings.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,10 @@
303303
<data name="EditableTextInvalidLineEnding" xml:space="preserve">
304304
<value>Cannot determine line endings as the text probably contain mixed line endings.</value>
305305
</data>
306+
<data name="RangeStartPosGreaterThanEndPos" xml:space="preserve">
307+
<value>Start position cannot be before End position.</value>
308+
</data>
309+
<data name="RangeRefPosShouldStartBeforeRangeStartPos" xml:space="preserve">
310+
<value>Reference Position should begin before start Position of Range.</value>
311+
</data>
306312
</root>

0 commit comments

Comments
 (0)