Skip to content

Commit 98117cd

Browse files
authored
1 parent cba73e7 commit 98117cd

28 files changed

+120
-120
lines changed

src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ protected bool IsActive()
237237
/// <param name="session"></param>
238238
protected CimSessionProxy CreateCimSessionProxy(CimSessionProxy originalProxy)
239239
{
240-
CimSessionProxy proxy = new CimSessionProxy(originalProxy);
240+
CimSessionProxy proxy = new(originalProxy);
241241
this.SubscribeEventAndAddProxytoCache(proxy);
242242
return proxy;
243243
}
@@ -259,7 +259,7 @@ protected CimSessionProxy CreateCimSessionProxy(CimSessionProxy originalProxy, b
259259
/// <param name="session"></param>
260260
protected CimSessionProxy CreateCimSessionProxy(CimSession session)
261261
{
262-
CimSessionProxy proxy = new CimSessionProxy(session);
262+
CimSessionProxy proxy = new(session);
263263
this.SubscribeEventAndAddProxytoCache(proxy);
264264
return proxy;
265265
}
@@ -282,7 +282,7 @@ protected CimSessionProxy CreateCimSessionProxy(CimSession session, bool passThr
282282
/// <param name="computerName"></param>
283283
protected CimSessionProxy CreateCimSessionProxy(string computerName)
284284
{
285-
CimSessionProxy proxy = new CimSessionProxy(computerName);
285+
CimSessionProxy proxy = new(computerName);
286286
this.SubscribeEventAndAddProxytoCache(proxy);
287287
return proxy;
288288
}
@@ -296,7 +296,7 @@ protected CimSessionProxy CreateCimSessionProxy(string computerName)
296296
/// <returns></returns>
297297
protected CimSessionProxy CreateCimSessionProxy(string computerName, CimInstance cimInstance)
298298
{
299-
CimSessionProxy proxy = new CimSessionProxy(computerName, cimInstance);
299+
CimSessionProxy proxy = new(computerName, cimInstance);
300300
this.SubscribeEventAndAddProxytoCache(proxy);
301301
return proxy;
302302
}
@@ -546,7 +546,7 @@ private void Cleanup()
546546
/// <summary>
547547
/// Lock object.
548548
/// </summary>
549-
private readonly object a_lock = new object();
549+
private readonly object a_lock = new();
550550

551551
/// <summary>
552552
/// Number of active operations.
@@ -568,7 +568,7 @@ private void Cleanup()
568568
/// <summary>
569569
/// Lock object.
570570
/// </summary>
571-
private readonly object cimSessionProxyCacheLock = new object();
571+
private readonly object cimSessionProxyCacheLock = new();
572572

573573
/// <summary>
574574
/// Cache all <see cref="CimSessionProxy"/> objects related to

src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ internal ParameterBinder(
256256
/// throw exception
257257
/// </para>
258258
/// </summary>
259-
private List<string> parametersetNamesList = new List<string>();
259+
private List<string> parametersetNamesList = new();
260260

261261
/// <summary>
262262
/// Parameter names list.
263263
/// </summary>
264-
private readonly List<string> parameterNamesList = new List<string>();
264+
private readonly List<string> parameterNamesList = new();
265265

266266
/// <summary>
267267
/// <para>
@@ -270,12 +270,12 @@ internal ParameterBinder(
270270
/// throw exception
271271
/// </para>
272272
/// </summary>
273-
private List<string> parametersetNamesListAtBeginProcess = new List<string>();
273+
private List<string> parametersetNamesListAtBeginProcess = new();
274274

275275
/// <summary>
276276
/// Parameter names list before begin process.
277277
/// </summary>
278-
private readonly List<string> parameterNamesListAtBeginProcess = new List<string>();
278+
private readonly List<string> parameterNamesListAtBeginProcess = new();
279279

280280
/// <summary>
281281
/// <para>
@@ -331,7 +331,7 @@ internal void SetParameter(string parameterName, bool isBeginProcess)
331331

332332
if (this.parametersetNamesList.Count == 0)
333333
{
334-
List<string> nameset = new List<string>();
334+
List<string> nameset = new();
335335
foreach (ParameterDefinitionEntry parameterDefinitionEntry in this.parameterDefinitionEntries[parameterName])
336336
{
337337
DebugHelper.WriteLogEx("parameterset name = '{0}'; mandatory = '{1}'", 1, parameterDefinitionEntry.ParameterSetName, parameterDefinitionEntry.IsMandatory);
@@ -370,7 +370,7 @@ internal void SetParameter(string parameterName, bool isBeginProcess)
370370
}
371371
else
372372
{
373-
List<string> nameset = new List<string>();
373+
List<string> nameset = new();
374374
foreach (ParameterDefinitionEntry entry in this.parameterDefinitionEntries[parameterName])
375375
{
376376
if (this.parametersetNamesList.Contains(entry.ParameterSetName))
@@ -418,7 +418,7 @@ internal string GetParameterSet()
418418

419419
string boundParameterSetName = null;
420420
string defaultParameterSetName = null;
421-
List<string> noMandatoryParameterSet = new List<string>();
421+
List<string> noMandatoryParameterSet = new();
422422

423423
// Looking for parameter set which have mandatory parameters
424424
foreach (string parameterSetName in this.parameterSetEntries.Keys)
@@ -687,7 +687,7 @@ protected virtual void DisposeInternal()
687687
/// <summary>
688688
/// Lock object.
689689
/// </summary>
690-
private readonly object myLock = new object();
690+
private readonly object myLock = new();
691691

692692
/// <summary>
693693
/// <para>
@@ -771,7 +771,7 @@ internal virtual CmdletOperationBase CmdletOperation
771771
/// </summary>
772772
internal void ThrowTerminatingError(Exception exception, string operation)
773773
{
774-
ErrorRecord errorRecord = new ErrorRecord(exception, operation, ErrorCategory.InvalidOperation, this);
774+
ErrorRecord errorRecord = new(exception, operation, ErrorCategory.InvalidOperation, this);
775775
this.CmdletOperation.ThrowTerminatingError(errorRecord);
776776
}
777777

@@ -909,7 +909,7 @@ internal void ThrowInvalidAuthenticationTypeError(
909909
ImpersonatedAuthenticationMechanism.Negotiate,
910910
ImpersonatedAuthenticationMechanism.Kerberos,
911911
ImpersonatedAuthenticationMechanism.NtlmDomain);
912-
PSArgumentOutOfRangeException exception = new PSArgumentOutOfRangeException(
912+
PSArgumentOutOfRangeException exception = new(
913913
parameterName, authentication, message);
914914
ThrowTerminatingError(exception, operationName);
915915
}
@@ -928,7 +928,7 @@ internal void ThrowConflictParameterWasSet(
928928
string message = string.Format(CultureInfo.CurrentUICulture,
929929
CimCmdletStrings.ConflictParameterWasSet,
930930
parameterName, conflictParameterName);
931-
PSArgumentException exception = new PSArgumentException(message, parameterName);
931+
PSArgumentException exception = new(message, parameterName);
932932
ThrowTerminatingError(exception, operationName);
933933
}
934934

@@ -944,7 +944,7 @@ internal void ThrowInvalidProperty(
944944
string operationName,
945945
IDictionary actualValue)
946946
{
947-
StringBuilder propList = new StringBuilder();
947+
StringBuilder propList = new();
948948
foreach (string property in propertiesList)
949949
{
950950
if (propList.Length > 0)
@@ -957,7 +957,7 @@ internal void ThrowInvalidProperty(
957957

958958
string message = string.Format(CultureInfo.CurrentUICulture, CimCmdletStrings.CouldNotFindPropertyFromGivenClass,
959959
className, propList);
960-
PSArgumentOutOfRangeException exception = new PSArgumentOutOfRangeException(
960+
PSArgumentOutOfRangeException exception = new(
961961
parameterName, actualValue, message);
962962
ThrowTerminatingError(exception, operationName);
963963
}

src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetAssociatedInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void GetCimAssociatedInstance(GetCimAssociatedInstanceCommand cmdlet)
4343
nameSpace = ConstValue.GetNamespace(cmdlet.CimInstance.CimSystemProperties.Namespace);
4444
}
4545

46-
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
46+
List<CimSessionProxy> proxys = new();
4747
switch (cmdlet.ParameterSetName)
4848
{
4949
case CimBaseCommand.ComputerSetName:

src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetCimClass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ public CimGetCimClass()
121121
/// <param name="cmdlet"><see cref="GetCimClassCommand"/> object.</param>
122122
public void GetCimClass(GetCimClassCommand cmdlet)
123123
{
124-
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
124+
List<CimSessionProxy> proxys = new();
125125
string nameSpace = ConstValue.GetNamespace(cmdlet.Namespace);
126126
string className = (cmdlet.ClassName == null) ? @"*" : cmdlet.ClassName;
127-
CimGetCimClassContext context = new CimGetCimClassContext(
127+
CimGetCimClassContext context = new(
128128
cmdlet.ClassName,
129129
cmdlet.MethodName,
130130
cmdlet.PropertyName,

src/Microsoft.Management.Infrastructure.CimCmdlets/CimGetInstance.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected void GetCimInstanceInternal(CimBaseCommand cmdlet)
8181
IEnumerable<string> computerNames = ConstValue.GetComputerNames(
8282
GetComputerName(cmdlet));
8383
string nameSpace;
84-
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
84+
List<CimSessionProxy> proxys = new();
8585
bool isGetCimInstanceCommand = (cmdlet is GetCimInstanceCommand);
8686
CimInstance targetCimInstance = null;
8787
switch (cmdlet.ParameterSetName)
@@ -301,7 +301,7 @@ protected static string CreateQuery(CimBaseCommand cmdlet)
301301
GetCimInstanceCommand cmd = cmdlet as GetCimInstanceCommand;
302302
if (cmd != null)
303303
{
304-
StringBuilder propertyList = new StringBuilder();
304+
StringBuilder propertyList = new();
305305
if (cmd.SelectProperties == null)
306306
{
307307
propertyList.Append('*');
@@ -397,7 +397,7 @@ private void SetSessionProxyProperties(
397397
proxy.ResourceUri = removeCimInstance.ResourceUri;
398398
}
399399

400-
CimRemoveCimInstanceContext context = new CimRemoveCimInstanceContext(
400+
CimRemoveCimInstanceContext context = new(
401401
ConstValue.GetNamespace(removeCimInstance.Namespace),
402402
proxy);
403403
proxy.ContextObject = context;
@@ -411,7 +411,7 @@ private void SetSessionProxyProperties(
411411
proxy.ResourceUri = setCimInstance.ResourceUri;
412412
}
413413

414-
CimSetCimInstanceContext context = new CimSetCimInstanceContext(
414+
CimSetCimInstanceContext context = new(
415415
ConstValue.GetNamespace(setCimInstance.Namespace),
416416
setCimInstance.Property,
417417
proxy,

src/Microsoft.Management.Infrastructure.CimCmdlets/CimInvokeCimMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void InvokeCimMethod(InvokeCimMethodCommand cmdlet)
9292
{
9393
IEnumerable<string> computerNames = ConstValue.GetComputerNames(cmdlet.ComputerName);
9494
string nameSpace;
95-
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
95+
List<CimSessionProxy> proxys = new();
9696
string action = string.Format(CultureInfo.CurrentUICulture, actionTemplate, cmdlet.MethodName);
9797

9898
switch (cmdlet.ParameterSetName)
@@ -194,7 +194,7 @@ public void InvokeCimMethod(InvokeCimMethodCommand cmdlet)
194194
foreach (CimSessionProxy proxy in proxys)
195195
{
196196
// create context object
197-
CimInvokeCimMethodContext context = new CimInvokeCimMethodContext(
197+
CimInvokeCimMethodContext context = new(
198198
nameSpace,
199199
cmdlet.MethodName,
200200
paramsCollection,

src/Microsoft.Management.Infrastructure.CimCmdlets/CimNewCimInstance.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void NewCimInstance(NewCimInstanceCommand cmdlet)
133133
}
134134

135135
// create ciminstance on server
136-
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
136+
List<CimSessionProxy> proxys = new();
137137

138138
switch (cmdlet.ParameterSetName)
139139
{
@@ -267,13 +267,13 @@ private CimInstance CreateCimInstance(
267267
IDictionary properties,
268268
NewCimInstanceCommand cmdlet)
269269
{
270-
CimInstance cimInstance = new CimInstance(className, cimNamespace);
270+
CimInstance cimInstance = new(className, cimNamespace);
271271
if (properties == null)
272272
{
273273
return cimInstance;
274274
}
275275

276-
List<string> keys = new List<string>();
276+
List<string> keys = new();
277277
if (key != null)
278278
{
279279
foreach (string keyName in key)
@@ -331,13 +331,13 @@ private CimInstance CreateCimInstance(
331331
IDictionary properties,
332332
NewCimInstanceCommand cmdlet)
333333
{
334-
CimInstance cimInstance = new CimInstance(cimClass);
334+
CimInstance cimInstance = new(cimClass);
335335
if (properties == null)
336336
{
337337
return cimInstance;
338338
}
339339

340-
List<string> notfoundProperties = new List<string>();
340+
List<string> notfoundProperties = new();
341341
foreach (string property in properties.Keys)
342342
{
343343
if (cimInstance.CimInstanceProperties[property] == null)

src/Microsoft.Management.Infrastructure.CimCmdlets/CimRemoveCimInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet)
6060

6161
IEnumerable<string> computerNames = ConstValue.GetComputerNames(
6262
GetComputerName(cmdlet));
63-
List<CimSessionProxy> proxys = new List<CimSessionProxy>();
63+
List<CimSessionProxy> proxys = new();
6464
switch (cmdlet.ParameterSetName)
6565
{
6666
case CimBaseCommand.CimInstanceComputerSet:

src/Microsoft.Management.Infrastructure.CimCmdlets/CimResultObserver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public virtual void OnCompleted()
259259
// OnNext, OnError
260260
try
261261
{
262-
AsyncResultCompleteEventArgs completeArgs = new AsyncResultCompleteEventArgs(
262+
AsyncResultCompleteEventArgs completeArgs = new(
263263
this.session, this.observable);
264264
this.OnNewResult(this, completeArgs);
265265
}
@@ -280,7 +280,7 @@ public virtual void OnError(Exception error)
280280
{
281281
try
282282
{
283-
AsyncResultErrorEventArgs errorArgs = new AsyncResultErrorEventArgs(
283+
AsyncResultErrorEventArgs errorArgs = new(
284284
this.session, this.observable, error, this.context);
285285
this.OnNewResult(this, errorArgs);
286286
}
@@ -300,7 +300,7 @@ protected void OnNextCore(object value)
300300
DebugHelper.WriteLogEx("value = {0}.", 1, value);
301301
try
302302
{
303-
AsyncResultObjectEventArgs resultArgs = new AsyncResultObjectEventArgs(
303+
AsyncResultObjectEventArgs resultArgs = new(
304304
this.session, this.observable, value);
305305
this.OnNewResult(this, resultArgs);
306306
}

0 commit comments

Comments
 (0)