From 0bce3e0e0d8156c7e694259d9d96f006607dfe42 Mon Sep 17 00:00:00 2001 From: Ilya Date: Fri, 19 Oct 2018 19:16:13 +0500 Subject: [PATCH] Style fixes in Format-Hex (#8083) --- .../FormatAndOutput/format-hex/Format-Hex.cs | 9 +++++---- .../commands/utility/UtilityCommon.cs | 20 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs index 18f370849e..a6c300fa6a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs @@ -55,16 +55,16 @@ namespace Microsoft.PowerShell.Commands public Encoding Encoding { get; set; } = ClrFacade.GetDefaultEncoding(); /// - /// Gets and sets count of bytes to read from the input stream. + /// Gets or sets count of bytes to read from the input stream. /// - [Parameter()] + [Parameter] [ValidateRange(ValidateRangeKind.Positive)] public Int64 Count { get; set; } = Int64.MaxValue; /// - /// 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. /// - [Parameter()] + [Parameter] [ValidateRange(ValidateRangeKind.NonNegative)] public Int64 Offset { get; set; } @@ -284,6 +284,7 @@ namespace Microsoft.PowerShell.Commands } break; + // If the object type is not supported, throw an error. Once Serialization is // available on CoreCLR, other types will be supported. default: diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs index d724330d86..f44b616e56 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs @@ -100,7 +100,7 @@ namespace Microsoft.PowerShell.Commands /// Underlying bytes stored in the collection. /// Indicates the path of the file whose contents are wrapped in the ByteCollection. [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; @@ -108,12 +108,12 @@ namespace Microsoft.PowerShell.Commands } /// - /// ByteCollection constructor. + /// Initializes a new instance of ByteCollection. /// /// The Offset address to be used while displaying the bytes in the collection. /// Underlying bytes stored in the collection. /// Indicates the path of the file whose contents are wrapped in the ByteCollection. - public ByteCollection(UInt64 offset, Byte[] value, string path) + public ByteCollection(UInt64 offset, byte[] value, string path) { if (value == null) { @@ -131,7 +131,7 @@ namespace Microsoft.PowerShell.Commands /// The Offset address to be used while displaying the bytes in the collection. /// Underlying bytes stored in the collection. [Obsolete("The constructor is deprecated.", true)] - public ByteCollection(UInt32 offset, Byte[] value) + public ByteCollection(UInt32 offset, byte[] value) { if (value == null) { @@ -147,7 +147,7 @@ namespace Microsoft.PowerShell.Commands /// /// The Offset address to be used while displaying the bytes in the collection. /// Underlying bytes stored in the collection. - public ByteCollection(UInt64 offset, Byte[] value) + public ByteCollection(UInt64 offset, byte[] value) { if (value == null) { @@ -162,7 +162,7 @@ namespace Microsoft.PowerShell.Commands /// ByteCollection constructor. /// /// Underlying bytes stored in the collection. - public ByteCollection(Byte[] value) + public ByteCollection(byte[] value) { if (value == null) { @@ -198,7 +198,7 @@ namespace Microsoft.PowerShell.Commands /// Gets underlying bytes stored in the collection. /// [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] - public Byte[] Bytes { get; private set; } + public byte[] Bytes { get; private set; } /// /// Gets the path of the file whose contents are wrapped in the ByteCollection. @@ -216,11 +216,11 @@ namespace Microsoft.PowerShell.Commands // '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) { @@ -232,7 +232,7 @@ namespace Microsoft.PowerShell.Commands 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);