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 @@ -946,7 +946,7 @@ dotnet_diagnostic.IDE0072.severity = silent
dotnet_diagnostic.IDE0073.severity = suggestion

# IDE0074: UseCoalesceCompoundAssignment
dotnet_diagnostic.IDE0074.severity = silent
dotnet_diagnostic.IDE0074.severity = warning

# IDE0075: SimplifyConditionalExpression
dotnet_diagnostic.IDE0075.severity = silent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected virtual void Dispose(bool disposing)
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
protected TSession[] Session
{
get { return _session ?? (_session = new TSession[] { this.DefaultSession }); }
get { return _session ??= new TSession[] { this.DefaultSession }; }

set
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ internal CimCmdletInvocationContext CmdletInvocationContext
{
get
{
return _cmdletInvocationContext ??
(_cmdletInvocationContext = new CimCmdletInvocationContext(
this.CmdletDefinitionContext,
this.Cmdlet,
this.GetDynamicNamespace()));
return _cmdletInvocationContext ??= new CimCmdletInvocationContext(
this.CmdletDefinitionContext,
this.Cmdlet,
this.GetDynamicNamespace());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public string Filename
return s_inputStream;
}

return _filename ?? (_filename = System.IO.Path.GetFileName(_path));
return _filename ??= System.IO.Path.GetFileName(_path);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ public override PSObject PrivateData
get
{
if (ui == null) return null;
return _consoleColorProxy ?? (_consoleColorProxy = PSObject.AsPSObject(new ConsoleColorProxy(ui)));
return _consoleColorProxy ??= PSObject.AsPSObject(new ConsoleColorProxy(ui));
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/System.Management.Automation/DscSupport/CimDSCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3709,8 +3709,7 @@ private static ScriptBlock CimKeywordImplementationFunction
get
{
// The scriptblock cache will handle mutual exclusion
return s_cimKeywordImplementationFunction ??
(s_cimKeywordImplementationFunction = ScriptBlock.Create(CimKeywordImplementationFunctionText));
return s_cimKeywordImplementationFunction ??= ScriptBlock.Create(CimKeywordImplementationFunctionText);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public OutputTypeAttribute(params string[] type)
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public string[] ParameterSetName
{
get => _parameterSetName ?? (_parameterSetName = new[] { ParameterAttribute.AllParameterSets });
get => _parameterSetName ??= new[] { ParameterAttribute.AllParameterSets };

set => _parameterSetName = value;
}
Expand Down
3 changes: 1 addition & 2 deletions src/System.Management.Automation/engine/CmdletInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,7 @@ internal override CommandMetadata CommandMetadata
{
get
{
return _cmdletMetadata ??
(_cmdletMetadata = CommandMetadata.Get(this.Name, this.ImplementingType, Context));
return _cmdletMetadata ??= CommandMetadata.Get(this.Name, this.ImplementingType, Context);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3928,8 +3928,7 @@ private HashSet<string> BoundObsoleteParameterNames
{
get
{
return _boundObsoleteParameterNames ??
(_boundObsoleteParameterNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase));
return _boundObsoleteParameterNames ??= new HashSet<string>(StringComparer.OrdinalIgnoreCase);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal InternalCommand()
/// <value>The invocation object for this command.</value>
internal InvocationInfo MyInvocation
{
get { return _myInvocation ?? (_myInvocation = new InvocationInfo(this)); }
get { return _myInvocation ??= new InvocationInfo(this); }
}

/// <summary>
Expand Down Expand Up @@ -470,7 +470,7 @@ public ProviderIntrinsics InvokeProvider
{
using (PSTransactionManager.GetEngineProtectionScope())
{
return _invokeProvider ?? (_invokeProvider = new ProviderIntrinsics(this));
return _invokeProvider ??= new ProviderIntrinsics(this);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ internal LookupPathCollection GetLookupDirectoryPaths()
}

// Cache the new lookup paths
return _cachedLookupPaths ?? (_cachedLookupPaths = result);
return _cachedLookupPaths ??= result;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/CommandInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public virtual Dictionary<string, ParameterMetadata> Parameters

internal CommandMetadata ExternalCommandMetadata
{
get { return _externalCommandMetadata ?? (_externalCommandMetadata = new CommandMetadata(this, true)); }
get { return _externalCommandMetadata ??= new CommandMetadata(this, true); }

set { _externalCommandMetadata = value; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public SessionState SessionState
/// </summary>
public CommandInvocationIntrinsics InvokeCommand
{
get { return _invokeCommand ?? (_invokeCommand = new CommandInvocationIntrinsics(_context)); }
get { return _invokeCommand ??= new CommandInvocationIntrinsics(_context); }
}

#endregion Public methods
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/ErrorPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ internal void SetTargetObject(object target)
/// for that ErrorCategory.
/// </summary>
/// <value>never null</value>
public ErrorCategoryInfo CategoryInfo { get => _categoryInfo ?? (_categoryInfo = new ErrorCategoryInfo(this)); }
public ErrorCategoryInfo CategoryInfo { get => _categoryInfo ??= new ErrorCategoryInfo(this); }

private ErrorCategoryInfo _categoryInfo;

Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ internal bool GetBooleanPreference(VariablePath preferenceVariablePath, bool def
/// <value></value>
internal HelpSystem HelpSystem
{
get { return _helpSystem ?? (_helpSystem = new HelpSystem(this)); }
get { return _helpSystem ??= new HelpSystem(this); }
}

private HelpSystem _helpSystem;
Expand Down Expand Up @@ -744,7 +744,7 @@ internal InternalHost InternalHost
/// </summary>
internal EngineIntrinsics EngineIntrinsics
{
get { return _engineIntrinsics ?? (_engineIntrinsics = new EngineIntrinsics(this)); }
get { return _engineIntrinsics ??= new EngineIntrinsics(this); }
}

private EngineIntrinsics _engineIntrinsics;
Expand Down
5 changes: 2 additions & 3 deletions src/System.Management.Automation/engine/ExternalScriptInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ internal override CommandMetadata CommandMetadata
{
get
{
return _commandMetadata ??
(_commandMetadata =
new CommandMetadata(this.ScriptBlock, this.Name, LocalPipeline.GetExecutionContextFromTLS()));
return _commandMetadata ??=
new CommandMetadata(this.ScriptBlock, this.Name, LocalPipeline.GetExecutionContextFromTLS());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/System.Management.Automation/engine/FunctionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,8 @@ internal override CommandMetadata CommandMetadata
{
get
{
return _commandMetadata ??
(_commandMetadata =
new CommandMetadata(this.ScriptBlock, this.Name, LocalPipeline.GetExecutionContextFromTLS()));
return _commandMetadata ??=
new CommandMetadata(this.ScriptBlock, this.Name, LocalPipeline.GetExecutionContextFromTLS());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/InformationRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal InformationRecord(InformationRecord baseRecord)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public List<string> Tags
{
get { return _tags ?? (_tags = new List<string>()); }
get { return _tags ??= new List<string>(); }

internal set { _tags = value; }
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public string User
[DataMember]
public string Computer
{
get { return this._computerName ?? (this._computerName = PsUtils.GetHostName()); }
get { return this._computerName ??= PsUtils.GetHostName(); }

set { this._computerName = value; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ public override InitialSessionStateEntry Clone()
/// </summary>
public Collection<Attribute> Attributes
{
get { return _attributes ?? (_attributes = new Collection<Attribute>()); }
get { return _attributes ??= new Collection<Attribute>(); }
}

private Collection<Attribute> _attributes;
Expand Down
5 changes: 2 additions & 3 deletions src/System.Management.Automation/engine/InvocationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ public Dictionary<string, object> BoundParameters
{
get
{
return _boundParameters ??
(_boundParameters = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase));
return _boundParameters ??= new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
}

internal set { _boundParameters = value; }
Expand All @@ -213,7 +212,7 @@ public Dictionary<string, object> BoundParameters
/// </summary>
public List<object> UnboundArguments
{
get { return _unboundArguments ?? (_unboundArguments = new List<object>()); }
get { return _unboundArguments ??= new List<object>(); }

internal set { _unboundArguments = value; }
}
Expand Down
12 changes: 4 additions & 8 deletions src/System.Management.Automation/engine/Modules/PSModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ public string ModuleBase
{
get
{
return _moduleBase ??
(_moduleBase = !string.IsNullOrEmpty(Path) ? IO.Path.GetDirectoryName(Path) : string.Empty);
return _moduleBase ??= !string.IsNullOrEmpty(Path) ? IO.Path.GetDirectoryName(Path) : string.Empty;
}
}

Expand Down Expand Up @@ -922,8 +921,7 @@ public ReadOnlyCollection<PSModuleInfo> NestedModules
{
get
{
return _readonlyNestedModules ??
(_readonlyNestedModules = new ReadOnlyCollection<PSModuleInfo>(_nestedModules));
return _readonlyNestedModules ??= new ReadOnlyCollection<PSModuleInfo>(_nestedModules);
}
}

Expand Down Expand Up @@ -1014,8 +1012,7 @@ public ReadOnlyCollection<PSModuleInfo> RequiredModules
{
get
{
return _readonlyRequiredModules ??
(_readonlyRequiredModules = new ReadOnlyCollection<PSModuleInfo>(_requiredModules));
return _readonlyRequiredModules ??= new ReadOnlyCollection<PSModuleInfo>(_requiredModules);
}
}

Expand All @@ -1040,8 +1037,7 @@ internal ReadOnlyCollection<ModuleSpecification> RequiredModulesSpecification
{
get
{
return _readonlyRequiredModulesSpecification ??
(_readonlyRequiredModulesSpecification = new ReadOnlyCollection<ModuleSpecification>(_requiredModulesSpecification));
return _readonlyRequiredModulesSpecification ??= new ReadOnlyCollection<ModuleSpecification>(_requiredModulesSpecification);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/MshCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ public CommandInvocationIntrinsics InvokeCommand
{
using (PSTransactionManager.GetEngineProtectionScope())
{
return _invokeCommand ?? (_invokeCommand = new CommandInvocationIntrinsics(Context, this));
return _invokeCommand ??= new CommandInvocationIntrinsics(Context, this);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/System.Management.Automation/engine/MshCommandRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public override string ToString()
/// <value>The invocation object for this command.</value>
internal InvocationInfo MyInvocation
{
get { return _myInvocation ?? (_myInvocation = _thisCommand.MyInvocation); }
get { return _myInvocation ??= _thisCommand.MyInvocation; }
}

/// <summary>
Expand Down Expand Up @@ -2206,7 +2206,7 @@ internal void SetMergeFromRuntime(MshCommandRuntime fromRuntime)
/// </summary>
internal Pipe InputPipe
{
get { return _inputPipe ?? (_inputPipe = new Pipe()); }
get { return _inputPipe ??= new Pipe(); }

set { _inputPipe = value; }
}
Expand All @@ -2216,7 +2216,7 @@ internal Pipe InputPipe
/// </summary>
internal Pipe OutputPipe
{
get { return _outputPipe ?? (_outputPipe = new Pipe()); }
get { return _outputPipe ??= new Pipe(); }

set { _outputPipe = value; }
}
Expand All @@ -2239,7 +2239,7 @@ internal object[] GetResultsAsArray()
/// </summary>
internal Pipe ErrorOutputPipe
{
get { return _errorOutputPipe ?? (_errorOutputPipe = new Pipe()); }
get { return _errorOutputPipe ??= new Pipe(); }

set { _errorOutputPipe = value; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ internal object Target
/// </summary>
internal CommandLineParameters CommandLineParameters
{
get { return _commandLineParameters ?? (_commandLineParameters = new CommandLineParameters()); }
get { return _commandLineParameters ??= new CommandLineParameters(); }

// Setter is needed to pass into RuntimeParameterBinder instances
set { _commandLineParameters = value; }
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/PathInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ private LocationGlobber PathResolver
_sessionState != null,
"The only constructor for this class should always set the sessionState field");

return _pathResolver ?? (_pathResolver = _sessionState.ExecutionContext.LocationGlobber);
return _pathResolver ??= _sessionState.ExecutionContext.LocationGlobber;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ internal override void BindParameter(string name, object value, CompiledCommandP
try
{
var setter = parameterMetadata != null
? (parameterMetadata.Setter ?? (parameterMetadata.Setter = GetSetter(Target.GetType(), name)))
? (parameterMetadata.Setter ??= GetSetter(Target.GetType(), name))
: GetSetter(Target.GetType(), name);
setter(Target, value);
}
Expand Down
5 changes: 2 additions & 3 deletions src/System.Management.Automation/engine/ScriptInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ internal override CommandMetadata CommandMetadata
{
get
{
return _commandMetadata ??
(_commandMetadata =
new CommandMetadata(this.ScriptBlock, this.Name, LocalPipeline.GetExecutionContextFromTLS()));
return _commandMetadata ??=
new CommandMetadata(this.ScriptBlock, this.Name, LocalPipeline.GetExecutionContextFromTLS());
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/System.Management.Automation/engine/SessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal void InitializeSessionStateInternalSpecialVariables(bool clearVariables
/// </summary>
internal LocationGlobber Globber
{
get { return _globberPrivate ?? (_globberPrivate = ExecutionContext.LocationGlobber); }
get { return _globberPrivate ??= ExecutionContext.LocationGlobber; }
}

private LocationGlobber _globberPrivate;
Expand All @@ -158,7 +158,7 @@ internal LocationGlobber Globber
/// </summary>
internal SessionState PublicSessionState
{
get { return _publicSessionState ?? (_publicSessionState = new SessionState(this)); }
get { return _publicSessionState ??= new SessionState(this); }

set { _publicSessionState = value; }
}
Expand All @@ -170,7 +170,7 @@ internal SessionState PublicSessionState
/// </summary>
internal ProviderIntrinsics InvokeProvider
{
get { return _invokeProvider ?? (_invokeProvider = new ProviderIntrinsics(this)); }
get { return _invokeProvider ??= new ProviderIntrinsics(this); }
}

private ProviderIntrinsics _invokeProvider;
Expand Down
Loading