Skip to content

Commit 136b648

Browse files
authored
Remove a few allocations for interfaces, which are not needed (#2414)
1 parent f1b31fc commit 136b648

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Microsoft.Identity.Web.TokenAcquisition/AspNetCore/TokenAcquisition-AspnetCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void ReplyForbiddenWithWwwAuthenticateHeader(
9494
+ $"&response_type=code&redirect_uri={application.AppConfig.RedirectUri}"
9595
+ $"&response_mode=query&scope=offline_access%20{string.Join("%20", scopes)}";
9696

97-
IDictionary<string, string> parameters = new Dictionary<string, string>()
97+
Dictionary<string, string> parameters = new()
9898
{
9999
{ Constants.ConsentUrl, consentUrl },
100100
{ Constants.Claims, msalServiceException.Claims },

src/Microsoft.Identity.Web.TokenAcquisition/TokenAcquisition.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class OAuthConstants
4141
#endif
4242
protected readonly IMsalTokenCacheProvider _tokenCacheProvider;
4343

44-
private readonly object _applicationSyncObj = new object();
44+
private readonly object _applicationSyncObj = new();
4545

4646
/// <summary>
4747
/// Please call GetOrBuildConfidentialClientApplication instead of accessing this field directly.
4848
/// </summary>
49-
private ConcurrentDictionary<string, IConfidentialClientApplication?> _applicationsByAuthorityClientId = new ConcurrentDictionary<string, IConfidentialClientApplication?>();
49+
private readonly ConcurrentDictionary<string, IConfidentialClientApplication?> _applicationsByAuthorityClientId = new ConcurrentDictionary<string, IConfidentialClientApplication?>();
5050
private bool _retryClientCertificate;
5151
protected readonly IMsalHttpClientFactory _httpClientFactory;
5252
protected readonly ILogger _logger;
@@ -558,8 +558,7 @@ private bool IsInvalidClientCertificateOrSignedAssertionError(MsalServiceExcepti
558558
internal /* for testing */ IConfidentialClientApplication GetOrBuildConfidentialClientApplication(
559559
MergedOptions mergedOptions)
560560
{
561-
IConfidentialClientApplication? application;
562-
if (!_applicationsByAuthorityClientId.TryGetValue(GetApplicationKey(mergedOptions), out application) || application == null)
561+
if (!_applicationsByAuthorityClientId.TryGetValue(GetApplicationKey(mergedOptions), out IConfidentialClientApplication? application) || application == null)
563562
{
564563
lock (_applicationSyncObj)
565564
{

src/Microsoft.Identity.Web/AzureADB2COpenIDConnectEventHandlers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ internal class AzureADB2COpenIDConnectEventHandlers
1414
{
1515
private readonly ILoginErrorAccessor _errorAccessor;
1616

17-
private readonly IDictionary<string, string> _userFlowToIssuerAddress =
18-
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
17+
private readonly Dictionary<string, string> _userFlowToIssuerAddress =
18+
new(StringComparer.OrdinalIgnoreCase);
1919

2020
public AzureADB2COpenIDConnectEventHandlers(
2121
string schemeName,

0 commit comments

Comments
 (0)