@azure-typespec/http-client-csharp-mgmt 1.0.0-alpha.20250409.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emitter/emitter.d.ts +4 -0
- package/dist/emitter/emitter.d.ts.map +1 -0
- package/dist/emitter/emitter.js +77 -0
- package/dist/emitter/emitter.js.map +1 -0
- package/dist/emitter/index.d.ts +2 -0
- package/dist/emitter/index.d.ts.map +1 -0
- package/dist/emitter/index.js +4 -0
- package/dist/emitter/index.js.map +1 -0
- package/dist/emitter/resource-type.d.ts +2 -0
- package/dist/emitter/resource-type.d.ts.map +1 -0
- package/dist/emitter/resource-type.js +31 -0
- package/dist/emitter/resource-type.js.map +1 -0
- package/dist/emitter/sdk-context-options.d.ts +3 -0
- package/dist/emitter/sdk-context-options.d.ts.map +1 -0
- package/dist/emitter/sdk-context-options.js +23 -0
- package/dist/emitter/sdk-context-options.js.map +1 -0
- package/dist/generator/Azure.Core.dll +0 -0
- package/dist/generator/Azure.Generator.Mgmt.deps.json +998 -0
- package/dist/generator/Azure.Generator.Mgmt.dll +0 -0
- package/dist/generator/Azure.Generator.Mgmt.pdb +0 -0
- package/dist/generator/Azure.Generator.Mgmt.xml +818 -0
- package/dist/generator/Azure.Generator.dll +0 -0
- package/dist/generator/Azure.Generator.pdb +0 -0
- package/dist/generator/Azure.Generator.xml +163 -0
- package/dist/generator/Azure.ResourceManager.dll +0 -0
- package/dist/generator/CommandLine.dll +0 -0
- package/dist/generator/Humanizer.dll +0 -0
- package/dist/generator/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/dist/generator/Microsoft.Build.Framework.dll +0 -0
- package/dist/generator/Microsoft.Build.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.dll +0 -0
- package/dist/generator/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- package/dist/generator/Microsoft.NET.StringTools.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.ClientModel.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.Input.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.runtimeconfig.json +12 -0
- package/dist/generator/NuGet.Common.dll +0 -0
- package/dist/generator/NuGet.Configuration.dll +0 -0
- package/dist/generator/NuGet.Frameworks.dll +0 -0
- package/dist/generator/Shared/Core/AppContextSwitchHelper.cs +42 -0
- package/dist/generator/Shared/Core/AsyncLockWithValue.cs +260 -0
- package/dist/generator/Shared/Core/AzureKeyCredentialPolicy.cs +50 -0
- package/dist/generator/Shared/Core/ClientDiagnostics.cs +73 -0
- package/dist/generator/Shared/Core/DiagnosticScope.cs +473 -0
- package/dist/generator/Shared/Core/DiagnosticScopeFactory.cs +104 -0
- package/dist/generator/Shared/Core/FixedDelayWithNoJitterStrategy.cs +26 -0
- package/dist/generator/Shared/Core/HttpMessageSanitizer.cs +198 -0
- package/dist/generator/Shared/Core/IOperationSource.cs +14 -0
- package/dist/generator/Shared/Core/NextLinkOperationImplementation.cs +690 -0
- package/dist/generator/Shared/Core/OperationFinalStateVia.cs +16 -0
- package/dist/generator/Shared/Core/OperationInternal.cs +256 -0
- package/dist/generator/Shared/Core/OperationInternalBase.cs +234 -0
- package/dist/generator/Shared/Core/OperationInternalOfT.cs +422 -0
- package/dist/generator/Shared/Core/OperationPoller.cs +114 -0
- package/dist/generator/Shared/Core/RawRequestUriBuilder.cs +192 -0
- package/dist/generator/Shared/Core/SequentialDelayStrategy.cs +38 -0
- package/dist/generator/Shared/Core/TaskExtensions.cs +313 -0
- package/dist/generator/Shared/Core/VoidValue.cs +10 -0
- package/dist/generator/System.ClientModel.dll +0 -0
- package/dist/generator/System.ComponentModel.Composition.dll +0 -0
- package/dist/generator/System.Composition.AttributedModel.dll +0 -0
- package/dist/generator/System.Composition.Convention.dll +0 -0
- package/dist/generator/System.Composition.Hosting.dll +0 -0
- package/dist/generator/System.Composition.Runtime.dll +0 -0
- package/dist/generator/System.Composition.TypedParts.dll +0 -0
- package/dist/generator/System.Configuration.ConfigurationManager.dll +0 -0
- package/dist/generator/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/System.IO.Pipelines.dll +0 -0
- package/dist/generator/System.Memory.Data.dll +0 -0
- package/dist/generator/System.Reflection.MetadataLoadContext.dll +0 -0
- package/dist/generator/System.Security.Cryptography.ProtectedData.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/Azure.Core.dll +0 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.deps.json +998 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.dll +0 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.pdb +0 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.xml +818 -0
- package/dist/generator/net8.0/Azure.Generator.dll +0 -0
- package/dist/generator/net8.0/Azure.Generator.pdb +0 -0
- package/dist/generator/net8.0/Azure.Generator.xml +163 -0
- package/dist/generator/net8.0/Azure.ResourceManager.dll +0 -0
- package/dist/generator/net8.0/CommandLine.dll +0 -0
- package/dist/generator/net8.0/Humanizer.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Build.Framework.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Build.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- package/dist/generator/net8.0/Microsoft.NET.StringTools.dll +0 -0
- package/dist/generator/net8.0/Microsoft.TypeSpec.Generator.ClientModel.dll +0 -0
- package/dist/generator/net8.0/Microsoft.TypeSpec.Generator.Input.dll +0 -0
- package/dist/generator/net8.0/Microsoft.TypeSpec.Generator.dll +0 -0
- package/dist/generator/net8.0/NuGet.Common.dll +0 -0
- package/dist/generator/net8.0/NuGet.Configuration.dll +0 -0
- package/dist/generator/net8.0/NuGet.Frameworks.dll +0 -0
- package/dist/generator/net8.0/Shared/Core/AppContextSwitchHelper.cs +42 -0
- package/dist/generator/net8.0/Shared/Core/AsyncLockWithValue.cs +260 -0
- package/dist/generator/net8.0/Shared/Core/AzureKeyCredentialPolicy.cs +50 -0
- package/dist/generator/net8.0/Shared/Core/ClientDiagnostics.cs +73 -0
- package/dist/generator/net8.0/Shared/Core/DiagnosticScope.cs +473 -0
- package/dist/generator/net8.0/Shared/Core/DiagnosticScopeFactory.cs +104 -0
- package/dist/generator/net8.0/Shared/Core/FixedDelayWithNoJitterStrategy.cs +26 -0
- package/dist/generator/net8.0/Shared/Core/HttpMessageSanitizer.cs +198 -0
- package/dist/generator/net8.0/Shared/Core/IOperationSource.cs +14 -0
- package/dist/generator/net8.0/Shared/Core/NextLinkOperationImplementation.cs +690 -0
- package/dist/generator/net8.0/Shared/Core/OperationFinalStateVia.cs +16 -0
- package/dist/generator/net8.0/Shared/Core/OperationInternal.cs +256 -0
- package/dist/generator/net8.0/Shared/Core/OperationInternalBase.cs +234 -0
- package/dist/generator/net8.0/Shared/Core/OperationInternalOfT.cs +422 -0
- package/dist/generator/net8.0/Shared/Core/OperationPoller.cs +114 -0
- package/dist/generator/net8.0/Shared/Core/RawRequestUriBuilder.cs +192 -0
- package/dist/generator/net8.0/Shared/Core/SequentialDelayStrategy.cs +38 -0
- package/dist/generator/net8.0/Shared/Core/TaskExtensions.cs +313 -0
- package/dist/generator/net8.0/Shared/Core/VoidValue.cs +10 -0
- package/dist/generator/net8.0/System.ClientModel.dll +0 -0
- package/dist/generator/net8.0/System.ComponentModel.Composition.dll +0 -0
- package/dist/generator/net8.0/System.Composition.AttributedModel.dll +0 -0
- package/dist/generator/net8.0/System.Composition.Convention.dll +0 -0
- package/dist/generator/net8.0/System.Composition.Hosting.dll +0 -0
- package/dist/generator/net8.0/System.Composition.Runtime.dll +0 -0
- package/dist/generator/net8.0/System.Composition.TypedParts.dll +0 -0
- package/dist/generator/net8.0/System.Configuration.ConfigurationManager.dll +0 -0
- package/dist/generator/net8.0/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/net8.0/System.IO.Pipelines.dll +0 -0
- package/dist/generator/net8.0/System.Memory.Data.dll +0 -0
- package/dist/generator/net8.0/System.Reflection.MetadataLoadContext.dll +0 -0
- package/dist/generator/net8.0/System.Security.Cryptography.ProtectedData.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- package/dist/generator/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- package/dist/generator/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/package.json +67 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#nullable enable
|
|
5
|
+
|
|
6
|
+
using System;
|
|
7
|
+
using System.Globalization;
|
|
8
|
+
using System.IO;
|
|
9
|
+
|
|
10
|
+
namespace Azure.Core
|
|
11
|
+
{
|
|
12
|
+
internal class RawRequestUriBuilder: RequestUriBuilder
|
|
13
|
+
{
|
|
14
|
+
private const string SchemeSeparator = "://";
|
|
15
|
+
private const char HostSeparator = '/';
|
|
16
|
+
private const char PortSeparator = ':';
|
|
17
|
+
private static readonly char[] HostOrPort = { HostSeparator, PortSeparator };
|
|
18
|
+
private const char QueryBeginSeparator = '?';
|
|
19
|
+
private const char QueryContinueSeparator = '&';
|
|
20
|
+
private const char QueryValueSeparator = '=';
|
|
21
|
+
|
|
22
|
+
private RawWritingPosition? _position;
|
|
23
|
+
|
|
24
|
+
private static void GetQueryParts(ReadOnlySpan<char> queryUnparsed, out ReadOnlySpan<char> name, out ReadOnlySpan<char> value)
|
|
25
|
+
{
|
|
26
|
+
int separatorIndex = queryUnparsed.IndexOf(QueryValueSeparator);
|
|
27
|
+
if (separatorIndex == -1)
|
|
28
|
+
{
|
|
29
|
+
name = queryUnparsed;
|
|
30
|
+
value = ReadOnlySpan<char>.Empty;
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
{
|
|
34
|
+
name = queryUnparsed.Slice(0, separatorIndex);
|
|
35
|
+
value = queryUnparsed.Slice(separatorIndex + 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public void AppendRaw(string value, bool escape)
|
|
40
|
+
{
|
|
41
|
+
AppendRaw(value.AsSpan(), escape);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private void AppendRaw(ReadOnlySpan<char> value, bool escape)
|
|
45
|
+
{
|
|
46
|
+
if (_position == null)
|
|
47
|
+
{
|
|
48
|
+
if (HasQuery)
|
|
49
|
+
{
|
|
50
|
+
_position = RawWritingPosition.Query;
|
|
51
|
+
}
|
|
52
|
+
else if (HasPath)
|
|
53
|
+
{
|
|
54
|
+
_position = RawWritingPosition.Path;
|
|
55
|
+
}
|
|
56
|
+
else if (!string.IsNullOrEmpty(Host))
|
|
57
|
+
{
|
|
58
|
+
_position = RawWritingPosition.Host;
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
{
|
|
62
|
+
_position = RawWritingPosition.Scheme;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
while (!value.IsEmpty)
|
|
67
|
+
{
|
|
68
|
+
if (_position == RawWritingPosition.Scheme)
|
|
69
|
+
{
|
|
70
|
+
int separator = value.IndexOf(SchemeSeparator.AsSpan(), StringComparison.InvariantCultureIgnoreCase);
|
|
71
|
+
if (separator == -1)
|
|
72
|
+
{
|
|
73
|
+
Scheme += value.ToString();
|
|
74
|
+
value = ReadOnlySpan<char>.Empty;
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
{
|
|
78
|
+
Scheme += value.Slice(0, separator).ToString();
|
|
79
|
+
// TODO: Find a better way to map schemes to default ports
|
|
80
|
+
Port = string.Equals(Scheme, "https", StringComparison.OrdinalIgnoreCase) ? 443 : 80;
|
|
81
|
+
value = value.Slice(separator + SchemeSeparator.Length);
|
|
82
|
+
_position = RawWritingPosition.Host;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (_position == RawWritingPosition.Host)
|
|
86
|
+
{
|
|
87
|
+
int separator = value.IndexOfAny(HostOrPort);
|
|
88
|
+
if (separator == -1)
|
|
89
|
+
{
|
|
90
|
+
if (!HasPath)
|
|
91
|
+
{
|
|
92
|
+
Host += value.ToString();
|
|
93
|
+
value = ReadOnlySpan<char>.Empty;
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
{
|
|
97
|
+
// All Host information must be written before Path information
|
|
98
|
+
// If Path already has information, we transition to writing Path
|
|
99
|
+
_position = RawWritingPosition.Path;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
{
|
|
104
|
+
Host += value.Slice(0, separator).ToString();
|
|
105
|
+
_position = value[separator] == HostSeparator ? RawWritingPosition.Path : RawWritingPosition.Port;
|
|
106
|
+
value = value.Slice(separator + 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (_position == RawWritingPosition.Port)
|
|
110
|
+
{
|
|
111
|
+
int separator = value.IndexOf(HostSeparator);
|
|
112
|
+
if (separator == -1)
|
|
113
|
+
{
|
|
114
|
+
#if NETCOREAPP2_1_OR_GREATER
|
|
115
|
+
Port = int.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture);
|
|
116
|
+
#else
|
|
117
|
+
Port = int.Parse(value.ToString(), CultureInfo.InvariantCulture);
|
|
118
|
+
#endif
|
|
119
|
+
value = ReadOnlySpan<char>.Empty;
|
|
120
|
+
}
|
|
121
|
+
else
|
|
122
|
+
{
|
|
123
|
+
#if NETCOREAPP2_1_OR_GREATER
|
|
124
|
+
Port = int.Parse(value.Slice(0, separator), NumberStyles.Integer, CultureInfo.InvariantCulture);
|
|
125
|
+
#else
|
|
126
|
+
Port = int.Parse(value.Slice(0, separator).ToString(), CultureInfo.InvariantCulture);
|
|
127
|
+
#endif
|
|
128
|
+
value = value.Slice(separator + 1);
|
|
129
|
+
}
|
|
130
|
+
// Port cannot be split (like Host), so always transition to Path when Port is parsed
|
|
131
|
+
_position = RawWritingPosition.Path;
|
|
132
|
+
}
|
|
133
|
+
else if (_position == RawWritingPosition.Path)
|
|
134
|
+
{
|
|
135
|
+
int separator = value.IndexOf(QueryBeginSeparator);
|
|
136
|
+
if (separator == -1)
|
|
137
|
+
{
|
|
138
|
+
AppendPath(value, escape);
|
|
139
|
+
value = ReadOnlySpan<char>.Empty;
|
|
140
|
+
}
|
|
141
|
+
else
|
|
142
|
+
{
|
|
143
|
+
AppendPath(value.Slice(0, separator), escape);
|
|
144
|
+
value = value.Slice(separator + 1);
|
|
145
|
+
_position = RawWritingPosition.Query;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else if (_position == RawWritingPosition.Query)
|
|
149
|
+
{
|
|
150
|
+
int separator = value.IndexOf(QueryContinueSeparator);
|
|
151
|
+
if (separator == 0)
|
|
152
|
+
{
|
|
153
|
+
value = value.Slice(1);
|
|
154
|
+
}
|
|
155
|
+
else if (separator == -1)
|
|
156
|
+
{
|
|
157
|
+
GetQueryParts(value, out var queryName, out var queryValue);
|
|
158
|
+
AppendQuery(queryName, queryValue, escape);
|
|
159
|
+
value = ReadOnlySpan<char>.Empty;
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
{
|
|
163
|
+
GetQueryParts(value.Slice(0, separator), out var queryName, out var queryValue);
|
|
164
|
+
AppendQuery(queryName, queryValue, escape);
|
|
165
|
+
value = value.Slice(separator + 1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private enum RawWritingPosition
|
|
172
|
+
{
|
|
173
|
+
Scheme,
|
|
174
|
+
Host,
|
|
175
|
+
Port,
|
|
176
|
+
Path,
|
|
177
|
+
Query
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public void AppendRawNextLink(string nextLink, bool escape)
|
|
181
|
+
{
|
|
182
|
+
// If it is an absolute link, we use the nextLink as the entire url
|
|
183
|
+
if (nextLink.StartsWith(Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase))
|
|
184
|
+
{
|
|
185
|
+
Reset(new Uri(nextLink));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
AppendRaw(nextLink, escape);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
using System;
|
|
5
|
+
|
|
6
|
+
#nullable enable
|
|
7
|
+
|
|
8
|
+
namespace Azure.Core
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// A delay strategy that uses a fixed sequence of delays with no jitter applied. This is used by management LROs.
|
|
12
|
+
/// </summary>
|
|
13
|
+
internal class SequentialDelayStrategy : DelayStrategy
|
|
14
|
+
{
|
|
15
|
+
private static readonly TimeSpan[] _pollingSequence = new TimeSpan[]
|
|
16
|
+
{
|
|
17
|
+
TimeSpan.FromSeconds(1),
|
|
18
|
+
TimeSpan.FromSeconds(1),
|
|
19
|
+
TimeSpan.FromSeconds(1),
|
|
20
|
+
TimeSpan.FromSeconds(2),
|
|
21
|
+
TimeSpan.FromSeconds(4),
|
|
22
|
+
TimeSpan.FromSeconds(8),
|
|
23
|
+
TimeSpan.FromSeconds(16),
|
|
24
|
+
TimeSpan.FromSeconds(32)
|
|
25
|
+
};
|
|
26
|
+
private static readonly TimeSpan _maxDelay = _pollingSequence[_pollingSequence.Length - 1];
|
|
27
|
+
|
|
28
|
+
public SequentialDelayStrategy() : base(_maxDelay, 0)
|
|
29
|
+
{
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected override TimeSpan GetNextDelayCore(Response? response, int retryNumber)
|
|
33
|
+
{
|
|
34
|
+
int index = retryNumber - 1;
|
|
35
|
+
return index >= _pollingSequence.Length ? _maxDelay : _pollingSequence[index];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#nullable disable
|
|
5
|
+
|
|
6
|
+
using System;
|
|
7
|
+
using System.Collections;
|
|
8
|
+
using System.Collections.Generic;
|
|
9
|
+
using System.Diagnostics;
|
|
10
|
+
using System.Runtime.CompilerServices;
|
|
11
|
+
using System.Threading;
|
|
12
|
+
using System.Threading.Tasks;
|
|
13
|
+
|
|
14
|
+
namespace Azure.Core.Pipeline
|
|
15
|
+
{
|
|
16
|
+
internal static class TaskExtensions
|
|
17
|
+
{
|
|
18
|
+
public static WithCancellationTaskAwaitable AwaitWithCancellation(this Task task, CancellationToken cancellationToken)
|
|
19
|
+
=> new WithCancellationTaskAwaitable(task, cancellationToken);
|
|
20
|
+
|
|
21
|
+
public static WithCancellationTaskAwaitable<T> AwaitWithCancellation<T>(this Task<T> task, CancellationToken cancellationToken)
|
|
22
|
+
=> new WithCancellationTaskAwaitable<T>(task, cancellationToken);
|
|
23
|
+
|
|
24
|
+
public static WithCancellationValueTaskAwaitable<T> AwaitWithCancellation<T>(this ValueTask<T> task, CancellationToken cancellationToken)
|
|
25
|
+
=> new WithCancellationValueTaskAwaitable<T>(task, cancellationToken);
|
|
26
|
+
|
|
27
|
+
public static T EnsureCompleted<T>(this Task<T> task)
|
|
28
|
+
{
|
|
29
|
+
#if DEBUG
|
|
30
|
+
VerifyTaskCompleted(task.IsCompleted);
|
|
31
|
+
#endif
|
|
32
|
+
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
33
|
+
return task.GetAwaiter().GetResult();
|
|
34
|
+
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public static void EnsureCompleted(this Task task)
|
|
38
|
+
{
|
|
39
|
+
#if DEBUG
|
|
40
|
+
VerifyTaskCompleted(task.IsCompleted);
|
|
41
|
+
#endif
|
|
42
|
+
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
43
|
+
task.GetAwaiter().GetResult();
|
|
44
|
+
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static T EnsureCompleted<T>(this ValueTask<T> task)
|
|
48
|
+
{
|
|
49
|
+
#if DEBUG
|
|
50
|
+
VerifyTaskCompleted(task.IsCompleted);
|
|
51
|
+
#endif
|
|
52
|
+
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
53
|
+
return task.GetAwaiter().GetResult();
|
|
54
|
+
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static void EnsureCompleted(this ValueTask task)
|
|
58
|
+
{
|
|
59
|
+
#if DEBUG
|
|
60
|
+
VerifyTaskCompleted(task.IsCompleted);
|
|
61
|
+
#endif
|
|
62
|
+
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
63
|
+
task.GetAwaiter().GetResult();
|
|
64
|
+
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead.
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public static Enumerable<T> EnsureSyncEnumerable<T>(this IAsyncEnumerable<T> asyncEnumerable) => new Enumerable<T>(asyncEnumerable);
|
|
68
|
+
|
|
69
|
+
public static ConfiguredValueTaskAwaitable<T> EnsureCompleted<T>(this ConfiguredValueTaskAwaitable<T> awaitable, bool async)
|
|
70
|
+
{
|
|
71
|
+
if (!async)
|
|
72
|
+
{
|
|
73
|
+
#if DEBUG
|
|
74
|
+
VerifyTaskCompleted(awaitable.GetAwaiter().IsCompleted);
|
|
75
|
+
#endif
|
|
76
|
+
}
|
|
77
|
+
return awaitable;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public static ConfiguredValueTaskAwaitable EnsureCompleted(this ConfiguredValueTaskAwaitable awaitable, bool async)
|
|
81
|
+
{
|
|
82
|
+
if (!async)
|
|
83
|
+
{
|
|
84
|
+
#if DEBUG
|
|
85
|
+
VerifyTaskCompleted(awaitable.GetAwaiter().IsCompleted);
|
|
86
|
+
#endif
|
|
87
|
+
}
|
|
88
|
+
return awaitable;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[Conditional("DEBUG")]
|
|
92
|
+
private static void VerifyTaskCompleted(bool isCompleted)
|
|
93
|
+
{
|
|
94
|
+
if (!isCompleted)
|
|
95
|
+
{
|
|
96
|
+
if (Debugger.IsAttached)
|
|
97
|
+
{
|
|
98
|
+
Debugger.Break();
|
|
99
|
+
}
|
|
100
|
+
// Throw an InvalidOperationException instead of using
|
|
101
|
+
// Debug.Assert because that brings down nUnit immediately
|
|
102
|
+
throw new InvalidOperationException("Task is not completed");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// <summary>
|
|
107
|
+
/// Both <see cref="Enumerable{T}"/> and <see cref="Enumerator{T}"/> are defined as public structs so that foreach can use duck typing
|
|
108
|
+
/// to call <see cref="Enumerable{T}.GetEnumerator"/> and avoid heap memory allocation.
|
|
109
|
+
/// Please don't delete this method and don't make these types private.
|
|
110
|
+
/// </summary>
|
|
111
|
+
/// <typeparam name="T"></typeparam>
|
|
112
|
+
public readonly struct Enumerable<T> : IEnumerable<T>
|
|
113
|
+
{
|
|
114
|
+
private readonly IAsyncEnumerable<T> _asyncEnumerable;
|
|
115
|
+
|
|
116
|
+
public Enumerable(IAsyncEnumerable<T> asyncEnumerable) => _asyncEnumerable = asyncEnumerable;
|
|
117
|
+
|
|
118
|
+
public Enumerator<T> GetEnumerator() => new Enumerator<T>(_asyncEnumerable.GetAsyncEnumerator());
|
|
119
|
+
|
|
120
|
+
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator<T>(_asyncEnumerable.GetAsyncEnumerator());
|
|
121
|
+
|
|
122
|
+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public readonly struct Enumerator<T> : IEnumerator<T>
|
|
126
|
+
{
|
|
127
|
+
private readonly IAsyncEnumerator<T> _asyncEnumerator;
|
|
128
|
+
|
|
129
|
+
public Enumerator(IAsyncEnumerator<T> asyncEnumerator) => _asyncEnumerator = asyncEnumerator;
|
|
130
|
+
|
|
131
|
+
#pragma warning disable AZC0107 // Do not call public asynchronous method in synchronous scope.
|
|
132
|
+
public bool MoveNext() => _asyncEnumerator.MoveNextAsync().EnsureCompleted();
|
|
133
|
+
#pragma warning restore AZC0107 // Do not call public asynchronous method in synchronous scope.
|
|
134
|
+
|
|
135
|
+
public void Reset() => throw new NotSupportedException($"{GetType()} is a synchronous wrapper for {_asyncEnumerator.GetType()} async enumerator, which can't be reset, so IEnumerable.Reset() calls aren't supported.");
|
|
136
|
+
|
|
137
|
+
public T Current => _asyncEnumerator.Current;
|
|
138
|
+
|
|
139
|
+
object IEnumerator.Current => Current;
|
|
140
|
+
|
|
141
|
+
#pragma warning disable AZC0107 // Do not call public asynchronous method in synchronous scope.
|
|
142
|
+
public void Dispose() => _asyncEnumerator.DisposeAsync().EnsureCompleted();
|
|
143
|
+
#pragma warning restore AZC0107 // Do not call public asynchronous method in synchronous scope.
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public readonly struct WithCancellationTaskAwaitable
|
|
147
|
+
{
|
|
148
|
+
private readonly CancellationToken _cancellationToken;
|
|
149
|
+
private readonly ConfiguredTaskAwaitable _awaitable;
|
|
150
|
+
|
|
151
|
+
public WithCancellationTaskAwaitable(Task task, CancellationToken cancellationToken)
|
|
152
|
+
{
|
|
153
|
+
_awaitable = task.ConfigureAwait(false);
|
|
154
|
+
_cancellationToken = cancellationToken;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public WithCancellationTaskAwaiter GetAwaiter() => new WithCancellationTaskAwaiter(_awaitable.GetAwaiter(), _cancellationToken);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public readonly struct WithCancellationTaskAwaitable<T>
|
|
161
|
+
{
|
|
162
|
+
private readonly CancellationToken _cancellationToken;
|
|
163
|
+
private readonly ConfiguredTaskAwaitable<T> _awaitable;
|
|
164
|
+
|
|
165
|
+
public WithCancellationTaskAwaitable(Task<T> task, CancellationToken cancellationToken)
|
|
166
|
+
{
|
|
167
|
+
_awaitable = task.ConfigureAwait(false);
|
|
168
|
+
_cancellationToken = cancellationToken;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public WithCancellationTaskAwaiter<T> GetAwaiter() => new WithCancellationTaskAwaiter<T>(_awaitable.GetAwaiter(), _cancellationToken);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public readonly struct WithCancellationValueTaskAwaitable<T>
|
|
175
|
+
{
|
|
176
|
+
private readonly CancellationToken _cancellationToken;
|
|
177
|
+
private readonly ConfiguredValueTaskAwaitable<T> _awaitable;
|
|
178
|
+
|
|
179
|
+
public WithCancellationValueTaskAwaitable(ValueTask<T> task, CancellationToken cancellationToken)
|
|
180
|
+
{
|
|
181
|
+
_awaitable = task.ConfigureAwait(false);
|
|
182
|
+
_cancellationToken = cancellationToken;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public WithCancellationValueTaskAwaiter<T> GetAwaiter() => new WithCancellationValueTaskAwaiter<T>(_awaitable.GetAwaiter(), _cancellationToken);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public readonly struct WithCancellationTaskAwaiter : ICriticalNotifyCompletion
|
|
189
|
+
{
|
|
190
|
+
private readonly CancellationToken _cancellationToken;
|
|
191
|
+
private readonly ConfiguredTaskAwaitable.ConfiguredTaskAwaiter _taskAwaiter;
|
|
192
|
+
|
|
193
|
+
public WithCancellationTaskAwaiter(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter awaiter, CancellationToken cancellationToken)
|
|
194
|
+
{
|
|
195
|
+
_taskAwaiter = awaiter;
|
|
196
|
+
_cancellationToken = cancellationToken;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public bool IsCompleted => _taskAwaiter.IsCompleted || _cancellationToken.IsCancellationRequested;
|
|
200
|
+
|
|
201
|
+
public void OnCompleted(Action continuation) => _taskAwaiter.OnCompleted(WrapContinuation(continuation));
|
|
202
|
+
|
|
203
|
+
public void UnsafeOnCompleted(Action continuation) => _taskAwaiter.UnsafeOnCompleted(WrapContinuation(continuation));
|
|
204
|
+
|
|
205
|
+
public void GetResult()
|
|
206
|
+
{
|
|
207
|
+
Debug.Assert(IsCompleted);
|
|
208
|
+
if (!_taskAwaiter.IsCompleted)
|
|
209
|
+
{
|
|
210
|
+
_cancellationToken.ThrowIfCancellationRequested();
|
|
211
|
+
}
|
|
212
|
+
_taskAwaiter.GetResult();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private Action WrapContinuation(in Action originalContinuation)
|
|
216
|
+
=> _cancellationToken.CanBeCanceled
|
|
217
|
+
? new WithCancellationContinuationWrapper(originalContinuation, _cancellationToken).Continuation
|
|
218
|
+
: originalContinuation;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public readonly struct WithCancellationTaskAwaiter<T> : ICriticalNotifyCompletion
|
|
222
|
+
{
|
|
223
|
+
private readonly CancellationToken _cancellationToken;
|
|
224
|
+
private readonly ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter _taskAwaiter;
|
|
225
|
+
|
|
226
|
+
public WithCancellationTaskAwaiter(ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter awaiter, CancellationToken cancellationToken)
|
|
227
|
+
{
|
|
228
|
+
_taskAwaiter = awaiter;
|
|
229
|
+
_cancellationToken = cancellationToken;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public bool IsCompleted => _taskAwaiter.IsCompleted || _cancellationToken.IsCancellationRequested;
|
|
233
|
+
|
|
234
|
+
public void OnCompleted(Action continuation) => _taskAwaiter.OnCompleted(WrapContinuation(continuation));
|
|
235
|
+
|
|
236
|
+
public void UnsafeOnCompleted(Action continuation) => _taskAwaiter.UnsafeOnCompleted(WrapContinuation(continuation));
|
|
237
|
+
|
|
238
|
+
public T GetResult()
|
|
239
|
+
{
|
|
240
|
+
Debug.Assert(IsCompleted);
|
|
241
|
+
if (!_taskAwaiter.IsCompleted)
|
|
242
|
+
{
|
|
243
|
+
_cancellationToken.ThrowIfCancellationRequested();
|
|
244
|
+
}
|
|
245
|
+
return _taskAwaiter.GetResult();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private Action WrapContinuation(in Action originalContinuation)
|
|
249
|
+
=> _cancellationToken.CanBeCanceled
|
|
250
|
+
? new WithCancellationContinuationWrapper(originalContinuation, _cancellationToken).Continuation
|
|
251
|
+
: originalContinuation;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public readonly struct WithCancellationValueTaskAwaiter<T> : ICriticalNotifyCompletion
|
|
255
|
+
{
|
|
256
|
+
private readonly CancellationToken _cancellationToken;
|
|
257
|
+
private readonly ConfiguredValueTaskAwaitable<T>.ConfiguredValueTaskAwaiter _taskAwaiter;
|
|
258
|
+
|
|
259
|
+
public WithCancellationValueTaskAwaiter(ConfiguredValueTaskAwaitable<T>.ConfiguredValueTaskAwaiter awaiter, CancellationToken cancellationToken)
|
|
260
|
+
{
|
|
261
|
+
_taskAwaiter = awaiter;
|
|
262
|
+
_cancellationToken = cancellationToken;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public bool IsCompleted => _taskAwaiter.IsCompleted || _cancellationToken.IsCancellationRequested;
|
|
266
|
+
|
|
267
|
+
public void OnCompleted(Action continuation) => _taskAwaiter.OnCompleted(WrapContinuation(continuation));
|
|
268
|
+
|
|
269
|
+
public void UnsafeOnCompleted(Action continuation) => _taskAwaiter.UnsafeOnCompleted(WrapContinuation(continuation));
|
|
270
|
+
|
|
271
|
+
public T GetResult()
|
|
272
|
+
{
|
|
273
|
+
Debug.Assert(IsCompleted);
|
|
274
|
+
if (!_taskAwaiter.IsCompleted)
|
|
275
|
+
{
|
|
276
|
+
_cancellationToken.ThrowIfCancellationRequested();
|
|
277
|
+
}
|
|
278
|
+
return _taskAwaiter.GetResult();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private Action WrapContinuation(in Action originalContinuation)
|
|
282
|
+
=> _cancellationToken.CanBeCanceled
|
|
283
|
+
? new WithCancellationContinuationWrapper(originalContinuation, _cancellationToken).Continuation
|
|
284
|
+
: originalContinuation;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private class WithCancellationContinuationWrapper
|
|
288
|
+
{
|
|
289
|
+
private Action _originalContinuation;
|
|
290
|
+
private readonly CancellationTokenRegistration _registration;
|
|
291
|
+
|
|
292
|
+
public WithCancellationContinuationWrapper(Action originalContinuation, CancellationToken cancellationToken)
|
|
293
|
+
{
|
|
294
|
+
Action continuation = ContinuationImplementation;
|
|
295
|
+
_originalContinuation = originalContinuation;
|
|
296
|
+
_registration = cancellationToken.Register(continuation);
|
|
297
|
+
Continuation = continuation;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
public Action Continuation { get; }
|
|
301
|
+
|
|
302
|
+
private void ContinuationImplementation()
|
|
303
|
+
{
|
|
304
|
+
Action originalContinuation = Interlocked.Exchange(ref _originalContinuation, null);
|
|
305
|
+
if (originalContinuation != null)
|
|
306
|
+
{
|
|
307
|
+
_registration.Dispose();
|
|
308
|
+
originalContinuation();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|