Skip to content

Commit b78e07d

Browse files
author
pi1024e
committed
Revert "Fixed windows capitalization typo and refactored lines for readability."
This reverts commit f6c9d786325ca3589406c654a582d6700e2ebe15.
1 parent 313eb37 commit b78e07d

File tree

10 files changed

+83
-64
lines changed

10 files changed

+83
-64
lines changed

src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ namespace Microsoft.Azure.Commands.Profile
3333
/// <summary>
3434
/// Cmdlet to log into an environment and download the subscriptions
3535
/// </summary>
36-
[Cmdlet("Connect", AzureRMConstants.AzureRMPrefix + "Account", DefaultParameterSetName = "UserWithSubscriptionId", SupportsShouldProcess = true)]
36+
[Cmdlet("Connect", AzureRMConstants.AzureRMPrefix + "Account", DefaultParameterSetName = "UserWithSubscriptionId", SupportsShouldProcess=true)]
3737
[Alias("Login-AzAccount", "Login-AzureRmAccount", "Add-" + AzureRMConstants.AzureRMPrefix + "Account")]
3838
[OutputType(typeof(PSAzureProfile))]
3939
public class ConnectAzureRmAccountCommand : AzureContextModificationCmdlet, IModuleAssemblyInitializer
4040
{
4141
public const string UserParameterSet = "UserWithSubscriptionId";
4242
public const string UserWithCredentialParameterSet = "UserWithCredential";
4343
public const string ServicePrincipalParameterSet = "ServicePrincipalWithSubscriptionId";
44-
public const string ServicePrincipalCertificateParameterSet = "ServicePrincipalCertificateWithSubscriptionId";
44+
public const string ServicePrincipalCertificateParameterSet= "ServicePrincipalCertificateWithSubscriptionId";
4545
public const string AccessTokenParameterSet = "AccessTokenWithSubscriptionId";
4646
public const string ManagedServiceParameterSet = "ManagedServiceLogin";
4747
public const string MSIEndpointVariable = "MSI_ENDPOINT";
@@ -112,7 +112,7 @@ public class ConnectAzureRmAccountCommand : AzureContextModificationCmdlet, IMod
112112
[ValidateNotNullOrEmpty]
113113
public string AccountId { get; set; }
114114

115-
[Parameter(ParameterSetName = ManagedServiceParameterSet, Mandatory = true, HelpMessage = "Login using managed service identity in the current environment.")]
115+
[Parameter(ParameterSetName = ManagedServiceParameterSet, Mandatory =true, HelpMessage = "Login using managed service identity in the current environment.")]
116116
[Alias("MSI", "ManagedService")]
117117
public SwitchParameter Identity { get; set; }
118118

@@ -241,8 +241,8 @@ public override void ExecuteCmdlet()
241241
? builder.Uri.ToString()
242242
: envUri;
243243

244-
if (!(this.IsBound(nameof(ManagedServiceHostName)) || string.IsNullOrWhiteSpace(envUri)
245-
|| this.IsBound(nameof(ManagedServiceSecret)) || string.IsNullOrWhiteSpace(envSecret)))
244+
if (!this.IsBound(nameof(ManagedServiceHostName)) && !string.IsNullOrWhiteSpace(envUri)
245+
&& !this.IsBound(nameof(ManagedServiceSecret)) && !string.IsNullOrWhiteSpace(envSecret))
246246
{
247247
// set flag indicating this is AppService Managed Identity ad hoc mode
248248
azureAccount.SetProperty(AuthenticationFactory.AppServiceManagedIdentityFlag, "the value not used");
@@ -369,33 +369,33 @@ public void OnImport()
369369
try
370370
{
371371
#endif
372-
AzureSessionInitializer.InitializeAzureSession();
372+
AzureSessionInitializer.InitializeAzureSession();
373373
#if DEBUG
374374
if (!TestMockSupport.RunningMocked)
375375
{
376376
#endif
377-
AzureSession.Instance.DataStore = new DiskDataStore();
377+
AzureSession.Instance.DataStore = new DiskDataStore();
378378
#if DEBUG
379379
}
380380
#endif
381381

382-
var autoSaveEnabled = AzureSession.Instance.ARMContextSaveMode == ContextSaveMode.CurrentUser;
383-
var autosaveVariable = System.Environment.GetEnvironmentVariable(AzureProfileConstants.AzureAutosaveVariable);
384-
bool localAutosave;
385-
if (bool.TryParse(autosaveVariable, out localAutosave))
386-
{
387-
autoSaveEnabled = localAutosave;
388-
}
382+
var autoSaveEnabled = AzureSession.Instance.ARMContextSaveMode == ContextSaveMode.CurrentUser;
383+
var autosaveVariable = System.Environment.GetEnvironmentVariable(AzureProfileConstants.AzureAutosaveVariable);
384+
bool localAutosave;
385+
if(bool.TryParse(autosaveVariable, out localAutosave))
386+
{
387+
autoSaveEnabled = localAutosave;
388+
}
389389

390-
InitializeProfileProvider(autoSaveEnabled);
391-
IServicePrincipalKeyStore keyStore =
392-
// TODO: Remove IfDef
390+
InitializeProfileProvider(autoSaveEnabled);
391+
IServicePrincipalKeyStore keyStore =
392+
// TODO: Remove IfDef
393393
#if NETSTANDARD
394394
new AzureRmServicePrincipalKeyStore(AzureRmProfileProvider.Instance.Profile);
395395
#else
396396
new AzureRmServicePrincipalKeyStore();
397397
#endif
398-
AzureSession.Instance.RegisterComponent(ServicePrincipalKeyStore.Name, () => keyStore);
398+
AzureSession.Instance.RegisterComponent(ServicePrincipalKeyStore.Name, () => keyStore);
399399
#if DEBUG
400400
}
401401
catch (Exception) when (TestMockSupport.RunningMocked)

src/Accounts/Authentication.Test/LongRunningCmdletTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void WaitForCompletion(AzureLongRunningJob job, Action<AzureLongRunningJob> vali
300300
finally
301301
{
302302
job.StateChanged -= this.HandleStateChange;
303-
foreach (var message in job.Debug)
303+
foreach (var message in job.Debug)
304304
{
305305
xunitLogger.Information(message?.Message);
306306
}
@@ -325,7 +325,7 @@ public class TestCmdletOutput
325325
public string Property { get { return "PropertyValue"; } }
326326
}
327327

328-
[Cmdlet(VerbsDiagnostic.Test, "AzureJob", ConfirmImpact = ConfirmImpact.High)]
328+
[Cmdlet(VerbsDiagnostic.Test, "AzureJob",ConfirmImpact =ConfirmImpact.High)]
329329
public class AzureStreamTestCmdlet : AzurePSCmdlet
330330
{
331331
public IList<ErrorRecord> Error { get; set; } = new List<ErrorRecord>();
@@ -362,14 +362,17 @@ protected override void InitializeQosEvent()
362362

363363
public override void ExecuteCmdlet()
364364
{
365-
if ((!CallShouldProcess || ShouldProcess("target", "action")) && (!CallShouldContinue || ShouldContinue("query", "caption")))
365+
if (!CallShouldProcess || ShouldProcess("target", "action"))
366366
{
367-
WriteValues(Verbose, WriteVerbose);
368-
WriteValues(Warning, WriteWarning);
369-
WriteValues(Progress, WriteProgress);
370-
WriteValues(Debug, WriteDebug);
371-
WriteValues(Output, WriteObject);
372-
WriteValues(Error, WriteError);
367+
if (!CallShouldContinue || ShouldContinue("query", "caption"))
368+
{
369+
WriteValues(Verbose, WriteVerbose);
370+
WriteValues(Warning, WriteWarning);
371+
WriteValues(Progress, WriteProgress);
372+
WriteValues(Debug, WriteDebug);
373+
WriteValues(Output, WriteObject);
374+
WriteValues(Error, WriteError);
375+
}
373376
}
374377

375378
if (Wait)

src/Accounts/Authentication/Models/MemoryDataStore.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,12 @@ public string[] GetFiles(string sourceDirName)
214214
HashSet<string> files = new HashSet<string>();
215215
foreach (var key in VirtualStore.Keys.ToArray())
216216
{
217-
if (key.StartsWith(sourceDirName) && VirtualStore[key] != FolderKey && !files.Contains(key))
217+
if (key.StartsWith(sourceDirName) && VirtualStore[key] != FolderKey)
218218
{
219-
220-
files.Add(key);
221-
219+
if (!files.Contains(key))
220+
{
221+
files.Add(key);
222+
}
222223
}
223224
}
224225
return files.ToArray();
@@ -229,9 +230,12 @@ public string[] GetFiles(string startDirectory, string filePattern, SearchOption
229230
HashSet<string> files = new HashSet<string>();
230231
foreach (var key in VirtualStore.Keys.ToArray())
231232
{
232-
if (key.StartsWith(startDirectory) && VirtualStore[key] != FolderKey && Regex.IsMatch(key, WildcardToRegex(filePattern), RegexOptions.IgnoreCase) && !files.Contains(key))
233+
if (key.StartsWith(startDirectory) && VirtualStore[key] != FolderKey && Regex.IsMatch(key, WildcardToRegex(filePattern), RegexOptions.IgnoreCase))
233234
{
234-
files.Add(key);
235+
if (!files.Contains(key))
236+
{
237+
files.Add(key);
238+
}
235239
}
236240
}
237241
return files.ToArray();

src/AnalysisServices/AnalysisServices/Commands/GetAzureRmAnalysisServicesServer.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace Microsoft.Azure.Commands.AnalysisServices
2323
{
24-
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AnalysisServicesServer"), OutputType(typeof(AzureAnalysisServicesServer))]
24+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AnalysisServicesServer"),OutputType(typeof(AzureAnalysisServicesServer))]
2525
[Alias("Get-" + ResourceManager.Common.AzureRMConstants.AzurePrefix + "As")]
2626
public class GetAzureAnalysisServicesServer : AnalysisServicesCmdletBase
2727
{
@@ -39,18 +39,18 @@ public class GetAzureAnalysisServicesServer : AnalysisServicesCmdletBase
3939

4040
public override void ExecuteCmdlet()
4141
{
42-
if (string.IsNullOrEmpty(Name))
43-
{
44-
// List all servers in given resource group if avaliable otherwise all servers in the subscription
45-
var list = AnalysisServicesClient.ListServers(ResourceGroupName);
46-
WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServerCollection(list), true);
47-
}
48-
else
42+
if (!string.IsNullOrEmpty(Name))
4943
{
5044
// Get for single server
5145
var server = AnalysisServicesClient.GetServer(ResourceGroupName, Name);
5246
WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(server));
5347
}
48+
else
49+
{
50+
// List all servers in given resource group if avaliable otherwise all servers in the subscription
51+
var list = AnalysisServicesClient.ListServers(ResourceGroupName);
52+
WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServerCollection(list), true);
53+
}
5454
}
5555
}
5656
}

src/Batch/Batch/ComputeNodeUsers/NewBatchComputeNodeUserCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class NewBatchComputeNodeUserCommand : BatchObjectModelCmdletBase
4040
[ValidateNotNullOrEmpty]
4141
public PSComputeNode ComputeNode { get; set; }
4242

43-
[Parameter(Mandatory = true, HelpMessage = "The name of the local Windows account created.")]
43+
[Parameter(Mandatory = true, HelpMessage = "The name of the local windows account created.")]
4444
[ValidateNotNullOrEmpty]
4545
public string Name { get; set; }
4646

src/Batch/Batch/Models/NewComputeNodeUserParameters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public NewComputeNodeUserParameters(BatchAccountContext context, string poolId,
2626
{ }
2727

2828
/// <summary>
29-
/// The name of the local Windows account created.
29+
/// The name of the local windows account created.
3030
/// </summary>
3131
public string ComputeNodeUserName { get; set; }
3232

src/Batch/Batch/Utils/Utils.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,12 @@ internal static void JobReleaseTaskSyncCollections(PSJobReleaseTask jobReleaseTa
225225
/// </summary>
226226
internal static void PoolInformationSyncCollections(PSPoolInformation poolInfo)
227227
{
228-
if (poolInfo != null && poolInfo.AutoPoolSpecification != null)
228+
if (poolInfo != null)
229229
{
230-
AutoPoolSpecificationSyncCollections(poolInfo.AutoPoolSpecification);
230+
if (poolInfo.AutoPoolSpecification != null)
231+
{
232+
AutoPoolSpecificationSyncCollections(poolInfo.AutoPoolSpecification);
233+
}
231234
}
232235
}
233236

@@ -236,9 +239,12 @@ internal static void PoolInformationSyncCollections(PSPoolInformation poolInfo)
236239
/// </summary>
237240
internal static void AutoPoolSpecificationSyncCollections(PSAutoPoolSpecification spec)
238241
{
239-
if (spec != null && spec.PoolSpecification != null)
242+
if (spec != null)
240243
{
241-
PoolSpecificationSyncCollections(spec.PoolSpecification);
244+
if (spec.PoolSpecification != null)
245+
{
246+
PoolSpecificationSyncCollections(spec.PoolSpecification);
247+
}
242248
}
243249
}
244250

@@ -412,8 +418,8 @@ public static void ExitConditionsSyncCollections(PSExitConditions exitConditions
412418
exitConditions.ExitCodeRanges,
413419
(e) =>
414420
{
415-
ExitCodeRangeMapping exitCodeRangeMapping = new ExitCodeRangeMapping(e.Start, e.End, e.omObject.ExitOptions);
416-
return exitCodeRangeMapping;
421+
ExitCodeRangeMapping exitCodeRangeMapping = new ExitCodeRangeMapping(e.Start, e.End, e.omObject.ExitOptions);
422+
return exitCodeRangeMapping;
417423
});
418424
exitConditions.omObject.ExitCodes = CreateSyncedList(exitConditions.ExitCodes,
419425
(e) =>

src/Compute/Compute/Extension/AzureVMBackup/AzureVMBackupExtensionUtil.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,21 +284,23 @@ public void CreateSnapshotForDisks(AzureVMBackupConfig vmConfig, string snapshot
284284
Dictionary<string, string> snapshotQuery = new Dictionary<string, string>();
285285
snapshotQuery.Add(backupExtensionMetadataName, snapshotTag);
286286
snapshotQuery.Add(backupExtensionIdentityMetadataName, taskId);
287-
for (int i = 0; i < loopingTimes; i++)
287+
int i = 0;
288+
for (; i < loopingTimes; i++)
288289
{
289290
List<CloudPageBlob> snapshotsFound = this.FindSnapshot(virtualMachineExtensionBaseCmdlet.DefaultProfile.DefaultContext, blobSASUris.pageBlobUri, blobSASUris.storageCredentialsFactory, snapshotQuery);
290291
if (snapshotsFound.Count == vmPageBlobUris.Count)
291292
{
292-
return;
293+
break;
293294
}
294295
else
295296
{
296297
Thread.Sleep(timePeriod);
297298
}
298299
}
299-
//Exceeded number of looping times, throw an exception
300-
throw new AzureVMBackupException(AzureVMBackupErrorCodes.TimeOut, "snapshot not created, or not found in time.");
301-
300+
if (i == loopingTimes)
301+
{
302+
throw new AzureVMBackupException(AzureVMBackupErrorCodes.TimeOut, "snapshot not created, or not found in time.");
303+
}
302304
}
303305
}
304306
}

src/Compute/Compute/VirtualMachine/Config/AddAzureVMSecretCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.Compute
2323
/// <summary>
2424
/// Add a Vault Secret Group object to VM
2525
/// </summary>
26-
[Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMSecret"), OutputType(typeof(PSVirtualMachine))]
26+
[Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMSecret"),OutputType(typeof(PSVirtualMachine))]
2727
public class NewAzureVaultSecretGroupCommand : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet
2828
{
2929
[Alias("VMProfile")]
@@ -70,7 +70,9 @@ public override void ExecuteCmdlet()
7070
this.VM.OSProfile.Secrets = new List<VaultSecretGroup>();
7171
}
7272

73-
for (int i = 0; i <= this.VM.OSProfile.Secrets.Count; i++)
73+
int i = 0;
74+
75+
for (; i <= this.VM.OSProfile.Secrets.Count; i++)
7476
{
7577
if (i == this.VM.OSProfile.Secrets.Count)
7678
{

src/Sql/Sql/ServerDisasterRecoveryConfiguration/Cmdlet/SetAzureSqlServerDisasterRecoveryConfiguration.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,18 @@ protected override IEnumerable<AzureSqlServerDisasterRecoveryConfigurationModel>
113113
protected override IEnumerable<AzureSqlServerDisasterRecoveryConfigurationModel> PersistChanges(
114114
IEnumerable<AzureSqlServerDisasterRecoveryConfigurationModel> entity)
115115
{
116-
if (ParameterSetName == ByFailoverParams)
116+
switch (ParameterSetName)
117117
{
118-
ModelAdapter.FailoverServerDisasterRecoveryConfiguration(this.ResourceGroupName,
119-
this.ServerName, entity.First(), AllowDataLoss.IsPresent);
120-
}
121-
else
122-
{
123-
// Warning user that no options were provided so no action can be taken.
124-
WriteWarning(Resources.SetDisasterRecoveryConfigurationNoOptionProvided);
118+
case ByFailoverParams:
119+
ModelAdapter.FailoverServerDisasterRecoveryConfiguration(this.ResourceGroupName,
120+
this.ServerName, entity.First(), AllowDataLoss.IsPresent);
121+
break;
122+
default:
123+
// Warning user that no options were provided so no action can be taken.
124+
WriteWarning(Resources.SetDisasterRecoveryConfigurationNoOptionProvided);
125+
break;
125126
}
127+
126128
return entity;
127129
}
128130
}

0 commit comments

Comments
 (0)