From 8c501a65210dbf2eedb8faf75a8ab5e3ec824bfe Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Wed, 25 Nov 2020 12:16:11 +0000 Subject: [PATCH 1/3] Fix RCS1188: Remove redundant auto-property initialization part 2 `src\Microsoft.PowerShell.Commands.Utility\Microsoft.PowerShell.Commands.Utility.csproj` Follow-up to #14244. https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1188.md --- .../commands/management/PingPathCommand.cs | 2 +- .../commands/utility/AddType.cs | 4 ++-- .../commands/utility/ExportAliasCommand.cs | 2 +- .../commands/utility/Measure-Object.cs | 4 ++-- .../commands/utility/New-Object.cs | 6 +++--- .../commands/utility/NewTimeSpanCommand.cs | 8 ++++---- .../commands/utility/OrderObjectBase.cs | 4 ++-- .../commands/utility/Select-Object.cs | 8 ++++---- .../commands/utility/Sort-Object.cs | 4 ++-- .../commands/utility/Var.cs | 2 +- .../Common/WebRequestPSCmdlet.Common.cs | 6 +++--- .../commands/utility/Write.cs | 16 ++++++++-------- .../commands/utility/WriteAliasCommandBase.cs | 2 +- .../commands/utility/WriteConsoleCmdlet.cs | 2 +- .../commands/utility/WriteProgressCmdlet.cs | 2 +- .../commands/utility/XmlCommands.cs | 4 ++-- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs index 197ffa694bd..43694f89d54 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs @@ -109,7 +109,7 @@ public override string[] Exclude /// [Parameter] [Alias("Type")] - public TestPathType PathType { get; set; } = TestPathType.Any; + public TestPathType PathType { get; set; } /// /// Gets or sets the IsValid parameter. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index a2ffec58392..30a6789653f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -280,7 +280,7 @@ private void ProcessPaths(List resolvedPaths) /// [Parameter(ParameterSetName = FromSourceParameterSetName)] [Parameter(ParameterSetName = FromMemberParameterSetName)] - public Language Language { get; set; } = Language.CSharp; + public Language Language { get; set; } /// /// Any reference DLLs to use in the compilation. @@ -392,7 +392,7 @@ public string OutputAssembly [Parameter(ParameterSetName = FromPathParameterSetName)] [Parameter(ParameterSetName = FromLiteralPathParameterSetName)] [Alias("OT")] - public OutputAssemblyType OutputType { get; set; } = OutputAssemblyType.Library; + public OutputAssemblyType OutputType { get; set; } /// /// Flag to pass the resulting types along. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs index 431f30a3dcc..b256c0f8632 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs @@ -109,7 +109,7 @@ public SwitchParameter PassThru /// Parameter that determines the format of the file created. /// [Parameter] - public ExportAliasFormat As { get; set; } = ExportAliasFormat.Csv; + public ExportAliasFormat As { get; set; } /// /// Property that sets append parameter. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs index 529687db68f..78c3595367a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Measure-Object.cs @@ -18,7 +18,7 @@ public abstract class MeasureInfo /// /// Property name. /// - public string Property { get; set; } = null; + public string Property { get; set; } } /// @@ -244,7 +244,7 @@ public MeasureObjectCommand() /// [ValidateNotNullOrEmpty] [Parameter(Position = 0)] - public PSPropertyExpression[] Property { get; set; } = null; + public PSPropertyExpression[] Property { get; set; } #endregion Common parameters in both sets diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs index b40b53952f0..c067615f3c0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs @@ -34,7 +34,7 @@ public sealed class NewObjectCommand : PSCmdlet /// the number [Parameter(ParameterSetName = netSetName, Mandatory = true, Position = 0)] [ValidateTrustedData] - public string TypeName { get; set; } = null; + public string TypeName { get; set; } #if !UNIX private Guid _comObjectClsId = Guid.Empty; @@ -43,7 +43,7 @@ public sealed class NewObjectCommand : PSCmdlet /// [Parameter(ParameterSetName = "Com", Mandatory = true, Position = 0)] [ValidateTrustedData] - public string ComObject { get; set; } = null; + public string ComObject { get; set; } #endif /// @@ -53,7 +53,7 @@ public sealed class NewObjectCommand : PSCmdlet [Parameter(ParameterSetName = netSetName, Mandatory = false, Position = 1)] [ValidateTrustedData] [Alias("Args")] - public object[] ArgumentList { get; set; } = null; + public object[] ArgumentList { get; set; } /// /// True if we should have an error when Com objects will use an interop assembly. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewTimeSpanCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewTimeSpanCommand.cs index 0e633ca5b2e..53c39250763 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewTimeSpanCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewTimeSpanCommand.cs @@ -68,25 +68,25 @@ public DateTime End /// Allows the user to override the day. /// [Parameter(ParameterSetName = "Time")] - public int Days { get; set; } = 0; + public int Days { get; set; } /// /// Allows the user to override the hour. /// [Parameter(ParameterSetName = "Time")] - public int Hours { get; set; } = 0; + public int Hours { get; set; } /// /// Allows the user to override the minute. /// [Parameter(ParameterSetName = "Time")] - public int Minutes { get; set; } = 0; + public int Minutes { get; set; } /// /// Allows the user to override the second. /// [Parameter(ParameterSetName = "Time")] - public int Seconds { get; set; } = 0; + public int Seconds { get; set; } #endregion diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs index b3f768f1a65..0e00de90d52 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/OrderObjectBase.cs @@ -182,9 +182,9 @@ internal sealed class OrderByProperty /// /// A logical matrix where each row is an input object and its property values specified by Properties. /// - internal List OrderMatrix { get; } = null; + internal List OrderMatrix { get; } - internal OrderByPropertyComparer Comparer { get; } = null; + internal OrderByPropertyComparer Comparer { get; } internal List MshParameterList { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs index 4fd27e4d007..0144812e9e0 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs @@ -91,14 +91,14 @@ public sealed class SelectObjectCommand : PSCmdlet /// [Parameter(ParameterSetName = "DefaultParameter")] [Parameter(ParameterSetName = "SkipLastParameter")] - public string[] ExcludeProperty { get; set; } = null; + public string[] ExcludeProperty { get; set; } /// /// /// [Parameter(ParameterSetName = "DefaultParameter")] [Parameter(ParameterSetName = "SkipLastParameter")] - public string ExpandProperty { get; set; } = null; + public string ExpandProperty { get; set; } /// /// @@ -152,14 +152,14 @@ public int First /// [Parameter(ParameterSetName = "DefaultParameter")] [ValidateRange(0, int.MaxValue)] - public int Skip { get; set; } = 0; + public int Skip { get; set; } /// /// Skip the specified number of items from end. /// [Parameter(ParameterSetName = "SkipLastParameter")] [ValidateRange(0, int.MaxValue)] - public int SkipLast { get; set; } = 0; + public int SkipLast { get; set; } /// /// With this switch present, the cmdlet won't "short-circuit" diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Sort-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Sort-Object.cs index 5f66b39753f..6ccc30dcf7f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Sort-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Sort-Object.cs @@ -53,14 +53,14 @@ public SwitchParameter Descending /// [Parameter(ParameterSetName = "Top", Mandatory = true)] [ValidateRange(1, int.MaxValue)] - public int Top { get; set; } = 0; + public int Top { get; set; } /// /// Gets or sets the number of items to return in a Bottom N sort. /// [Parameter(ParameterSetName = "Bottom", Mandatory = true)] [ValidateRange(1, int.MaxValue)] - public int Bottom { get; set; } = 0; + public int Bottom { get; set; } /// /// Moves unique entries to the front of the list. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs index 6f379462cfe..06cae529d46 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs @@ -401,7 +401,7 @@ public sealed class NewVariableCommand : VariableCommandBase /// be ReadOnly, Constant, and/or Private. /// [Parameter] - public ScopedItemOptions Option { get; set; } = ScopedItemOptions.None; + public ScopedItemOptions Option { get; set; } /// /// Specifies the visibility of the new variable... diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index f540fa67636..4bf9e353536 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -139,7 +139,7 @@ public abstract partial class WebRequestPSCmdlet : PSCmdlet /// OAuth/Bearer: Requires Token. /// [Parameter] - public virtual WebAuthenticationType Authentication { get; set; } = WebAuthenticationType.None; + public virtual WebAuthenticationType Authentication { get; set; } /// /// Gets or sets the Credential property. @@ -178,7 +178,7 @@ public abstract partial class WebRequestPSCmdlet : PSCmdlet /// Gets or sets the TLS/SSL protocol used by the Web Cmdlet. /// [Parameter] - public virtual WebSslProtocol SslProtocol { get; set; } = WebSslProtocol.Default; + public virtual WebSslProtocol SslProtocol { get; set; } /// /// Gets or sets the Token property. Token is required by Authentication OAuth and Bearer. @@ -239,7 +239,7 @@ public virtual int MaximumRedirection /// [Parameter] [ValidateRange(0, Int32.MaxValue)] - public virtual int MaximumRetryCount { get; set; } = 0; + public virtual int MaximumRetryCount { get; set; } /// /// Gets or sets the RetryIntervalSec property, which determines the number seconds between retries. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs index c812d47ec7f..35e1bc8542a 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs @@ -21,7 +21,7 @@ public sealed class WriteDebugCommand : PSCmdlet [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true)] [AllowEmptyString] [Alias("Msg")] - public string Message { get; set; } = null; + public string Message { get; set; } /// /// This method implements the ProcessRecord method for Write-Debug command. @@ -69,7 +69,7 @@ public sealed class WriteVerboseCommand : PSCmdlet [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true)] [AllowEmptyString] [Alias("Msg")] - public string Message { get; set; } = null; + public string Message { get; set; } /// /// This method implements the ProcessRecord method for Write-verbose command. @@ -117,7 +117,7 @@ public sealed class WriteWarningCommand : PSCmdlet [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true)] [AllowEmptyString] [Alias("Msg")] - public string Message { get; set; } = null; + public string Message { get; set; } /// /// This method implements the ProcessRecord method for Write-Warning command. @@ -215,7 +215,7 @@ public class WriteOrThrowErrorCommand : PSCmdlet /// ErrorRecord.Exception -- if not specified, ErrorRecord.Exception is System.Exception. /// [Parameter(ParameterSetName = "WithException", Mandatory = true)] - public Exception Exception { get; set; } = null; + public Exception Exception { get; set; } /// /// If Exception is specified, this is ErrorRecord.ErrorDetails.Message; @@ -226,21 +226,21 @@ public class WriteOrThrowErrorCommand : PSCmdlet [AllowNull] [AllowEmptyString] [Alias("Msg")] - public string Message { get; set; } = null; + public string Message { get; set; } /// /// If Exception is specified, this is ErrorRecord.ErrorDetails.Message; /// otherwise, the Exception is System.Exception, and this is Exception.Message. /// [Parameter(ParameterSetName = "ErrorRecord", Mandatory = true)] - public ErrorRecord ErrorRecord { get; set; } = null; + public ErrorRecord ErrorRecord { get; set; } /// /// ErrorRecord.CategoryInfo.Category. /// [Parameter(ParameterSetName = "NoException")] [Parameter(ParameterSetName = "WithException")] - public ErrorCategory Category { get; set; } = ErrorCategory.NotSpecified; + public ErrorCategory Category { get; set; } /// /// ErrorRecord.ErrorId. @@ -254,7 +254,7 @@ public class WriteOrThrowErrorCommand : PSCmdlet /// [Parameter(ParameterSetName = "NoException")] [Parameter(ParameterSetName = "WithException")] - public object TargetObject { get; set; } = null; + public object TargetObject { get; set; } /// /// ErrorRecord.ErrorDetails.RecommendedAction. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs index 82c9c9f6557..efef3b5ea65 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs @@ -36,7 +36,7 @@ public class WriteAliasCommandBase : PSCmdlet /// for new aliases). /// [Parameter] - public ScopedItemOptions Option { get; set; } = ScopedItemOptions.None; + public ScopedItemOptions Option { get; set; } /// /// If set to true, the alias that is set is passed to the pipeline. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs index 6bfad511406..e9a1018459d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs @@ -18,7 +18,7 @@ public sealed class WriteHostCommand : ConsoleColorCmdlet /// [Parameter(Position = 0, ValueFromRemainingArguments = true, ValueFromPipeline = true)] [Alias("Msg", "Message")] - public object Object { get; set; } = null; + public object Object { get; set; } /// /// False to add a newline to the end of the output string, true if not. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs index 93a1c392c11..2135ffa99d3 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteProgressCmdlet.cs @@ -37,7 +37,7 @@ public sealed class WriteProgressCommand : PSCmdlet /// [Parameter(Position = 2)] [ValidateRange(0, Int32.MaxValue)] - public int Id { get; set; } = 0; + public int Id { get; set; } /// /// Percentage completion of the activity, or -1 if n/a. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs index 0e86cdbfa18..c0093bd6959 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/XmlCommands.cs @@ -32,7 +32,7 @@ public sealed class ExportClixmlCommand : PSCmdlet, IDisposable /// [Parameter] [ValidateRange(1, int.MaxValue)] - public int Depth { get; set; } = 0; + public int Depth { get; set; } /// /// Mandatory file name to write to. @@ -388,7 +388,7 @@ public sealed class ConvertToXmlCommand : PSCmdlet, IDisposable /// [Parameter(HelpMessage = "Specifies how many levels of contained objects should be included in the XML representation")] [ValidateRange(1, int.MaxValue)] - public int Depth { get; set; } = 0; + public int Depth { get; set; } /// /// Input Object which is written to XML format. From 707509005144329a95f581901902bd54030f185b Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Thu, 3 Dec 2020 19:31:21 +0000 Subject: [PATCH 2/3] revert changes to enums address @iSazonov review --- .../commands/management/PingPathCommand.cs | 2 +- .../commands/utility/AddType.cs | 4 ++-- .../commands/utility/ExportAliasCommand.cs | 2 +- .../commands/utility/Var.cs | 2 +- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 2 +- .../commands/utility/Write.cs | 2 +- .../commands/utility/WriteAliasCommandBase.cs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs index 43694f89d54..197ffa694bd 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/PingPathCommand.cs @@ -109,7 +109,7 @@ public override string[] Exclude /// [Parameter] [Alias("Type")] - public TestPathType PathType { get; set; } + public TestPathType PathType { get; set; } = TestPathType.Any; /// /// Gets or sets the IsValid parameter. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index 30a6789653f..a2ffec58392 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -280,7 +280,7 @@ private void ProcessPaths(List resolvedPaths) /// [Parameter(ParameterSetName = FromSourceParameterSetName)] [Parameter(ParameterSetName = FromMemberParameterSetName)] - public Language Language { get; set; } + public Language Language { get; set; } = Language.CSharp; /// /// Any reference DLLs to use in the compilation. @@ -392,7 +392,7 @@ public string OutputAssembly [Parameter(ParameterSetName = FromPathParameterSetName)] [Parameter(ParameterSetName = FromLiteralPathParameterSetName)] [Alias("OT")] - public OutputAssemblyType OutputType { get; set; } + public OutputAssemblyType OutputType { get; set; } = OutputAssemblyType.Library; /// /// Flag to pass the resulting types along. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs index b256c0f8632..431f30a3dcc 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ExportAliasCommand.cs @@ -109,7 +109,7 @@ public SwitchParameter PassThru /// Parameter that determines the format of the file created. /// [Parameter] - public ExportAliasFormat As { get; set; } + public ExportAliasFormat As { get; set; } = ExportAliasFormat.Csv; /// /// Property that sets append parameter. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs index 06cae529d46..6f379462cfe 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs @@ -401,7 +401,7 @@ public sealed class NewVariableCommand : VariableCommandBase /// be ReadOnly, Constant, and/or Private. /// [Parameter] - public ScopedItemOptions Option { get; set; } + public ScopedItemOptions Option { get; set; } = ScopedItemOptions.None; /// /// Specifies the visibility of the new variable... diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index 4bf9e353536..e10f3d9345c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -139,7 +139,7 @@ public abstract partial class WebRequestPSCmdlet : PSCmdlet /// OAuth/Bearer: Requires Token. /// [Parameter] - public virtual WebAuthenticationType Authentication { get; set; } + public virtual WebAuthenticationType Authentication { get; set; } = WebAuthenticationType.None; /// /// Gets or sets the Credential property. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs index 35e1bc8542a..baf18faac4f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Write.cs @@ -240,7 +240,7 @@ public class WriteOrThrowErrorCommand : PSCmdlet /// [Parameter(ParameterSetName = "NoException")] [Parameter(ParameterSetName = "WithException")] - public ErrorCategory Category { get; set; } + public ErrorCategory Category { get; set; } = ErrorCategory.NotSpecified; /// /// ErrorRecord.ErrorId. diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs index efef3b5ea65..82c9c9f6557 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteAliasCommandBase.cs @@ -36,7 +36,7 @@ public class WriteAliasCommandBase : PSCmdlet /// for new aliases). /// [Parameter] - public ScopedItemOptions Option { get; set; } + public ScopedItemOptions Option { get; set; } = ScopedItemOptions.None; /// /// If set to true, the alias that is set is passed to the pipeline. From 3641aaa11c78d2e65eaa4b2c3527b550e1a98d5c Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Fri, 4 Dec 2020 09:49:05 +0000 Subject: [PATCH 3/3] revert change address @iSazonov review --- .../utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index e10f3d9345c..6102a66625d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -178,7 +178,7 @@ public abstract partial class WebRequestPSCmdlet : PSCmdlet /// Gets or sets the TLS/SSL protocol used by the Web Cmdlet. /// [Parameter] - public virtual WebSslProtocol SslProtocol { get; set; } + public virtual WebSslProtocol SslProtocol { get; set; } = WebSslProtocol.Default; /// /// Gets or sets the Token property. Token is required by Authentication OAuth and Bearer.