Skip to content

Commit 350192f

Browse files
authored
Improve the Codes of Az.Accounts with Reference to Copilot (#27653)
1 parent 27c0fc9 commit 350192f

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.Azure.Commands.Common.Authentication;
1818
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1919
using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core;
20+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Interfaces;
2021
using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Models;
2122
using Microsoft.Azure.Commands.Common.Authentication.Config.Models;
2223
using Microsoft.Azure.Commands.Common.Authentication.Factories;
@@ -517,8 +518,7 @@ public override void ExecuteCmdlet()
517518
return;
518519
}
519520

520-
IHttpOperationsFactory httpClientFactory = null;
521-
AzureSession.Instance.TryGetComponent(HttpClientOperationsFactory.Name, out httpClientFactory);
521+
AzureSession.Instance.TryGetComponent(HttpClientOperationsFactory.Name, out IHttpOperationsFactory httpClientFactory);
522522

523523
SetContextWithOverwritePrompt((localProfile, profileClient, name) =>
524524
{

src/Accounts/Accounts/CommonModule/EnvironmentExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ internal static void CheckAndEnqueue<T>(this ConcurrentQueue<T> queue, T item)
342342

343343
internal static bool TryDequeueIfNotNull<T>(this ConcurrentQueue<T> queue, out T result)
344344
{
345-
result = default(T);
345+
result = default;
346346
if (null == queue)
347347
{
348348
return false;

src/Accounts/Accounts/Token/GetAzureRmAccessToken.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.Azure.Commands.ResourceManager.Common;
2020
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2121
using Microsoft.Azure.PowerShell.Authenticators;
22+
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2223
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2324

2425
using System;
@@ -126,7 +127,7 @@ public override void ExecuteCmdlet()
126127
UserId = accessToken.UserId,
127128
};
128129
result.ExpiresOn = (accessToken as MsalAccessToken)?.ExpiresOn ?? result.ExpiresOn;
129-
if(result.ExpiresOn == default(DateTimeOffset))
130+
if (result.ExpiresOn == default)
130131
{
131132
try
132133
{

src/Accounts/Authentication.ResourceManager/AzureRmProfile.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void Load(IFileProvider provider)
174174

175175
bool SafeDeserializeObject<T>(string serialization, out T result, JsonConverter converter = null)
176176
{
177-
result = default(T);
177+
result = default;
178178
bool success = false;
179179
try
180180
{
@@ -207,8 +207,7 @@ private void Initialize(AzureRmProfile profile)
207207
EnvironmentTable[environment.Key] = environment.Value;
208208
}
209209

210-
AzKeyStore keystore = null;
211-
AzureSession.Instance.TryGetComponent(AzKeyStore.Name, out keystore);
210+
AzureSession.Instance.TryGetComponent(AzKeyStore.Name, out AzKeyStore keystore);
212211

213212
foreach (var context in profile.Contexts)
214213
{
@@ -249,8 +248,7 @@ private void LoadImpl(string contents)
249248
/// </summary>
250249
public AzureRmProfile RefillCredentialsFromKeyStore()
251250
{
252-
AzKeyStore keystore = null;
253-
AzureSession.Instance.TryGetComponent(AzKeyStore.Name, out keystore);
251+
AzureSession.Instance.TryGetComponent(AzKeyStore.Name, out AzKeyStore keystore);
254252
AzureRmProfile ret = this.DeepCopy();
255253
if (keystore != null)
256254
{

0 commit comments

Comments
 (0)