Skip to content

Commit f023521

Browse files
committed
Reformat
1 parent 44e84fb commit f023521

8 files changed

Lines changed: 96 additions & 99 deletions

File tree

src/Microsoft.PowerShell.Security/security/AclCommands.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ internal CmdletProviderContext CmdletProviderContext
8787
{
8888
get
8989
{
90-
CmdletProviderContext coreCommandContext =
91-
new(this);
90+
CmdletProviderContext coreCommandContext = new(this);
9291

9392
Collection<string> includeFilter =
9493
SessionStateUtilities.ConvertArrayToCollection<string>(Include);
@@ -1427,8 +1426,7 @@ protected override void ProcessRecord()
14271426
pSacl = GetSaclWithCapId(CentralAccessPolicy);
14281427
if (pSacl == IntPtr.Zero)
14291428
{
1430-
SystemException e = new(
1431-
UtilsStrings.GetSaclWithCapIdFail);
1429+
SystemException e = new(UtilsStrings.GetSaclWithCapIdFail);
14321430
WriteError(new ErrorRecord(e,
14331431
"SetAcl_CentralAccessPolicy",
14341432
ErrorCategory.InvalidResult,
@@ -1441,8 +1439,7 @@ protected override void ProcessRecord()
14411439
pSacl = GetEmptySacl();
14421440
if (pSacl == IntPtr.Zero)
14431441
{
1444-
SystemException e = new(
1445-
UtilsStrings.GetEmptySaclFail);
1442+
SystemException e = new(UtilsStrings.GetEmptySaclFail);
14461443
WriteError(new ErrorRecord(e,
14471444
"SetAcl_ClearCentralAccessPolicy",
14481445
ErrorCategory.InvalidResult,
@@ -1496,8 +1493,7 @@ protected override void ProcessRecord()
14961493
IntPtr pToken = GetTokenWithEnabledPrivilege("SeSecurityPrivilege", previousState);
14971494
if (pToken == IntPtr.Zero)
14981495
{
1499-
SystemException e = new(
1500-
UtilsStrings.GetTokenWithEnabledPrivilegeFail);
1496+
SystemException e = new(UtilsStrings.GetTokenWithEnabledPrivilegeFail);
15011497
WriteError(new ErrorRecord(e,
15021498
"SetAcl_AdjustTokenPrivileges",
15031499
ErrorCategory.InvalidResult,

src/Microsoft.PowerShell.Security/security/CertificateCommands.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ protected override void ProcessRecord()
160160
}
161161
catch (CryptographicException e)
162162
{
163-
ErrorRecord er =
164-
new(e,
165-
"GetPfxCertificateUnknownCryptoError",
166-
ErrorCategory.NotSpecified,
167-
null);
163+
ErrorRecord er = new(
164+
e,
165+
"GetPfxCertificateUnknownCryptoError",
166+
ErrorCategory.NotSpecified,
167+
targetObject: null);
168168
WriteError(er);
169169
continue;
170170
}

src/Microsoft.PowerShell.Security/security/CertificateProvider.cs

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -664,17 +664,15 @@ public CertificateProvider()
664664
//
665665
// create and cache CurrentUser store-location
666666
//
667-
X509StoreLocation user =
668-
new(StoreLocation.CurrentUser);
667+
X509StoreLocation user = new(StoreLocation.CurrentUser);
669668
s_storeLocations.Add(user);
670669
AddItemToCache(nameof(StoreLocation.CurrentUser),
671670
user);
672671

673672
//
674673
// create and cache LocalMachine store-location
675674
//
676-
X509StoreLocation machine =
677-
new(StoreLocation.LocalMachine);
675+
X509StoreLocation machine = new(StoreLocation.LocalMachine);
678676
s_storeLocations.Add(machine);
679677
AddItemToCache(nameof(StoreLocation.LocalMachine),
680678
machine);
@@ -997,9 +995,7 @@ protected override void NewItem(
997995
fResult = Security.NativeMethods.CertCloseStore(hCertStore, 0);
998996
}
999997

1000-
X509Store outStore = new(
1001-
pathElements[1],
1002-
StoreLocation.LocalMachine);
998+
X509Store outStore = new(pathElements[1], StoreLocation.LocalMachine);
1003999
WriteItemObject(outStore, path, true);
10041000
}
10051001

@@ -1016,13 +1012,12 @@ protected override Collection<PSDriveInfo> InitializeDefaultDrives()
10161012
{
10171013
string providerDescription = CertificateProviderStrings.CertProvidername;
10181014

1019-
PSDriveInfo drive =
1020-
new(
1021-
"Cert", // drive name
1022-
ProviderInfo,// provider name
1023-
@"\", // root path
1024-
providerDescription,
1025-
null);
1015+
PSDriveInfo drive = new(
1016+
name: "Cert",
1017+
provider: ProviderInfo,
1018+
root: @"\",
1019+
providerDescription,
1020+
credential: null);
10261021

10271022
Collection<PSDriveInfo> drives = new();
10281023
drives.Add(drive);
@@ -1274,9 +1269,7 @@ protected override void GetItem(string path)
12741269
if (store != null)
12751270
{
12761271
// create X509Store
1277-
X509Store outStore = new(
1278-
store.StoreName,
1279-
store.Location.Location);
1272+
X509Store outStore = new(store.StoreName, store.Location.Location);
12801273
WriteItemObject(outStore, path, isContainer);
12811274
}
12821275
}
@@ -1506,11 +1499,11 @@ private static ErrorRecord CreateErrorRecord(string path,
15061499
break;
15071500
}
15081501

1509-
ErrorRecord er =
1510-
new(e,
1511-
"CertProviderItemNotFound",
1512-
ErrorCategory.ObjectNotFound,
1513-
null);
1502+
ErrorRecord er = new(
1503+
e,
1504+
"CertProviderItemNotFound",
1505+
ErrorCategory.ObjectNotFound,
1506+
targetObject: null);
15141507

15151508
er.ErrorDetails = ed;
15161509

@@ -1543,10 +1536,10 @@ private void ThrowErrorRemoting(int stat)
15431536
private void ThrowInvalidOperation(string errorId, string message)
15441537
{
15451538
ErrorRecord errorRecord = new(
1546-
new InvalidOperationException(message),
1547-
errorId,
1548-
ErrorCategory.InvalidOperation,
1549-
null);
1539+
new InvalidOperationException(message),
1540+
errorId,
1541+
ErrorCategory.InvalidOperation,
1542+
targetObject: null);
15501543
errorRecord.ErrorDetails = new ErrorDetails(message);
15511544
ThrowTerminatingError(errorRecord);
15521545

@@ -2595,9 +2588,7 @@ private void GetStoresOrNames(
25952588
else
25962589
{
25972590
X509NativeStore store = GetStore(storePath, name, location);
2598-
X509Store ManagedStore = new(
2599-
store.StoreName,
2600-
store.Location.Location);
2591+
X509Store ManagedStore = new(store.StoreName, store.Location.Location);
26012592
thingToReturn = ManagedStore;
26022593
}
26032594

@@ -3581,8 +3572,7 @@ internal static List<string> GetStoreNamesAtLocation(StoreLocation location)
35813572
break;
35823573
}
35833574

3584-
Security.NativeMethods.CertEnumSystemStoreCallBackProto callBack =
3585-
new(CertEnumSystemStoreCallBack);
3575+
Security.NativeMethods.CertEnumSystemStoreCallBackProto callBack = new(CertEnumSystemStoreCallBack);
35863576

35873577
// Return a new list to avoid synchronization issues.
35883578

src/Microsoft.PowerShell.Security/security/CmsCommands.cs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ protected override void BeginProcessing()
9696
{
9797
ErrorRecord error = new(
9898
new ArgumentException(
99-
string.Format(CultureInfo.InvariantCulture,
100-
CmsCommands.FilePathMustBeFileSystemPath, Path)),
101-
"FilePathMustBeFileSystemPath", ErrorCategory.ObjectNotFound, provider);
99+
string.Format(
100+
CultureInfo.InvariantCulture,
101+
CmsCommands.FilePathMustBeFileSystemPath,
102+
Path)),
103+
"FilePathMustBeFileSystemPath",
104+
ErrorCategory.ObjectNotFound,
105+
provider);
102106
ThrowTerminatingError(error);
103107
}
104108

@@ -247,9 +251,13 @@ protected override void BeginProcessing()
247251
{
248252
ErrorRecord error = new(
249253
new ArgumentException(
250-
string.Format(CultureInfo.InvariantCulture,
251-
CmsCommands.FilePathMustBeFileSystemPath, Path)),
252-
"FilePathMustBeFileSystemPath", ErrorCategory.ObjectNotFound, provider);
254+
string.Format(
255+
CultureInfo.InvariantCulture,
256+
CmsCommands.FilePathMustBeFileSystemPath,
257+
Path)),
258+
"FilePathMustBeFileSystemPath",
259+
ErrorCategory.ObjectNotFound,
260+
provider);
253261
ThrowTerminatingError(error);
254262
}
255263

@@ -424,9 +432,13 @@ protected override void BeginProcessing()
424432
{
425433
ErrorRecord error = new(
426434
new ArgumentException(
427-
string.Format(CultureInfo.InvariantCulture,
428-
CmsCommands.FilePathMustBeFileSystemPath, Path)),
429-
"FilePathMustBeFileSystemPath", ErrorCategory.ObjectNotFound, provider);
435+
string.Format(
436+
CultureInfo.InvariantCulture,
437+
CmsCommands.FilePathMustBeFileSystemPath,
438+
Path)),
439+
"FilePathMustBeFileSystemPath",
440+
ErrorCategory.ObjectNotFound,
441+
provider);
430442
ThrowTerminatingError(error);
431443
}
432444

@@ -514,9 +526,13 @@ private string Decrypt(string actualContent)
514526
{
515527
ErrorRecord error = new(
516528
new ArgumentException(
517-
string.Format(CultureInfo.InvariantCulture,
518-
CmsCommands.InputContainedNoEncryptedContentIncludeContext, "-IncludeContext")),
519-
"InputContainedNoEncryptedContentIncludeContext", ErrorCategory.ObjectNotFound, null);
529+
string.Format(
530+
CultureInfo.InvariantCulture,
531+
CmsCommands.InputContainedNoEncryptedContentIncludeContext,
532+
"-IncludeContext")),
533+
"InputContainedNoEncryptedContentIncludeContext",
534+
ErrorCategory.ObjectNotFound,
535+
targetObject: null);
520536
ThrowTerminatingError(error);
521537
}
522538

src/Microsoft.PowerShell.Security/security/CredentialCommands.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ protected override void BeginProcessing()
104104
}
105105
catch (ArgumentException exception)
106106
{
107-
ErrorRecord errorRecord = new(exception, "CouldNotPromptForCredential", ErrorCategory.InvalidOperation, null);
107+
ErrorRecord errorRecord = new(
108+
exception,
109+
"CouldNotPromptForCredential",
110+
ErrorCategory.InvalidOperation,
111+
targetObject: null);
108112
WriteError(errorRecord);
109113
}
110114

src/Microsoft.PowerShell.Security/security/ExecutionPolicyCommands.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected override void BeginProcessing()
6969
new InvalidOperationException(),
7070
"ListAndScopeSpecified",
7171
ErrorCategory.InvalidOperation,
72-
null);
72+
targetObject: null);
7373

7474
errorRecord.ErrorDetails = new ErrorDetails(message);
7575
ThrowTerminatingError(errorRecord);
@@ -86,8 +86,7 @@ protected override void BeginProcessing()
8686
PSObject outputObject = new();
8787

8888
ExecutionPolicy policy = SecuritySupport.GetExecutionPolicy(shellId, scope);
89-
PSNoteProperty inputNote = new(
90-
"Scope", scope);
89+
PSNoteProperty inputNote = new("Scope", scope);
9190
outputObject.Properties.Add(inputNote);
9291
inputNote = new PSNoteProperty(
9392
"ExecutionPolicy", policy);
@@ -180,7 +179,7 @@ protected override void BeginProcessing()
180179
new InvalidOperationException(),
181180
"CantSetGroupPolicy",
182181
ErrorCategory.InvalidOperation,
183-
null);
182+
targetObject: null);
184183

185184
errorRecord.ErrorDetails = new ErrorDetails(message);
186185
ThrowTerminatingError(errorRecord);
@@ -225,7 +224,7 @@ protected override void ProcessRecord()
225224
new System.Security.SecurityException(),
226225
"ExecutionPolicyOverride",
227226
ErrorCategory.PermissionDenied,
228-
null);
227+
targetObject: null);
229228

230229
errorRecord.ErrorDetails = new ErrorDetails(message);
231230
errorRecord.ErrorDetails.RecommendedAction = recommendedAction;
@@ -333,7 +332,7 @@ private void OnAccessDeniedError(Exception exception)
333332
exception,
334333
exception.GetType().FullName,
335334
ErrorCategory.PermissionDenied,
336-
null);
335+
targetObject: null);
337336

338337
errorRecord.ErrorDetails = new ErrorDetails(message);
339338
ThrowTerminatingError(errorRecord);

src/Microsoft.PowerShell.Security/security/SignatureCommands.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,7 @@ protected override Signature PerformAction(string filePath)
484484
e,
485485
"ForceArgumentException",
486486
ErrorCategory.WriteError,
487-
filePath
488-
);
487+
filePath);
489488
WriteError(er);
490489
return null;
491490
}
@@ -495,8 +494,7 @@ protected override Signature PerformAction(string filePath)
495494
e,
496495
"ForceIOException",
497496
ErrorCategory.WriteError,
498-
filePath
499-
);
497+
filePath);
500498
WriteError(er);
501499
return null;
502500
}
@@ -506,8 +504,7 @@ protected override Signature PerformAction(string filePath)
506504
e,
507505
"ForceUnauthorizedAccessException",
508506
ErrorCategory.PermissionDenied,
509-
filePath
510-
);
507+
filePath);
511508
WriteError(er);
512509
return null;
513510
}
@@ -517,8 +514,7 @@ protected override Signature PerformAction(string filePath)
517514
e,
518515
"ForceNotSupportedException",
519516
ErrorCategory.WriteError,
520-
filePath
521-
);
517+
filePath);
522518
WriteError(er);
523519
return null;
524520
}
@@ -528,8 +524,7 @@ protected override Signature PerformAction(string filePath)
528524
e,
529525
"ForceSecurityException",
530526
ErrorCategory.PermissionDenied,
531-
filePath
532-
);
527+
filePath);
533528
WriteError(er);
534529
return null;
535530
}

0 commit comments

Comments
 (0)