Skip to content

Commit 5db70e9

Browse files
authored
Make TokenCacheData.CacheBytes readonly per API review feedback (Azure#24710)
* Make TokenCacheData.CacheBytes readonly per API review feedback * update api spec
1 parent ce2a35b commit 5db70e9

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

sdk/identity/Azure.Identity/Azure.Identity.sln

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.28803.352
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31717.71
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Identity", "src\Azure.Identity.csproj", "{8A856C05-8CC7-4A1A-A3DC-DD628ECD3E2A}"
77
EndProject
@@ -19,7 +19,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1919
EndProject
2020
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{DBE8A141-33F2-489A-A228-B2C919E10C03}"
2121
EndProject
22-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Identity.Perf", "perf\Azure.Identity.Perf.csproj", "{94123C93-FB92-4D05-AA7B-45E1896696FC}"
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Identity.Perf", "perf\Azure.Identity.Perf.csproj", "{94123C93-FB92-4D05-AA7B-45E1896696FC}"
23+
EndProject
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Test.Perf", "..\..\..\common\Perf\Azure.Test.Perf\Azure.Test.Perf.csproj", "{D181301A-2FA4-420D-963F-529445E61409}"
2325
EndProject
2426
Global
2527
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -47,6 +49,10 @@ Global
4749
{94123C93-FB92-4D05-AA7B-45E1896696FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
4850
{94123C93-FB92-4D05-AA7B-45E1896696FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
4951
{94123C93-FB92-4D05-AA7B-45E1896696FC}.Release|Any CPU.Build.0 = Release|Any CPU
52+
{D181301A-2FA4-420D-963F-529445E61409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53+
{D181301A-2FA4-420D-963F-529445E61409}.Debug|Any CPU.Build.0 = Debug|Any CPU
54+
{D181301A-2FA4-420D-963F-529445E61409}.Release|Any CPU.ActiveCfg = Release|Any CPU
55+
{D181301A-2FA4-420D-963F-529445E61409}.Release|Any CPU.Build.0 = Release|Any CPU
5056
EndGlobalSection
5157
GlobalSection(SolutionProperties) = preSolution
5258
HideSolutionNode = FALSE

sdk/identity/Azure.Identity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Removed `RegionalAuthority` from `ClientCertificateCredentialOptions` and `ClientSecretCredentialOptions`, along with the `RegionalAuthority` type. This feature will stay in preview, and these APIs will be added back in `1.6.0-beta.1`.
99
- Renamed struct `TokenCacheDetails` to `TokenCacheData`.
1010
- Renamed class `TokenCacheNotificationDetails` to `TokenCacheRefreshArgs`.
11+
- Updated `CacheBytes` property on `TokenCacheData` to be readonly and a required constructor parameter.
1112

1213
### Bugs Fixed
1314
- Fixed issue with `AuthorizationCodeCredential` not specifying correct redirectUrl (Issue [#24183](https://github.com/Azure/azure-sdk-for-net/issues/24183))

sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ public partial struct TokenCacheData
266266
{
267267
private object _dummy;
268268
private int _dummyPrimitive;
269-
public System.ReadOnlyMemory<byte> CacheBytes { get { throw null; } set { } }
269+
public TokenCacheData(System.ReadOnlyMemory<byte> cacheBytes) { throw null; }
270+
public System.ReadOnlyMemory<byte> CacheBytes { get { throw null; } }
270271
}
271272
public partial class TokenCachePersistenceOptions
272273
{

sdk/identity/Azure.Identity/src/TokenCacheData.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ namespace Azure.Identity
1010
/// </summary>
1111
public struct TokenCacheData
1212
{
13+
/// <summary>
14+
/// Constructs a new <see cref="TokenCacheData"/> instance with the specified cache bytes.
15+
/// </summary>
16+
/// <param name="cacheBytes">The serialized content of the token cache.</param>
17+
public TokenCacheData(ReadOnlyMemory<byte> cacheBytes)
18+
{
19+
CacheBytes = cacheBytes;
20+
}
21+
1322
/// <summary>
1423
/// The bytes representing the state of the token cache.
1524
/// </summary>
16-
public ReadOnlyMemory<byte> CacheBytes { get; set; }
25+
public ReadOnlyMemory<byte> CacheBytes { get; }
1726
}
1827
}

sdk/identity/Azure.Identity/src/UnsafeTokenCacheOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public abstract class UnsafeTokenCacheOptions : TokenCachePersistenceOptions
3131
/// <param name="args">The <see cref="TokenCacheRefreshArgs"/> containing information about the current state of the cache.</param>
3232
/// <param name="cancellationToken">The <see cref="CancellationToken"/> controlling the lifetime of this operation.</param>
3333
protected internal virtual async Task<TokenCacheData> RefreshCacheAsync(TokenCacheRefreshArgs args, CancellationToken cancellationToken = default) =>
34-
new() {CacheBytes = await RefreshCacheAsync().ConfigureAwait(false)};
34+
new TokenCacheData(await RefreshCacheAsync().ConfigureAwait(false));
3535
}
3636
}

0 commit comments

Comments
 (0)