File size: 28,530 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
#if !STANDALONE
using System.Management.Automation.Internal;
#endif
namespace System.Management.Automation.Language
{
#region Public Interfaces
/// <summary>
/// Represents a single point in a script. The script may come from a file or interactive input.
/// </summary>
#nullable enable
public interface IScriptPosition
{
/// <summary>
/// The name of the file, or if the script did not come from a file, then null.
/// </summary>
string? File { get; }
/// <summary>
/// The line number of the position, with the value 1 being the first line.
/// </summary>
int LineNumber { get; }
/// <summary>
/// The column number of the position, with the value 1 being the first column.
/// </summary>
int ColumnNumber { get; }
/// <summary>
/// The offset from the beginning of the script.
/// </summary>
int Offset { get; }
/// <summary>
/// The complete text of the line that this position is included on.
/// </summary>
string Line { get; }
/// <summary>
/// The complete script that this position is included in.
/// </summary>
string? GetFullScript();
}
#nullable restore
/// <summary>
/// Represents the a span of text in a script.
/// </summary>
#nullable enable
public interface IScriptExtent
{
/// <summary>
/// The filename the extent includes, or null if the extent is not included in any file.
/// </summary>
string? File { get; }
/// <summary>
/// The starting position of the extent.
/// </summary>
IScriptPosition StartScriptPosition { get; }
/// <summary>
/// The end position of the extent. This position is actually 1 character past the end of the extent.
/// </summary>
IScriptPosition EndScriptPosition { get; }
/// <summary>
/// The line number at the beginning of the extent, with the value 1 being the first line.
/// </summary>
int StartLineNumber { get; }
/// <summary>
/// The column number at the beginning of the extent, with the value 1 being the first column.
/// </summary>
int StartColumnNumber { get; }
/// <summary>
/// The line number at the end of the extent, with the value 1 being the first line.
/// </summary>
int EndLineNumber { get; }
/// <summary>
/// The column number at the end of the extent, with the value 1 being the first column.
/// </summary>
int EndColumnNumber { get; }
/// <summary>
/// The script text that the extent includes.
/// </summary>
string Text { get; }
/// <summary>
/// The starting offset of the extent.
/// </summary>
int StartOffset { get; }
/// <summary>
/// The ending offset of the extent.
/// </summary>
int EndOffset { get; }
}
#nullable restore
/// <summary>
/// A few utility functions for script positions.
/// </summary>
internal static class PositionUtilities
{
/// <summary>
/// Return a unique position representing an empty or missing position.
/// </summary>
public static IScriptPosition EmptyPosition { get; } = new EmptyScriptPosition();
/// <summary>
/// Return a unique extent representing an empty or missing extent.
/// </summary>
public static IScriptExtent EmptyExtent { get; } = new EmptyScriptExtent();
/// <summary>
/// Return a message that looks like:
///
/// At {filename}:{line} char:{column}
/// + $x + @y
/// + ~
/// </summary>
internal static string VerboseMessage(IScriptExtent position)
{
if (PositionUtilities.EmptyExtent.Equals(position))
{
return string.Empty;
}
string fileName = position.File;
if (string.IsNullOrEmpty(fileName))
{
fileName = ParserStrings.TextForWordLine;
}
string sourceLine = position.StartScriptPosition.Line.TrimEnd();
string message = string.Empty;
if (!string.IsNullOrEmpty(sourceLine))
{
int spacesBeforeError = position.StartColumnNumber - 1;
int errorLength = (position.StartLineNumber == position.EndLineNumber && position.EndColumnNumber <= sourceLine.Length + 1)
? position.EndColumnNumber - position.StartColumnNumber
: sourceLine.Length - position.StartColumnNumber + 1;
// Expand tabs before figuring out if we need to truncate the line
if (sourceLine.Contains('\t'))
{
var copyLine = new StringBuilder(sourceLine.Length * 2);
var beforeError = sourceLine.Substring(0, spacesBeforeError).Replace("\t", " ");
var error = sourceLine.Substring(spacesBeforeError, errorLength).Replace("\t", " ");
copyLine.Append(beforeError);
copyLine.Append(error);
copyLine.Append(sourceLine.Substring(spacesBeforeError + errorLength).Replace("\t", " "));
spacesBeforeError = beforeError.Length;
errorLength = error.Length;
sourceLine = copyLine.ToString();
}
// Max width is 69 because:
// * sometimes PowerShell is opened with width 80
// * we always prepend "+ "
// * we sometimes prepend "... "
// * we sometimes append " ..."
// * wrapping kicks in if we hit the width exactly, so -1 to avoid that.
const int maxLineLength = 69;
bool needsPrefixDots = false;
bool needsSuffixDots = false;
int lineLength = sourceLine.Length;
var sb = new StringBuilder(sourceLine.Length * 2 + 4);
if (lineLength > maxLineLength)
{
// Need to truncate - include as much of the error as we can, but with
// some preceding context if possible.
int totalPrefix = spacesBeforeError;
int prefix = Math.Min(totalPrefix, 12);
int totalSuffix = lineLength - errorLength - spacesBeforeError;
int suffix = Math.Min(totalSuffix, 8);
int candidateLength = prefix + errorLength + suffix;
if (candidateLength >= maxLineLength)
{
// Too long. The suffix is truncated automatically by
// the Substring call, but we might need some of the
// squiggles removed as well.
if (prefix + errorLength >= maxLineLength)
{
errorLength = maxLineLength - prefix;
}
needsSuffixDots = true;
}
else
{
// We can shift prefix to suffix or vice versa to fill in
// more of the line. Prefer shifting to prefix.
int prefixAvailable = totalPrefix - prefix;
if (prefixAvailable > 0)
{
prefix += Math.Min(prefixAvailable, maxLineLength - candidateLength);
candidateLength = prefix + errorLength + suffix;
}
if (candidateLength < maxLineLength && totalSuffix > 0)
{
suffix += Math.Min(totalSuffix, maxLineLength - candidateLength);
}
needsSuffixDots = (suffix < totalSuffix);
}
needsPrefixDots = (prefix < totalPrefix);
var startIndex = Math.Max(spacesBeforeError - prefix, 0);
sourceLine = sourceLine.Substring(startIndex, maxLineLength);
spacesBeforeError = Math.Min(spacesBeforeError, prefix);
errorLength = Math.Min(errorLength, maxLineLength - spacesBeforeError);
}
if (needsPrefixDots)
{
sb.Append("\u2026 "); // Unicode ellipsis character
}
sb.Append(sourceLine);
if (needsSuffixDots)
{
sb.Append(" \u2026"); // Unicode ellipsis character
}
sb.Append(Environment.NewLine);
sb.Append("+ ");
sb.Append(' ', spacesBeforeError + (needsPrefixDots ? 2 : 0));
// errorLength of 0 happens at EOF - always write out 1.
sb.Append('~', errorLength > 0 ? errorLength : 1);
message = sb.ToString();
}
return StringUtil.Format(
ParserStrings.TextForPositionMessage,
fileName,
position.StartLineNumber,
position.StartColumnNumber,
message);
}
/// <summary>
/// Return a message that looks like:
/// 12+ $x + <<<< $b.
/// </summary>
internal static string BriefMessage(IScriptPosition position)
{
StringBuilder message = new StringBuilder(position.Line);
if (position.ColumnNumber > message.Length)
{
message.Append(" <<<< ");
}
else
{
message.Insert(position.ColumnNumber - 1, " >>>> ");
}
return StringUtil.Format(ParserStrings.TraceScriptLineMessage, position.LineNumber, message.ToString());
}
internal static IScriptExtent NewScriptExtent(IScriptExtent start, IScriptExtent end)
{
if (start == end)
{
return start;
}
if (start == EmptyExtent)
{
return end;
}
if (end == EmptyExtent)
{
return start;
}
InternalScriptExtent startExtent = start as InternalScriptExtent;
InternalScriptExtent endExtent = end as InternalScriptExtent;
Diagnostics.Assert(startExtent != null && endExtent != null, "This function only handles internal and empty extents");
Diagnostics.Assert(startExtent.PositionHelper == endExtent.PositionHelper, "Extents must be from same source");
return new InternalScriptExtent(startExtent.PositionHelper, startExtent.StartOffset, endExtent.EndOffset);
}
internal static bool IsBefore(this IScriptExtent extentToTest, IScriptExtent startExtent)
{
if (extentToTest.EndLineNumber < startExtent.StartLineNumber)
{
return true;
}
if (extentToTest.EndLineNumber == startExtent.StartLineNumber)
{
return extentToTest.EndColumnNumber <= startExtent.StartColumnNumber;
}
return false;
}
internal static bool IsAfter(this IScriptExtent extentToTest, IScriptExtent endExtent)
{
if (extentToTest.StartLineNumber > endExtent.EndLineNumber)
{
return true;
}
if (extentToTest.StartLineNumber == endExtent.EndLineNumber)
{
return extentToTest.StartColumnNumber >= endExtent.EndColumnNumber;
}
return false;
}
internal static bool IsWithin(this IScriptExtent extentToTest, IScriptExtent extent)
{
return extentToTest.StartOffset >= extent.StartOffset && extentToTest.EndOffset <= extent.EndOffset;
}
internal static bool IsAfter(this IScriptExtent extent, int line, int column)
{
if (line < extent.StartLineNumber)
return true;
return (line == extent.StartLineNumber && column < extent.StartColumnNumber);
}
internal static bool ContainsLineAndColumn(this IScriptExtent extent, int line, int column)
{
if (extent.StartLineNumber == line)
{
if (column == 0)
{
return true;
}
if (column >= extent.StartColumnNumber)
{
if (extent.EndLineNumber != extent.StartLineNumber)
{
return true;
}
return (column < extent.EndColumnNumber);
}
return false;
}
if (extent.StartLineNumber > line)
return false;
if (line > extent.EndLineNumber)
return false;
if (extent.EndLineNumber == line)
return column < extent.EndColumnNumber;
return true;
}
}
#endregion Public Interfaces
#region Internal Position
internal class PositionHelper
{
private int[] _lineStartMap;
internal PositionHelper(string filename, string scriptText)
{
File = filename;
ScriptText = scriptText;
}
internal string ScriptText { get; }
internal int[] LineStartMap
{
set { _lineStartMap = value; }
}
public string File { get; }
internal int LineFromOffset(int offset)
{
int line = Array.BinarySearch<int>(_lineStartMap, offset);
if (line < 0)
{
line = ~line - 1;
}
return line + 1;
}
internal int ColumnFromOffset(int offset)
{
return offset - _lineStartMap[LineFromOffset(offset) - 1] + 1;
}
internal string Text(int line)
{
int start = _lineStartMap[line - 1];
if (line < _lineStartMap.Length)
{
int length = _lineStartMap[line] - start;
return ScriptText.Substring(start, length);
}
return ScriptText.Substring(start);
}
}
internal sealed class InternalScriptPosition : IScriptPosition
{
private readonly PositionHelper _positionHelper;
internal InternalScriptPosition(PositionHelper _positionHelper, int offset)
{
this._positionHelper = _positionHelper;
Offset = offset;
}
public string File { get { return _positionHelper.File; } }
public int LineNumber { get { return _positionHelper.LineFromOffset(Offset); } }
public int ColumnNumber { get { return _positionHelper.ColumnFromOffset(Offset); } }
public string Line { get { return _positionHelper.Text(LineNumber); } }
public int Offset { get; }
internal InternalScriptPosition CloneWithNewOffset(int offset)
{
return new InternalScriptPosition(_positionHelper, offset);
}
public string GetFullScript()
{
return _positionHelper.ScriptText;
}
}
internal sealed class InternalScriptExtent : IScriptExtent
{
internal InternalScriptExtent(PositionHelper _positionHelper, int startOffset, int endOffset)
{
this.PositionHelper = _positionHelper;
StartOffset = startOffset;
EndOffset = endOffset;
}
public string File
{
get { return PositionHelper.File; }
}
public IScriptPosition StartScriptPosition
{
get { return new InternalScriptPosition(PositionHelper, StartOffset); }
}
public IScriptPosition EndScriptPosition
{
get { return new InternalScriptPosition(PositionHelper, EndOffset); }
}
public int StartLineNumber
{
get { return PositionHelper.LineFromOffset(StartOffset); }
}
public int StartColumnNumber
{
get { return PositionHelper.ColumnFromOffset(StartOffset); }
}
public int EndLineNumber
{
get { return PositionHelper.LineFromOffset(EndOffset); }
}
public int EndColumnNumber
{
get { return PositionHelper.ColumnFromOffset(EndOffset); }
}
public string Text
{
get
{
// StartOffset can be > the length for the EOF token.
if (StartOffset > PositionHelper.ScriptText.Length)
{
return string.Empty;
}
return PositionHelper.ScriptText.Substring(StartOffset, EndOffset - StartOffset);
}
}
public override string ToString()
{
return Text;
}
internal PositionHelper PositionHelper { get; }
public int StartOffset { get; }
public int EndOffset { get; }
}
#endregion Internal Position
#region "Empty" Positions
internal sealed class EmptyScriptPosition : IScriptPosition
{
public string File { get { return null; } }
public int LineNumber { get { return 0; } }
public int ColumnNumber { get { return 0; } }
public int Offset { get { return 0; } }
public string Line { get { return string.Empty; } }
public string GetFullScript() { return null; }
}
internal sealed class EmptyScriptExtent : IScriptExtent
{
public string File { get { return null; } }
public IScriptPosition StartScriptPosition { get { return PositionUtilities.EmptyPosition; } }
public IScriptPosition EndScriptPosition { get { return PositionUtilities.EmptyPosition; } }
public int StartLineNumber { get { return 0; } }
public int StartColumnNumber { get { return 0; } }
public int EndLineNumber { get { return 0; } }
public int EndColumnNumber { get { return 0; } }
public int StartOffset { get { return 0; } }
public int EndOffset { get { return 0; } }
public string Text { get { return string.Empty; } }
public override bool Equals(object obj)
{
if (!(obj is IScriptExtent otherPosition))
{
return false;
}
if ((string.IsNullOrEmpty(otherPosition.File)) &&
(otherPosition.StartLineNumber == StartLineNumber) &&
(otherPosition.StartColumnNumber == StartColumnNumber) &&
(otherPosition.EndLineNumber == EndLineNumber) &&
(otherPosition.EndColumnNumber == EndColumnNumber) &&
(string.IsNullOrEmpty(otherPosition.Text)))
{
return true;
}
else
{
return false;
}
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
#endregion "Empty" Positions
/// <summary>
/// Represents a single point in a script. The script may come from a file or interactive input.
/// </summary>
public sealed class ScriptPosition : IScriptPosition
{
private readonly string _fullScript;
/// <summary>
/// Creates a new script position, which represents a point in a script.
/// </summary>
/// <param name="scriptName">The name of the file, or if the script did not come from a file, then null.</param>
/// <param name="scriptLineNumber">The line number of the position, with the value 1 being the first line.</param>
/// <param name="offsetInLine">The column number of the position, with the value 1 being the first column.</param>
/// <param name="line">The complete text of the line that this position is included on.</param>
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public ScriptPosition(string scriptName, int scriptLineNumber, int offsetInLine, string line)
{
File = scriptName;
LineNumber = scriptLineNumber;
ColumnNumber = offsetInLine;
if (string.IsNullOrEmpty(line))
{
Line = string.Empty;
}
else
{
Line = line;
}
}
/// <summary>
/// Creates a new script position, which represents a point in a script.
/// </summary>
/// <param name="scriptName">The name of the file, or if the script did not come from a file, then null.</param>
/// <param name="scriptLineNumber">The line number of the position, with the value 1 being the first line.</param>
/// <param name="offsetInLine">The column number of the position, with the value 1 being the first column.</param>
/// <param name="line">The complete text of the line that this position is included on.</param>
/// <param name="fullScript">The complete script text. Optional, can be null.</param>
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public ScriptPosition(
string scriptName,
int scriptLineNumber,
int offsetInLine,
string line,
string fullScript)
: this(scriptName, scriptLineNumber, offsetInLine, line)
{
_fullScript = fullScript;
}
/// <summary>
/// The name of the file, or if the script did not come from a file, then null.
/// </summary>
public string File { get; }
/// <summary>
/// The line number of the position, with the value 1 being the first line.
/// </summary>
public int LineNumber { get; }
/// <summary>
/// The column number of the position, with the value 1 being the first column.
/// </summary>
public int ColumnNumber { get; }
/// <summary>
/// The offset from the beginning of the script, always return 0.
/// </summary>
public int Offset { get { return 0; } }
/// <summary>
/// The complete text of the line that this position is included on.
/// </summary>
public string Line { get; }
/// <summary>
/// The complete script that this position is included in.
/// </summary>
public string GetFullScript() { return _fullScript; }
}
/// <summary>
/// A script extent used to customize the display of error location information.
/// </summary>
public sealed class ScriptExtent : IScriptExtent
{
private ScriptPosition _startPosition;
private ScriptPosition _endPosition;
private ScriptExtent()
{
}
/// <summary>
/// Creates a new ScriptExtent class.
/// </summary>
public ScriptExtent(ScriptPosition startPosition, ScriptPosition endPosition)
{
_startPosition = startPosition;
_endPosition = endPosition;
}
/// <summary>
/// The name of the file, or if the script did not come from a file, then null.
/// </summary>
public string File { get { return _startPosition.File; } }
/// <summary>
/// The starting position of the extent.
/// </summary>
public IScriptPosition StartScriptPosition { get { return _startPosition; } }
/// <summary>
/// The end position of the extent. This position is actually 1 character past the end of the extent.
/// </summary>
public IScriptPosition EndScriptPosition { get { return _endPosition; } }
/// <summary>
/// The line number at the beginning of the extent, with the value 1 being the first line.
/// </summary>
public int StartLineNumber { get { return _startPosition.LineNumber; } }
/// <summary>
/// The column number at the beginning of the extent, with the value 1 being the first column.
/// </summary>
public int StartColumnNumber { get { return _startPosition.ColumnNumber; } }
/// <summary>
/// The line number at the end of the extent, with the value 1 being the first line.
/// </summary>
public int EndLineNumber { get { return _endPosition.LineNumber; } }
/// <summary>
/// The column number at the end of the extent, with the value 1 being the first column.
/// </summary>
public int EndColumnNumber { get { return _endPosition.ColumnNumber; } }
/// <summary>
/// The start offset (always returns 0)
/// </summary>
public int StartOffset { get { return 0; } }
/// <summary>
/// The end offset (always returns 0)
/// </summary>
public int EndOffset { get { return 0; } }
/// <summary>
/// The script text that the extent includes.
/// </summary>
public string Text
{
get
{
if (EndColumnNumber > 0)
{
if (StartLineNumber == EndLineNumber)
{
return _startPosition.Line.Substring(_startPosition.ColumnNumber - 1,
_endPosition.ColumnNumber - _startPosition.ColumnNumber);
}
var start = _startPosition.Line.AsSpan(_startPosition.ColumnNumber);
var end = _endPosition.Line.AsSpan(0, _endPosition.ColumnNumber);
return string.Create(CultureInfo.InvariantCulture, $"{start}...{end}");
}
else
{
return string.Empty;
}
}
}
internal void ToPSObjectForRemoting(PSObject dest)
{
RemotingEncoder.AddNoteProperty(dest, "ScriptExtent_File", () => File);
RemotingEncoder.AddNoteProperty(dest, "ScriptExtent_StartLineNumber", () => StartLineNumber);
RemotingEncoder.AddNoteProperty(dest, "ScriptExtent_StartColumnNumber", () => StartColumnNumber);
RemotingEncoder.AddNoteProperty(dest, "ScriptExtent_EndLineNumber", () => EndLineNumber);
RemotingEncoder.AddNoteProperty(dest, "ScriptExtent_EndColumnNumber", () => EndColumnNumber);
}
private void PopulateFromSerializedInfo(PSObject serializedScriptExtent)
{
string file = RemotingDecoder.GetPropertyValue<string>(serializedScriptExtent, "ScriptExtent_File");
int startLineNumber = RemotingDecoder.GetPropertyValue<int>(serializedScriptExtent, "ScriptExtent_StartLineNumber");
int startColumnNumber = RemotingDecoder.GetPropertyValue<int>(serializedScriptExtent, "ScriptExtent_StartColumnNumber");
int endLineNumber = RemotingDecoder.GetPropertyValue<int>(serializedScriptExtent, "ScriptExtent_EndLineNumber");
int endColumnNumber = RemotingDecoder.GetPropertyValue<int>(serializedScriptExtent, "ScriptExtent_EndColumnNumber");
ScriptPosition startPosition = new ScriptPosition(file, startLineNumber, startColumnNumber, null);
ScriptPosition endPosition = new ScriptPosition(file, endLineNumber, endColumnNumber, null);
_startPosition = startPosition;
_endPosition = endPosition;
}
internal static ScriptExtent FromPSObjectForRemoting(PSObject serializedScriptExtent)
{
ScriptExtent extent = new ScriptExtent();
extent.PopulateFromSerializedInfo(serializedScriptExtent);
return extent;
}
}
}
|