diff --git a/src/Docker.DotNet/Endpoints/PluginOperations.cs b/src/Docker.DotNet/Endpoints/PluginOperations.cs index 80fc7e21..38ae57c0 100644 --- a/src/Docker.DotNet/Endpoints/PluginOperations.cs +++ b/src/Docker.DotNet/Endpoints/PluginOperations.cs @@ -60,7 +60,7 @@ internal PluginOperations(DockerClient client) IQueryString queryParameters = new QueryString(parameters); return StreamUtil.MonitorStreamForMessagesAsync( - _client.MakeRequestForStreamAsync(_client.NoErrorHandlers, HttpMethod.Post, "plugins/pull", queryParameters, data, null, CancellationToken.None), + _client.MakeRequestForStreamAsync(_client.NoErrorHandlers, HttpMethod.Post, $"plugins/pull", queryParameters, data, null, CancellationToken.None), _client, cancellationToken, progress); @@ -145,7 +145,7 @@ public async Task InspectPluginAsync(string name, CancellationToken canc var query = new QueryString(parameters); var data = new BinaryRequestContent(plugin, TarContentType); - return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "plugins/create", query, data, cancellationToken); + return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, $"plugins/create", query, data, cancellationToken); } public Task PushPluginAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) diff --git a/test/Docker.DotNet.Tests/ISystemOperations.Tests.cs b/test/Docker.DotNet.Tests/ISystemOperations.Tests.cs index ea60e88d..8cc13ad0 100644 --- a/test/Docker.DotNet.Tests/ISystemOperations.Tests.cs +++ b/test/Docker.DotNet.Tests/ISystemOperations.Tests.cs @@ -39,7 +39,7 @@ public ISystemOperationsTests(TestFixture testFixture, ITestOutputHelper outputH [Fact] public void Docker_IsRunning() { - var dockerProcess = Process.GetProcesses().FirstOrDefault(process => process.ProcessName.Equals("docker", StringComparison.InvariantCultureIgnoreCase) || process.ProcessName.Equals("dockerd", StringComparison.InvariantCultureIgnoreCase)); + var dockerProcess = Process.GetProcesses().FirstOrDefault(_ => _.ProcessName.Equals("docker", StringComparison.InvariantCultureIgnoreCase) || _.ProcessName.Equals("dockerd", StringComparison.InvariantCultureIgnoreCase)); Assert.NotNull(dockerProcess); // docker is not running } @@ -63,7 +63,7 @@ public async Task MonitorEventsAsync_EmptyContainersList_CanBeCancelled() var progress = new Progress(); using var cts = new CancellationTokenSource(); - await cts.CancelAsync(); + cts.Cancel(); await Task.Delay(1); await Assert.ThrowsAsync(() => _dockerClient.System.MonitorEventsAsync(new ContainerEventsParameters(), progress, cts.Token)); @@ -116,7 +116,7 @@ await _dockerClient.Images.DeleteImageAsync( // Give it some time for output operation to complete before cancelling task await Task.Delay(TimeSpan.FromSeconds(1)); - await cts.CancelAsync(); + cts.Cancel(); await Assert.ThrowsAsync(() => task).ConfigureAwait(false); @@ -144,7 +144,7 @@ public async Task MonitorEventsAsync_IsCancelled_NoStreamCorruption() cts.Token); // (2) Wait for some time to make sure we get into blocking IO call - await Task.Delay(100, CancellationToken.None); + await Task.Delay(100); // (3) Invoke another request that will attempt to grab the same buffer var listImagesTask1 = _dockerClient.Images.TagImageAsync( @@ -153,32 +153,33 @@ public async Task MonitorEventsAsync_IsCancelled_NoStreamCorruption() { RepositoryName = _repositoryName, Tag = newImageTag, - }, CancellationToken.None); + }, + default); // (4) Wait for a short bit again and cancel the monitor task - if we get lucky, we the list images call will grab the same buffer while sw.Restart(); var iterations = rand.Next(15000000); - for (var j = 0; j < iterations; j++) + for (int j = 0; j < iterations; j++) { // noop } - _output.WriteLine($"Waited for {sw.Elapsed.TotalMilliseconds} ms"); - await cts.CancelAsync(); + cts.Cancel(); - await listImagesTask1; + listImagesTask1.GetAwaiter().GetResult(); - await _dockerClient.Images.TagImageAsync( + _dockerClient.Images.TagImageAsync( $"{_repositoryName}:{_tag}", new ImageTagParameters { RepositoryName = _repositoryName, Tag = newImageTag, - }, CancellationToken.None); + } + ).GetAwaiter().GetResult(); - await monitorTask; + monitorTask.GetAwaiter().GetResult(); } catch (OperationCanceledException) { @@ -261,7 +262,7 @@ await _dockerClient.Images.TagImageAsync( await _dockerClient.Containers.RemoveContainerAsync(createContainerResponse.ID, new ContainerRemoveParameters(), cts.Token); await Task.Delay(TimeSpan.FromSeconds(1)); - await cts.CancelAsync(); + cts.Cancel(); await Assert.ThrowsAsync(() => task); @@ -275,4 +276,4 @@ public async Task PingAsync_Succeeds() await _dockerClient.System.PingAsync(); } } -} +} \ No newline at end of file diff --git a/tools/specgen/specgen.exe b/tools/specgen/specgen.exe new file mode 100644 index 00000000..e48a1c84 Binary files /dev/null and b/tools/specgen/specgen.exe differ