docs(cache): 更新 WeakKeyCache 异常文档

- 为 GetOrAdd 方法添加 valueFactory 返回 null 时的异常说明
- 在 GlobalUsings 中添加 System.Runtime.CompilerServices 引用
This commit is contained in:
GeWuYou 2026-04-17 19:17:46 +08:00
parent 45ab38519b
commit 3be34156cf
2 changed files with 3 additions and 0 deletions

View File

@ -7,3 +7,4 @@ global using System.Reflection;
global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.DependencyInjection;
global using System.Diagnostics; global using System.Diagnostics;
global using System.Collections.Concurrent; global using System.Collections.Concurrent;
global using System.Runtime.CompilerServices;

View File

@ -27,6 +27,7 @@ internal sealed class WeakKeyCache<TKey, TValue>
/// <returns>已存在或新创建的缓存值。</returns> /// <returns>已存在或新创建的缓存值。</returns>
/// <exception cref="ArgumentNullException"> /// <exception cref="ArgumentNullException">
/// <paramref name="key" /> 或 <paramref name="valueFactory" /> 为 <see langword="null" />。 /// <paramref name="key" /> 或 <paramref name="valueFactory" /> 为 <see langword="null" />。
/// 或 <paramref name="valueFactory" /> 返回 <see langword="null" />。
/// </exception> /// </exception>
public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory) public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
{ {
@ -60,6 +61,7 @@ internal sealed class WeakKeyCache<TKey, TValue>
/// <returns>已存在或新创建的缓存值。</returns> /// <returns>已存在或新创建的缓存值。</returns>
/// <exception cref="ArgumentNullException"> /// <exception cref="ArgumentNullException">
/// <paramref name="key" /> 或 <paramref name="valueFactory" /> 为 <see langword="null" />。 /// <paramref name="key" /> 或 <paramref name="valueFactory" /> 为 <see langword="null" />。
/// 或 <paramref name="valueFactory" /> 返回 <see langword="null" />。
/// </exception> /// </exception>
public TValue GetOrAdd<TState>(TKey key, TState state, Func<TKey, TState, TValue> valueFactory) public TValue GetOrAdd<TState>(TKey key, TState state, Func<TKey, TState, TValue> valueFactory)
{ {