Enable IDE0030: UseCoalesceExpressionForNullable (#14289)

This commit is contained in:
xtqqczze authored and GitHub committed 2021-07-13 10:13:49 -07:00
1 parent bfb4a818bf
commit 00bc0f6d29
5 files changed
+9 -15

No files matched your search

+1 -1
View File
@@ -1204,7 +1204,7 @@ dotnet_diagnostic.IDE0029.severity = silent
# IDE0030: UseCoalesceExpressionForNullable
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0030
dotnet_diagnostic.IDE0030.severity = silent
dotnet_diagnostic.IDE0030.severity = warning
# IDE0031: UseNullPropagation
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031
@@ -160,7 +160,7 @@ namespace Microsoft.PowerShell.Commands
[Parameter]
public ProcessorArchitecture ProcessorArchitecture
{
get { return _processorArchitecture.HasValue ? _processorArchitecture.Value : ProcessorArchitecture.None; }
get { return _processorArchitecture ?? ProcessorArchitecture.None; }
set { _processorArchitecture = value; }
}
@@ -3521,9 +3521,7 @@ namespace System.Management.Automation
ActionPreference preference;
if (_batchInvocationSettings != null)
{
preference = (_batchInvocationSettings.ErrorActionPreference.HasValue) ?
_batchInvocationSettings.ErrorActionPreference.Value
: ActionPreference.Continue;
preference = _batchInvocationSettings.ErrorActionPreference ?? ActionPreference.Continue;
}
else
{
@@ -136,8 +136,7 @@ namespace Microsoft.PowerShell.Commands
{
get
{
return _openTimeout.HasValue ? _openTimeout.Value :
RunspaceConnectionInfo.DefaultOpenTimeout;
return _openTimeout ?? RunspaceConnectionInfo.DefaultOpenTimeout;
}
set
@@ -164,8 +163,7 @@ namespace Microsoft.PowerShell.Commands
{
get
{
return _cancelTimeout.HasValue ? _cancelTimeout.Value :
BaseTransportManager.ClientCloseTimeoutMs;
return _cancelTimeout ?? BaseTransportManager.ClientCloseTimeoutMs;
}
set
@@ -189,8 +187,7 @@ namespace Microsoft.PowerShell.Commands
{
get
{
return _idleTimeout.HasValue ? _idleTimeout.Value
: RunspaceConnectionInfo.DefaultIdleTimeout;
return _idleTimeout ?? RunspaceConnectionInfo.DefaultIdleTimeout;
}
set
@@ -299,8 +296,7 @@ namespace Microsoft.PowerShell.Commands
{
get
{
return (_operationtimeout.HasValue ? _operationtimeout.Value :
BaseTransportManager.ClientDefaultOperationTimeoutMs);
return _operationtimeout ?? BaseTransportManager.ClientDefaultOperationTimeoutMs;
}
set
@@ -168,7 +168,7 @@ namespace System.Management.Automation
// The default server settings is to make new commands execute in the calling thread...this saves
// thread switching time and thread pool pressure on the service.
// Users can override the server settings only if they are administrators
PSThreadOptions serverThreadOptions = configData.ShellThreadOptions.HasValue ? configData.ShellThreadOptions.Value : PSThreadOptions.UseCurrentThread;
PSThreadOptions serverThreadOptions = configData.ShellThreadOptions ?? PSThreadOptions.UseCurrentThread;
if (threadOptions == PSThreadOptions.Default || threadOptions == serverThreadOptions)
{
RunspacePool.ThreadOptions = serverThreadOptions;
@@ -184,7 +184,7 @@ namespace System.Management.Automation
}
// Set Thread ApartmentState for this RunspacePool
ApartmentState serverApartmentState = configData.ShellThreadApartmentState.HasValue ? configData.ShellThreadApartmentState.Value : Runspace.DefaultApartmentState;
ApartmentState serverApartmentState = configData.ShellThreadApartmentState ?? Runspace.DefaultApartmentState;
if (apartmentState == ApartmentState.Unknown || apartmentState == serverApartmentState)
{