-
Notifications
You must be signed in to change notification settings - Fork 5k
M.E.C.M. Add TryGetValue(ReadOnlySpan<char>) API #112695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
src/libraries/Microsoft.Extensions.Caching.Memory/tests/AltLookupTests.cs
Outdated
Show resolved
Hide resolved
|
||
#if NET9_0_OR_GREATER | ||
[OverloadResolutionPriority(1)] | ||
public bool TryGetValue(ReadOnlySpan<char> key, out object? result) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add proper XML documentation comments to describe the purpose and parameters of this method.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is in src - let me know if I'm wrong (humans., I mean)
[OverloadResolutionPriority(1)] | ||
public bool TryGetValue(ReadOnlySpan<char> key, out object? result) { throw null; } | ||
[OverloadResolutionPriority(1)] | ||
public bool TryGetValue<TItem>(ReadOnlySpan<char> key, out TItem? value) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add proper XML documentation comments to describe the purpose and parameters of this method.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is in src - let me know if I'm wrong (humans., I mean)
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs
Outdated
Show resolved
Hide resolved
- 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 |
src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs
Outdated
Show resolved
Hide resolved
…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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -211,9 +211,68 @@ public bool TryGetValue(object key, out object? result) | |||
DateTime utcNow = UtcNow; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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."); |
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs
Outdated
Show resolved
Hide resolved
/// <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)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.TryGetValue
APIs takingReadOnlySpan<char>
, as approved in #110504fix #110504