-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Use generics in syncing code. #72929
Conversation
@@ -83,7 +83,7 @@ public async Task TestAssetSynchronization() | |||
var assetSource = new SimpleAssetSource(workspace.Services.GetService<ISerializerService>(), map); | |||
|
|||
var service = new AssetProvider(sessionId, storage, assetSource, remoteWorkspace.Services.GetService<ISerializerService>()); | |||
await service.SynchronizeAssetsAsync(AssetPath.FullLookupForTesting, new HashSet<Checksum>(map.Keys), results: null, CancellationToken.None); | |||
await service.SynchronizeAssetsAsync<object>(AssetPath.FullLookupForTesting, new HashSet<Checksum>(map.Keys), results: null, CancellationToken.None); |
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.
<object>
is used when the request is genuinely asking for heterogenous data.
@@ -39,24 +39,24 @@ internal sealed partial class AssetProvider(Checksum solutionChecksum, SolutionA | |||
using var _1 = PooledHashSet<Checksum>.GetInstance(out var checksums); | |||
checksums.Add(checksum); | |||
|
|||
using var _2 = PooledDictionary<Checksum, object>.GetInstance(out var results); | |||
using var _2 = PooledDictionary<Checksum, T>.GetInstance(out var results); |
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.
the method this is in is already generic. so this now allows that generic information to flow into SynchronizeAssetsAsync
} | ||
|
||
public override async ValueTask<ImmutableArray<(Checksum checksum, T asset)>> GetAssetsAsync<T>( | ||
AssetPath assetPath, HashSet<Checksum> checksums, CancellationToken cancellationToken) | ||
{ | ||
using var _ = PooledDictionary<Checksum, object>.GetInstance(out var results); | ||
using var _ = PooledDictionary<Checksum, T>.GetInstance(out var results); | ||
|
||
await this.SynchronizeAssetsAsync(assetPath, checksums, results, cancellationToken).ConfigureAwait(false); |
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.
the method this is in is already generic. so this now allows that generic information to flow into SynchronizeAssetsAsync
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.
@jasonmalinowski For review when you get back. |
This has the added benefit of being able to add logs that can track what type teh caller is asking for.