M.E.C.M. Add TryGetValue(ReadOnlySpan<char>) API#112695
Conversation
|
Note regarding the |
1 similar comment
|
Note regarding the |
- demand GetAlternateLookup works on the target runtimes - rely on documented "out set to default on failure" lookup behavior
|
@stephentoub made less defensive in 4f60149, per feedback |
…into marc/MECMSpanGet
| public bool TryGetValue(System.ReadOnlySpan<char> key, out object? value) { throw null; } | ||
| [System.Runtime.CompilerServices.OverloadResolutionPriority(1)] | ||
| public bool TryGetValue<TItem>(System.ReadOnlySpan<char> key, out TItem? value) { throw null; } | ||
| #endif |
There was a problem hiding this comment.
This will get stomped on when anyone runs the ref generator. We prefer to put such TFM-specific methods in a separator file, e.g. https://github.com/dotnet/runtime/blob/d63f63725a6fd71c7b723640a2418d0f7a30e7bc/src/libraries/Microsoft.Extensions.Caching.Abstractions/ref/Microsoft.Extensions.Caching.Abstractions.netcoreapp.cs
|
|
||
| CoherentState coherentState = _coherentState; // Clear() can update the reference in the meantime | ||
| if (coherentState.TryGetValue(key, out CacheEntry? tmp)) | ||
| coherentState.TryGetValue(key, out CacheEntry? entry); // note we rely on documented "default when fails" contract re the out |
There was a problem hiding this comment.
We could formalize the comment with an assert, e.g.
| coherentState.TryGetValue(key, out CacheEntry? entry); // note we rely on documented "default when fails" contract re the out | |
| bool success = coherentState.TryGetValue(key, out CacheEntry? entry); | |
| Debug.Assert(success || entry is null, "We rely on documented 'default when fails' contract."); |
| /// <param name="value">The located value or null.</param> | ||
| /// <returns>True if the key was found.</returns> | ||
| /// <remarks>This method allows values with <see cref="string"/> keys to be queried by content without allocating a new <see cref="string"/> instance.</remarks> | ||
| [OverloadResolutionPriority(1)] |
|
This didn't actually run CI |
|
It also merged with https://github.com/dotnet/runtime/pull/112695/files#r1963779247 unaddressed |
|
Well shoot, it was all briefly green. Will fix: sorry.
…On Thu, 20 Feb 2025, 16:00 Stephen Toub, ***@***.***> wrote:
It also merged with
https://github.com/dotnet/runtime/pull/112695/files#r1963779247
unaddressed
—
Reply to this email directly, view it on GitHub
<#112695 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMEQJOGMXH7NN7MLLBT2QX3Z7AVCNFSM6AAAAABXOPZ4Q6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZRHEZTINBWGY>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: stephentoub]*stephentoub* left a comment (dotnet/runtime#112695)
<#112695 (comment)>
It also merged with
https://github.com/dotnet/runtime/pull/112695/files#r1963779247
unaddressed
—
Reply to this email directly, view it on GitHub
<#112695 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMEQJOGMXH7NN7MLLBT2QX3Z7AVCNFSM6AAAAABXOPZ4Q6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZRHEZTINBWGY>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Implement
MemoryCache.TryGetValueAPIs takingReadOnlySpan<char>, as approved in #110504fix #110504