Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ public sealed class FormatHex : PSCmdlet
public Encoding Encoding { get; set; } = ClrFacade.GetDefaultEncoding();

/// <summary>
/// Gets and sets count of bytes to read from the input stream.
/// Gets or sets count of bytes to read from the input stream.
/// </summary>
[Parameter()]
[Parameter]
[ValidateRange(ValidateRangeKind.Positive)]
public Int64 Count { get; set; } = Int64.MaxValue;

/// <summary>
/// Gets and sets offset of bytes to start reading the input stream from.
/// Gets or sets offset of bytes to start reading the input stream from.
/// </summary>
[Parameter()]
[Parameter]
[ValidateRange(ValidateRangeKind.NonNegative)]
public Int64 Offset { get; set; }

Expand Down Expand Up @@ -284,6 +284,7 @@ private void ProcessObjectContent(PSObject inputObject)
}

break;

// If the object type is not supported, throw an error. Once Serialization is
// available on CoreCLR, other types will be supported.
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ public class ByteCollection
/// <param name="value">Underlying bytes stored in the collection.</param>
/// <param name="path">Indicates the path of the file whose contents are wrapped in the ByteCollection.</param>
[Obsolete("The constructor is deprecated.", true)]
public ByteCollection(UInt32 offset, Byte[] value, string path)
public ByteCollection(UInt32 offset, byte[] value, string path)
{
Offset64 = offset;
Bytes = value;
Path = path;
}

/// <summary>
/// ByteCollection constructor.
/// Initializes a new instance of ByteCollection.
/// </summary>
/// <param name="offset">The Offset address to be used while displaying the bytes in the collection.</param>
/// <param name="value">Underlying bytes stored in the collection.</param>
/// <param name="path">Indicates the path of the file whose contents are wrapped in the ByteCollection.</param>
public ByteCollection(UInt64 offset, Byte[] value, string path)
public ByteCollection(UInt64 offset, byte[] value, string path)
{
if (value == null)
{
Expand All @@ -131,7 +131,7 @@ public ByteCollection(UInt64 offset, Byte[] value, string path)
/// <param name="offset">The Offset address to be used while displaying the bytes in the collection.</param>
/// <param name="value">Underlying bytes stored in the collection.</param>
[Obsolete("The constructor is deprecated.", true)]
public ByteCollection(UInt32 offset, Byte[] value)
public ByteCollection(UInt32 offset, byte[] value)
{
if (value == null)
{
Expand All @@ -147,7 +147,7 @@ public ByteCollection(UInt32 offset, Byte[] value)
/// </summary>
/// <param name="offset">The Offset address to be used while displaying the bytes in the collection.</param>
/// <param name="value">Underlying bytes stored in the collection.</param>
public ByteCollection(UInt64 offset, Byte[] value)
public ByteCollection(UInt64 offset, byte[] value)
{
if (value == null)
{
Expand All @@ -162,7 +162,7 @@ public ByteCollection(UInt64 offset, Byte[] value)
/// ByteCollection constructor.
/// </summary>
/// <param name="value">Underlying bytes stored in the collection.</param>
public ByteCollection(Byte[] value)
public ByteCollection(byte[] value)
{
if (value == null)
{
Expand Down Expand Up @@ -198,7 +198,7 @@ private set
/// Gets underlying bytes stored in the collection.
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public Byte[] Bytes { get; private set; }
public byte[] Bytes { get; private set; }

/// <summary>
/// Gets the path of the file whose contents are wrapped in the ByteCollection.
Expand All @@ -216,11 +216,11 @@ public override string ToString()

// '20 + 3' comes from format "{0:X20} ".
// '20' comes from '[Uint64]::MaxValue.ToString().Length'.
StringBuilder nextLine = new StringBuilder(20 + 3 + BytesPerLine*3);
StringBuilder nextLine = new StringBuilder(20 + 3 + (BytesPerLine * 3));
StringBuilder asciiEnd = new StringBuilder(BytesPerLine);

// '+1' comes from 'result.Append(nextLine.ToString() + " " + asciiEnd.ToString());' below.
StringBuilder result = new StringBuilder(nextLine.Capacity+asciiEnd.Capacity + 1);
StringBuilder result = new StringBuilder(nextLine.Capacity + asciiEnd.Capacity + 1);

if (Bytes.Length > 0)
{
Expand All @@ -232,7 +232,7 @@ public override string ToString()

nextLine.AppendFormat(CultureInfo.InvariantCulture, LineFormat, currentOffset);

foreach (Byte currentByte in Bytes)
foreach (byte currentByte in Bytes)
{
// Display each byte, in 2-digit hexadecimal, and add that to the left-hand side.
nextLine.AppendFormat("{0:X2} ", currentByte);
Expand Down