11using System ;
2+ using System . Globalization ;
23
34namespace Microsoft . Windows . PowerShell . ScriptAnalyzer
45{
@@ -10,12 +11,16 @@ public Position(int line, int column)
1011 {
1112 if ( line < 1 )
1213 {
13- throw new ArgumentException ( "line cannot be less than 1." , nameof ( line ) ) ;
14+ throw new ArgumentException (
15+ String . Format ( CultureInfo . CurrentCulture , Strings . PositionLineLessThanOne ) ,
16+ nameof ( line ) ) ;
1417 }
1518
1619 if ( column < 1 )
1720 {
18- throw new ArgumentException ( "line cannot be less than 1." , nameof ( line ) ) ;
21+ throw new ArgumentException (
22+ String . Format ( CultureInfo . CurrentCulture , Strings . PositionColumnLessThanOne ) ,
23+ nameof ( column ) ) ;
1924 }
2025
2126 Line = line ;
@@ -38,24 +43,20 @@ public Position Shift(int lineDelta, int columnDelta)
3843 int newLine = Line ;
3944 int newColumn = Column ;
4045
41- if ( lineDelta != 0 )
46+ newLine += lineDelta ;
47+ if ( newLine < 1 )
4248 {
43- newLine += lineDelta ;
44- if ( newLine < 1 )
45- {
46- throw new ArgumentException ( "Invalid line delta. Resulting start line number must be greather than 1." ) ;
47-
48- }
49+ throw new ArgumentException (
50+ String . Format ( CultureInfo . CurrentCulture , Strings . PositionLineLessThanOne ) ,
51+ nameof ( lineDelta ) ) ;
4952 }
5053
51- if ( columnDelta != 0 )
54+ newColumn += columnDelta ;
55+ if ( newColumn < 1 )
5256 {
53- newColumn += columnDelta ;
54- if ( newColumn < 1 )
55- {
56- throw new ArgumentException ( "Invalid column delta. Resulting start column number must be greather than 1." ) ;
57-
58- }
57+ throw new ArgumentException (
58+ String . Format ( CultureInfo . CurrentCulture , Strings . PositionColumnLessThanOne ) ,
59+ nameof ( columnDelta ) ) ;
5960 }
6061
6162 return new Position ( newLine , newColumn ) ;
@@ -75,7 +76,9 @@ public static Position Normalize(Position refPos, Position pos)
7576
7677 if ( pos < refPos )
7778 {
78- throw new ArgumentException ( "input should be less than that of the invoking object." ) ;
79+ throw new ArgumentException ( String . Format (
80+ CultureInfo . CurrentCulture ,
81+ Strings . PositionRefPosLessThanInputPos ) ) ;
7982 }
8083
8184 if ( pos . Line == refPos . Line )
0 commit comments