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
2 changes: 1 addition & 1 deletion .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void GetCimClass(GetCimClassCommand cmdlet)
{
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ internal void GetCimInstance(CimInstance cimInstance, XOperationContextBase cont
}

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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ internal void AddSessionToCache(CimSession cimSession, XOperationContextBase con
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();
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal static bool IsDefaultComputerName(string computerName)
/// <returns></returns>
internal static IEnumerable<string> GetComputerNames(IEnumerable<string> computerNames)
{
return (computerNames == null) ? NullComputerNames : computerNames;
return computerNames ?? NullComputerNames;
}

/// <summary>
Expand All @@ -110,7 +110,7 @@ internal static string GetComputerName(string computerName)
/// <returns></returns>
internal static string GetNamespace(string nameSpace)
{
return (nameSpace == null) ? DefaultNameSpace : nameSpace;
return nameSpace ?? DefaultNameSpace;
}

/// <summary>
Expand All @@ -122,7 +122,7 @@ internal static string GetNamespace(string nameSpace)
/// <returns></returns>
internal static string GetQueryDialectWithDefault(string queryDialect)
{
return (queryDialect == null) ? DefaultQueryDialect : queryDialect;
return queryDialect ?? DefaultQueryDialect;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ protected void ProcessReaderThread(object state)
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);

Expand Down Expand Up @@ -1784,7 +1784,7 @@ private void ProcessErrorThread(object state)
}
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);

Expand Down Expand Up @@ -1908,7 +1908,7 @@ private void ProcessReaderThread(object state)
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);
}
Expand Down Expand Up @@ -2035,7 +2035,7 @@ private void ProcessReaderThread(object state)
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ private PSDataCollection<PSObject> InvokePowerShell(PowerShell powershell, Runsp
Exception lastException = errorList[0] as Exception;
if (lastException != null)
{
exceptionThrown = (lastException.Message != null) ? lastException.Message : string.Empty;
exceptionThrown = lastException.Message ?? string.Empty;
}
else
{
Expand Down