mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Enable IDE0029: UseCoalesceExpression (#15770)
Enable [IDE0029: UseCoalesceExpression](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0029)
This commit is contained in:
+1
-1
@@ -1200,7 +1200,7 @@ dotnet_diagnostic.IDE0028.severity = silent
|
||||
|
||||
# IDE0029: UseCoalesceExpression
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0029
|
||||
dotnet_diagnostic.IDE0029.severity = silent
|
||||
dotnet_diagnostic.IDE0029.severity = warning
|
||||
|
||||
# IDE0030: UseCoalesceExpressionForNullable
|
||||
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0030
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
{
|
||||
List<CimSessionProxy> proxys = new();
|
||||
string nameSpace = ConstValue.GetNamespace(cmdlet.Namespace);
|
||||
string className = (cmdlet.ClassName == null) ? @"*" : cmdlet.ClassName;
|
||||
string className = cmdlet.ClassName ?? @"*";
|
||||
CimGetCimClassContext context = new(
|
||||
cmdlet.ClassName,
|
||||
cmdlet.MethodName,
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
}
|
||||
|
||||
CimSessionProxy proxy = CreateCimSessionProxy(newCimInstanceContext.Proxy);
|
||||
string nameSpace = (cimInstance.CimSystemProperties.Namespace == null) ? newCimInstanceContext.Namespace : cimInstance.CimSystemProperties.Namespace;
|
||||
string nameSpace = cimInstance.CimSystemProperties.Namespace ?? newCimInstanceContext.Namespace;
|
||||
proxy.GetInstanceAsync(nameSpace, cimInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -951,7 +951,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
CimTestCimSessionContext testCimSessionContext = context as CimTestCimSessionContext;
|
||||
uint sessionId = this.sessionState.GenerateSessionId();
|
||||
string originalSessionName = testCimSessionContext.CimSessionWrapper.Name;
|
||||
string sessionName = (originalSessionName != null) ? originalSessionName : string.Format(CultureInfo.CurrentUICulture, @"{0}{1}", CimSessionState.CimSessionClassName, sessionId);
|
||||
string sessionName = originalSessionName ?? string.Format(CultureInfo.CurrentUICulture, @"{0}{1}", CimSessionState.CimSessionClassName, sessionId);
|
||||
|
||||
// detach CimSession from the proxy object
|
||||
CimSession createdCimSession = testCimSessionContext.Proxy.Detach();
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
/// <returns></returns>
|
||||
internal static IEnumerable<string> GetComputerNames(IEnumerable<string> computerNames)
|
||||
{
|
||||
return (computerNames == null) ? NullComputerNames : computerNames;
|
||||
return computerNames ?? NullComputerNames;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,7 +110,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
/// <returns></returns>
|
||||
internal static string GetNamespace(string nameSpace)
|
||||
{
|
||||
return (nameSpace == null) ? DefaultNameSpace : nameSpace;
|
||||
return nameSpace ?? DefaultNameSpace;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,7 +122,7 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets
|
||||
/// <returns></returns>
|
||||
internal static string GetQueryDialectWithDefault(string queryDialect)
|
||||
{
|
||||
return (queryDialect == null) ? DefaultQueryDialect : queryDialect;
|
||||
return queryDialect ?? DefaultQueryDialect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1422,7 +1422,7 @@ namespace System.Management.Automation.Remoting.Client
|
||||
Dbg.Assert(false, "Need to adjust transport fragmentor to accomodate read buffer size.");
|
||||
}
|
||||
|
||||
string errorMsg = (e.Message != null) ? e.Message : string.Empty;
|
||||
string errorMsg = e.Message ?? string.Empty;
|
||||
_tracer.WriteMessage("HyperVSocketClientSessionTransportManager", "StartReaderThread", Guid.Empty,
|
||||
"Transport manager reader thread ended with error: {0}", errorMsg);
|
||||
|
||||
@@ -1784,7 +1784,7 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string errorMsg = (e.Message != null) ? e.Message : string.Empty;
|
||||
string errorMsg = e.Message ?? string.Empty;
|
||||
_tracer.WriteMessage("SSHClientSessionTransportManager", "ProcessErrorThread", Guid.Empty,
|
||||
"Transport manager error thread ended with error: {0}", errorMsg);
|
||||
|
||||
@@ -1908,7 +1908,7 @@ namespace System.Management.Automation.Remoting.Client
|
||||
Dbg.Assert(false, "Need to adjust transport fragmentor to accomodate read buffer size.");
|
||||
}
|
||||
|
||||
string errorMsg = (e.Message != null) ? e.Message : string.Empty;
|
||||
string errorMsg = e.Message ?? string.Empty;
|
||||
_tracer.WriteMessage("SSHClientSessionTransportManager", "ProcessReaderThread", Guid.Empty,
|
||||
"Transport manager reader thread ended with error: {0}", errorMsg);
|
||||
}
|
||||
@@ -2035,7 +2035,7 @@ namespace System.Management.Automation.Remoting.Client
|
||||
Dbg.Assert(false, "Need to adjust transport fragmentor to accommodate read buffer size.");
|
||||
}
|
||||
|
||||
string errorMsg = (e.Message != null) ? e.Message : string.Empty;
|
||||
string errorMsg = e.Message ?? string.Empty;
|
||||
_tracer.WriteMessage("NamedPipeClientSessionTransportManager", "StartReaderThread", Guid.Empty,
|
||||
"Transport manager reader thread ended with error: {0}", errorMsg);
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ namespace System.Management.Automation
|
||||
Exception lastException = errorList[0] as Exception;
|
||||
if (lastException != null)
|
||||
{
|
||||
exceptionThrown = (lastException.Message != null) ? lastException.Message : string.Empty;
|
||||
exceptionThrown = lastException.Message ?? string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user