- Notifications
You must be signed in to change notification settings - Fork5.2k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedFeb 19, 2025
Note regarding the |
1 similar comment
ghost commentedFeb 19, 2025
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 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
- demand GetAlternateLookup works on the target runtimes- rely on documented "out set to default on failure" lookup behavior
mgravell commentedFeb 19, 2025
@stephentoub made less defensive in4f60149, per feedback |
src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| publicboolTryGetValue(System.ReadOnlySpan<char>key,outobject?value){thrownull;} | ||
| [System.Runtime.CompilerServices.OverloadResolutionPriority(1)] | ||
| publicboolTryGetValue<TItem>(System.ReadOnlySpan<char>key,outTItem?value){thrownull;} | ||
| #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
| CoherentStatecoherentState=_coherentState;// Clear() can update the reference in the meantime | ||
| if(coherentState.TryGetValue(key,outCacheEntry?tmp)) | ||
| coherentState.TryGetValue(key,outCacheEntry?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,outCacheEntry?entry);// note we rely on documented "default when fails" contract re the out | |
| boolsuccess=coherentState.TryGetValue(key,outCacheEntry?entry); | |
| Debug.Assert(success||entryisnull,"We rely on documented 'default when fails' contract."); |
src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| /// <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.
7e9343b intodotnet:mainUh oh!
There was an error while loading.Please reload this page.
stephentoub commentedFeb 20, 2025
This didn't actually run CI |
stephentoub commentedFeb 20, 2025
It also merged withhttps://github.com/dotnet/runtime/pull/112695/files#r1963779247 unaddressed |
mgravell commentedFeb 20, 2025 via email
Well shoot, it was all briefly green. Will fix: sorry. …On Thu, 20 Feb 2025, 16:00 Stephen Toub, ***@***.***> wrote: It also merged withhttps://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 withhttps://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