Skip to content

Commit 46f10ba

Browse files
author
pi1024e
committed
Fixed windows capitalization typo and refactored lines for readability.
1 parent b57b4d3 commit 46f10ba

File tree

10 files changed

+64
-83
lines changed

10 files changed

+64
-83
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: 9 additions & 12 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,17 +362,14 @@ protected override void InitializeQosEvent()
362362

363363
public override void ExecuteCmdlet()
364364
{
365-
if (!CallShouldProcess || ShouldProcess("target", "action"))
365+
if ((!CallShouldProcess || ShouldProcess("target", "action")) && (!CallShouldContinue || ShouldContinue("query", "caption")))
366366
{
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-
}
367+
WriteValues(Verbose, WriteVerbose);
368+
WriteValues(Warning, WriteWarning);
369+
WriteValues(Progress, WriteProgress);
370+
WriteValues(Debug, WriteDebug);
371+
WriteValues(Output, WriteObject);
372+
WriteValues(Error, WriteError);
376373
}
377374

378375
if (Wait)

src/Accounts/Authentication/Models/MemoryDataStore.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,11 @@ 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)
217+
if (key.StartsWith(sourceDirName) && VirtualStore[key] != FolderKey && !files.Contains(key))
218218
{
219-
if (!files.Contains(key))
220-
{
221-
files.Add(key);
222-
}
219+
220+
files.Add(key);
221+
223222
}
224223
}
225224
return files.ToArray();
@@ -230,12 +229,9 @@ public string[] GetFiles(string startDirectory, string filePattern, SearchOption
230229
HashSet<string> files = new HashSet<string>();
231230
foreach (var key in VirtualStore.Keys.ToArray())
232231
{
233-
if (key.StartsWith(startDirectory) && VirtualStore[key] != FolderKey && Regex.IsMatch(key, WildcardToRegex(filePattern), RegexOptions.IgnoreCase))
232+
if (key.StartsWith(startDirectory) && VirtualStore[key] != FolderKey && Regex.IsMatch(key, WildcardToRegex(filePattern), RegexOptions.IgnoreCase) && !files.Contains(key))
234233
{
235-
if (!files.Contains(key))
236-
{
237-
files.Add(key);
238-
}
234+
files.Add(key);
239235
}
240236
}
241237
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-
// Get for single server
45-
var server = AnalysisServicesClient.GetServer(ResourceGroupName, Name);
46-
WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(server));
47-
}
48-
else
42+
if (string.IsNullOrEmpty(Name))
4943
{
5044
// List all servers in given resource group if avaliable otherwise all servers in the subscription
5145
var list = AnalysisServicesClient.ListServers(ResourceGroupName);
5246
WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServerCollection(list), true);
5347
}
48+
else
49+
{
50+
// Get for single server
51+
var server = AnalysisServicesClient.GetServer(ResourceGroupName, Name);
52+
WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(server));
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: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,9 @@ internal static void JobReleaseTaskSyncCollections(PSJobReleaseTask jobReleaseTa
225225
/// </summary>
226226
internal static void PoolInformationSyncCollections(PSPoolInformation poolInfo)
227227
{
228-
if (poolInfo != null)
228+
if (poolInfo != null && poolInfo.AutoPoolSpecification != null)
229229
{
230-
if (poolInfo.AutoPoolSpecification != null)
231-
{
232-
AutoPoolSpecificationSyncCollections(poolInfo.AutoPoolSpecification);
233-
}
230+
AutoPoolSpecificationSyncCollections(poolInfo.AutoPoolSpecification);
234231
}
235232
}
236233

@@ -239,12 +236,9 @@ internal static void PoolInformationSyncCollections(PSPoolInformation poolInfo)
239236
/// </summary>
240237
internal static void AutoPoolSpecificationSyncCollections(PSAutoPoolSpecification spec)
241238
{
242-
if (spec != null)
239+
if (spec != null && spec.PoolSpecification != null)
243240
{
244-
if (spec.PoolSpecification != null)
245-
{
246-
PoolSpecificationSyncCollections(spec.PoolSpecification);
247-
}
241+
PoolSpecificationSyncCollections(spec.PoolSpecification);
248242
}
249243
}
250244

@@ -418,8 +412,8 @@ public static void ExitConditionsSyncCollections(PSExitConditions exitConditions
418412
exitConditions.ExitCodeRanges,
419413
(e) =>
420414
{
421-
ExitCodeRangeMapping exitCodeRangeMapping = new ExitCodeRangeMapping(e.Start, e.End, e.omObject.ExitOptions);
422-
return exitCodeRangeMapping;
415+
ExitCodeRangeMapping exitCodeRangeMapping = new ExitCodeRangeMapping(e.Start, e.End, e.omObject.ExitOptions);
416+
return exitCodeRangeMapping;
423417
});
424418
exitConditions.omObject.ExitCodes = CreateSyncedList(exitConditions.ExitCodes,
425419
(e) =>

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,23 +284,21 @@ 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-
int i = 0;
288-
for (; i < loopingTimes; i++)
287+
for (int i = 0; i < loopingTimes; i++)
289288
{
290289
List<CloudPageBlob> snapshotsFound = this.FindSnapshot(virtualMachineExtensionBaseCmdlet.DefaultProfile.DefaultContext, blobSASUris.pageBlobUri, blobSASUris.storageCredentialsFactory, snapshotQuery);
291290
if (snapshotsFound.Count == vmPageBlobUris.Count)
292291
{
293-
break;
292+
return;
294293
}
295294
else
296295
{
297296
Thread.Sleep(timePeriod);
298297
}
299298
}
300-
if (i == loopingTimes)
301-
{
302-
throw new AzureVMBackupException(AzureVMBackupErrorCodes.TimeOut, "snapshot not created, or not found in time.");
303-
}
299+
//Exceeded number of looping times, throw an exception
300+
throw new AzureVMBackupException(AzureVMBackupErrorCodes.TimeOut, "snapshot not created, or not found in time.");
301+
304302
}
305303
}
306304
}

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

Lines changed: 2 additions & 4 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,9 +70,7 @@ public override void ExecuteCmdlet()
7070
this.VM.OSProfile.Secrets = new List<VaultSecretGroup>();
7171
}
7272

73-
int i = 0;
74-
75-
for (; i <= this.VM.OSProfile.Secrets.Count; i++)
73+
for (int i = 0; i <= this.VM.OSProfile.Secrets.Count; i++)
7674
{
7775
if (i == this.VM.OSProfile.Secrets.Count)
7876
{

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,16 @@ protected override IEnumerable<AzureSqlServerDisasterRecoveryConfigurationModel>
113113
protected override IEnumerable<AzureSqlServerDisasterRecoveryConfigurationModel> PersistChanges(
114114
IEnumerable<AzureSqlServerDisasterRecoveryConfigurationModel> entity)
115115
{
116-
switch (ParameterSetName)
116+
if (ParameterSetName == ByFailoverParams)
117117
{
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;
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);
126125
}
127-
128126
return entity;
129127
}
130128
}

0 commit comments

Comments
 (0)