Skip to content

Commit 3b5ea4f

Browse files
John Luopranavkm
John Luo
andauthored
Add API docs for Caching and WebEncoders (#28945)
* Add API docs for Caching and WebEncoders Co-authored-by: Pranav K <[email protected]>
1 parent 9deb14d commit 3b5ea4f

File tree

8 files changed

+57
-10
lines changed

8 files changed

+57
-10
lines changed

src/Caching/SqlServer/src/Microsoft.Extensions.Caching.SqlServer.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<Description>Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using Microsoft SQL Server.</Description>
55
<TargetFramework>netstandard2.0</TargetFramework>
6-
<NoWarn>$(NoWarn);CS1591</NoWarn>
76
<GenerateDocumentationFile>true</GenerateDocumentationFile>
87
<PackageTags>cache;distributedcache;sqlserver</PackageTags>
98
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>

src/Caching/SqlServer/src/SqlServerCache.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public class SqlServerCache : IDistributedCache
2727
private readonly TimeSpan _defaultSlidingExpiration;
2828
private readonly Object _mutex = new Object();
2929

30+
/// <summary>
31+
/// Initializes a new instance of <see cref="SqlServerCache"/>.
32+
/// </summary>
33+
/// <param name="options">The configuration options.</param>
3034
public SqlServerCache(IOptions<SqlServerCacheOptions> options)
3135
{
3236
var cacheOptions = options.Value;
@@ -88,6 +92,7 @@ public SqlServerCache(IOptions<SqlServerCacheOptions> options)
8892
}
8993
}
9094

95+
/// <inheritdoc />
9196
public byte[] Get(string key)
9297
{
9398
if (key == null)
@@ -102,6 +107,7 @@ public byte[] Get(string key)
102107
return value;
103108
}
104109

110+
/// <inheritdoc />
105111
public async Task<byte[]> GetAsync(string key, CancellationToken token = default(CancellationToken))
106112
{
107113
if (key == null)
@@ -118,6 +124,7 @@ public byte[] Get(string key)
118124
return value;
119125
}
120126

127+
/// <inheritdoc />
121128
public void Refresh(string key)
122129
{
123130
if (key == null)
@@ -130,6 +137,7 @@ public void Refresh(string key)
130137
ScanForExpiredItemsIfRequired();
131138
}
132139

140+
/// <inheritdoc />
133141
public async Task RefreshAsync(string key, CancellationToken token = default(CancellationToken))
134142
{
135143
if (key == null)
@@ -144,6 +152,7 @@ public void Refresh(string key)
144152
ScanForExpiredItemsIfRequired();
145153
}
146154

155+
/// <inheritdoc />
147156
public void Remove(string key)
148157
{
149158
if (key == null)
@@ -156,6 +165,7 @@ public void Remove(string key)
156165
ScanForExpiredItemsIfRequired();
157166
}
158167

168+
/// <inheritdoc />
159169
public async Task RemoveAsync(string key, CancellationToken token = default(CancellationToken))
160170
{
161171
if (key == null)
@@ -170,6 +180,7 @@ public void Remove(string key)
170180
ScanForExpiredItemsIfRequired();
171181
}
172182

183+
/// <inheritdoc />
173184
public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
174185
{
175186
if (key == null)
@@ -194,6 +205,7 @@ public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
194205
ScanForExpiredItemsIfRequired();
195206
}
196207

208+
/// <inheritdoc />
197209
public async Task SetAsync(
198210
string key,
199211
byte[] value,

src/Caching/StackExchangeRedis/src/Microsoft.Extensions.Caching.StackExchangeRedis.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<Description>Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using Redis.</Description>
55
<TargetFramework>netstandard2.0</TargetFramework>
6-
<NoWarn>$(NoWarn);CS1591</NoWarn>
76
<GenerateDocumentationFile>true</GenerateDocumentationFile>
87
<PackageTags>cache;distributedcache;redis</PackageTags>
98
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>

src/Caching/StackExchangeRedis/src/RedisCache.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
namespace Microsoft.Extensions.Caching.StackExchangeRedis
1313
{
14+
/// <summary>
15+
/// Distributed cache implementation using Redis.
16+
/// <para>Uses <c>StackExchange.Redis</c> as the Redis client.</para>
17+
/// </summary>
1418
public class RedisCache : IDistributedCache, IDisposable
1519
{
1620
// KEYS[1] = = key
@@ -39,6 +43,10 @@ public class RedisCache : IDistributedCache, IDisposable
3943

4044
private readonly SemaphoreSlim _connectionLock = new SemaphoreSlim(initialCount: 1, maxCount: 1);
4145

46+
/// <summary>
47+
/// Initializes a new instance of <see cref="RedisCache"/>.
48+
/// </summary>
49+
/// <param name="optionsAccessor">The configuration options.</param>
4250
public RedisCache(IOptions<RedisCacheOptions> optionsAccessor)
4351
{
4452
if (optionsAccessor == null)
@@ -52,6 +60,7 @@ public RedisCache(IOptions<RedisCacheOptions> optionsAccessor)
5260
_instance = _options.InstanceName ?? string.Empty;
5361
}
5462

63+
/// <inheritdoc />
5564
public byte[] Get(string key)
5665
{
5766
if (key == null)
@@ -62,6 +71,7 @@ public byte[] Get(string key)
6271
return GetAndRefresh(key, getData: true);
6372
}
6473

74+
/// <inheritdoc />
6575
public async Task<byte[]> GetAsync(string key, CancellationToken token = default(CancellationToken))
6676
{
6777
if (key == null)
@@ -74,6 +84,7 @@ public byte[] Get(string key)
7484
return await GetAndRefreshAsync(key, getData: true, token: token).ConfigureAwait(false);
7585
}
7686

87+
/// <inheritdoc />
7788
public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
7889
{
7990
if (key == null)
@@ -107,6 +118,7 @@ public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
107118
});
108119
}
109120

121+
/// <inheritdoc />
110122
public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default(CancellationToken))
111123
{
112124
if (key == null)
@@ -142,6 +154,7 @@ public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
142154
}).ConfigureAwait(false);
143155
}
144156

157+
/// <inheritdoc />
145158
public void Refresh(string key)
146159
{
147160
if (key == null)
@@ -152,6 +165,7 @@ public void Refresh(string key)
152165
GetAndRefresh(key, getData: false);
153166
}
154167

168+
/// <inheritdoc />
155169
public async Task RefreshAsync(string key, CancellationToken token = default(CancellationToken))
156170
{
157171
if (key == null)
@@ -301,6 +315,7 @@ private byte[] GetAndRefresh(string key, bool getData)
301315
return null;
302316
}
303317

318+
/// <inheritdoc />
304319
public void Remove(string key)
305320
{
306321
if (key == null)
@@ -314,6 +329,7 @@ public void Remove(string key)
314329
// TODO: Error handling
315330
}
316331

332+
/// <inheritdoc />
317333
public async Task RemoveAsync(string key, CancellationToken token = default(CancellationToken))
318334
{
319335
if (key == null)
@@ -432,6 +448,7 @@ private void Refresh(string key, DateTimeOffset? absExpr, TimeSpan? sldExpr)
432448
return options.AbsoluteExpiration;
433449
}
434450

451+
/// <inheritdoc />
435452
public void Dispose()
436453
{
437454
if (_disposed)

src/WebEncoders/src/Microsoft.Extensions.WebEncoders.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<Description>Contains registration and configuration APIs to add the core framework encoders to a dependency injection container.</Description>
55
<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0;$(DefaultNetCoreTargetFramework)</TargetFrameworks>
66
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">$(DefaultNetCoreTargetFramework)</TargetFrameworks>
7-
<NoWarn>$(NoWarn);CS1591</NoWarn>
87
<GenerateDocumentationFile>true</GenerateDocumentationFile>
98
<PackageTags>aspnetcore</PackageTags>
109
<IsAspNetCoreApp>true</IsAspNetCoreApp>

src/WebEncoders/src/Testing/HtmlTestEncoder.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
namespace Microsoft.Extensions.WebEncoders.Testing
99
{
1010
/// <summary>
11-
/// Encoder used for unit testing.
11+
/// <see cref="HtmlEncoder"/> used for unit testing. This encoder does not perform any encoding and should not be used in application code.
1212
/// </summary>
1313
public sealed class HtmlTestEncoder : HtmlEncoder
1414
{
15+
/// <inheritdoc />
1516
public override int MaxOutputCharactersPerInputCharacter
1617
{
1718
get { return 1; }
1819
}
1920

21+
/// <inheritdoc />
2022
public override string Encode(string value)
2123
{
2224
if (value == null)
@@ -32,6 +34,7 @@ public override string Encode(string value)
3234
return $"HtmlEncode[[{value}]]";
3335
}
3436

37+
/// <inheritdoc />
3538
public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
3639
{
3740
if (output == null)
@@ -54,6 +57,7 @@ public override void Encode(TextWriter output, char[] value, int startIndex, int
5457
output.Write("]]");
5558
}
5659

60+
/// <inheritdoc />
5761
public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
5862
{
5963
if (output == null)
@@ -76,16 +80,19 @@ public override void Encode(TextWriter output, string value, int startIndex, int
7680
output.Write("]]");
7781
}
7882

83+
/// <inheritdoc />
7984
public override bool WillEncode(int unicodeScalar)
8085
{
8186
return false;
8287
}
8388

89+
/// <inheritdoc />
8490
public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
8591
{
8692
return -1;
8793
}
8894

95+
/// <inheritdoc />
8996
public override unsafe bool TryEncodeUnicodeScalar(
9097
int unicodeScalar,
9198
char* buffer,
@@ -101,4 +108,4 @@ public override unsafe bool TryEncodeUnicodeScalar(
101108
return false;
102109
}
103110
}
104-
}
111+
}

src/WebEncoders/src/Testing/JavaScriptTestEncoder.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
namespace Microsoft.Extensions.WebEncoders.Testing
99
{
1010
/// <summary>
11-
/// Encoder used for unit testing.
11+
/// <see cref="JavaScriptEncoder"/> used for unit testing. This encoder does not perform any encoding and should not be used in application code.
1212
/// </summary>
1313
public class JavaScriptTestEncoder : JavaScriptEncoder
1414
{
15+
/// <inheritdoc />
1516
public override int MaxOutputCharactersPerInputCharacter
1617
{
1718
get { return 1; }
1819
}
1920

21+
/// <inheritdoc />
2022
public override string Encode(string value)
2123
{
2224
if (value == null)
@@ -32,6 +34,7 @@ public override string Encode(string value)
3234
return $"JavaScriptEncode[[{value}]]";
3335
}
3436

37+
/// <inheritdoc />
3538
public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
3639
{
3740
if (output == null)
@@ -54,6 +57,7 @@ public override void Encode(TextWriter output, char[] value, int startIndex, int
5457
output.Write("]]");
5558
}
5659

60+
/// <inheritdoc />
5761
public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
5862
{
5963
if (output == null)
@@ -76,16 +80,19 @@ public override void Encode(TextWriter output, string value, int startIndex, int
7680
output.Write("]]");
7781
}
7882

83+
/// <inheritdoc />
7984
public override bool WillEncode(int unicodeScalar)
8085
{
8186
return false;
8287
}
8388

89+
/// <inheritdoc />
8490
public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
8591
{
8692
return -1;
8793
}
8894

95+
/// <inheritdoc />
8996
public override unsafe bool TryEncodeUnicodeScalar(
9097
int unicodeScalar,
9198
char* buffer,
@@ -101,4 +108,4 @@ public override unsafe bool TryEncodeUnicodeScalar(
101108
return false;
102109
}
103110
}
104-
}
111+
}

src/WebEncoders/src/Testing/UrlTestEncoder.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
namespace Microsoft.Extensions.WebEncoders.Testing
99
{
1010
/// <summary>
11-
/// Encoder used for unit testing.
11+
/// <see cref="UrlEncoder"/> used for unit testing. This encoder does not perform any encoding and should not be used in application code.
1212
/// </summary>
1313
public class UrlTestEncoder : UrlEncoder
1414
{
15+
/// <inheritdoc />
1516
public override int MaxOutputCharactersPerInputCharacter
1617
{
1718
get { return 1; }
1819
}
1920

21+
/// <inheritdoc />
2022
public override string Encode(string value)
2123
{
2224
if (value == null)
@@ -32,6 +34,7 @@ public override string Encode(string value)
3234
return $"UrlEncode[[{value}]]";
3335
}
3436

37+
/// <inheritdoc />
3538
public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
3639
{
3740
if (output == null)
@@ -54,6 +57,7 @@ public override void Encode(TextWriter output, char[] value, int startIndex, int
5457
output.Write("]]");
5558
}
5659

60+
/// <inheritdoc />
5761
public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
5862
{
5963
if (output == null)
@@ -76,16 +80,19 @@ public override void Encode(TextWriter output, string value, int startIndex, int
7680
output.Write("]]");
7781
}
7882

83+
/// <inheritdoc />
7984
public override bool WillEncode(int unicodeScalar)
8085
{
8186
return false;
8287
}
8388

89+
/// <inheritdoc />
8490
public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
8591
{
8692
return -1;
8793
}
8894

95+
/// <inheritdoc />
8996
public override unsafe bool TryEncodeUnicodeScalar(
9097
int unicodeScalar,
9198
char* buffer,
@@ -101,4 +108,4 @@ public override unsafe bool TryEncodeUnicodeScalar(
101108
return false;
102109
}
103110
}
104-
}
111+
}

0 commit comments

Comments
 (0)