diff --git a/.pipelines/cs-build-steps.yaml b/.pipelines/cs-build-steps.yaml
index 284decfa..3624ce15 100644
--- a/.pipelines/cs-build-steps.yaml
+++ b/.pipelines/cs-build-steps.yaml
@@ -42,7 +42,7 @@ steps:
publishTestResults: true
arguments: '-v:n -c release -p:CodeCoverage=true --no-build'
-- task: PublishCodeCoverageResults@1
+- task: PublishCodeCoverageResults@2
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
diff --git a/cs/build/build.props b/cs/build/build.props
index 6da060a8..af08f618 100644
--- a/cs/build/build.props
+++ b/cs/build/build.props
@@ -28,16 +28,9 @@
true
-
-
- netcoreapp3.1
- netstandard2.1
- netstandard2.1
-
-
- 7.6.812
+ 8.9.3
5.4.1
3.3.0
0.3.0
@@ -45,7 +38,7 @@
15.8.0
4.9.0
3.6.133
- 4.8.13
+ 5.3.9
4.7.2
15.5.31
3.12.5
@@ -95,7 +88,7 @@
true
- $(TestResultsDirectory)/$(TestBaseName)-coverage.xml
+ $(TestResultsDirectory)/$(TestBaseName)-coverage.xml
Interop|Test|xunit|AltCover|System.Reactive
ThisAssembly|System.Runtime|CodeAnalysis
$(TestResultsDirectory)/$(TestBaseName)-lcov.info
diff --git a/cs/global.json b/cs/global.json
index adf50e1f..2920a09a 100644
--- a/cs/global.json
+++ b/cs/global.json
@@ -1,5 +1,6 @@
{
- "sdk": {
- "version": "6.0.412"
- }
-}
\ No newline at end of file
+ "sdk": {
+ "version": "8.0.400",
+ "rollForward": "latestFeature"
+ }
+}
diff --git a/cs/src/Connections/DevTunnels.Connections.csproj b/cs/src/Connections/DevTunnels.Connections.csproj
index cfba0373..e0745d99 100644
--- a/cs/src/Connections/DevTunnels.Connections.csproj
+++ b/cs/src/Connections/DevTunnels.Connections.csproj
@@ -3,7 +3,7 @@
Microsoft.DevTunnels.Connections
Microsoft.DevTunnels.Connections
- netcoreapp3.1;net6.0
+ net6.0;net8.0
true
true
false
diff --git a/cs/src/Connections/WebSocketStream.cs b/cs/src/Connections/WebSocketStream.cs
index b3ae0739..65d0f3df 100644
--- a/cs/src/Connections/WebSocketStream.cs
+++ b/cs/src/Connections/WebSocketStream.cs
@@ -102,11 +102,16 @@ public static async Task ConnectToWebSocketAsync(Uri uri, Actio
}
catch (WebSocketException wse) when (wse.WebSocketErrorCode == WebSocketError.NotAWebSocket)
{
- // The http request didn't upgrade to a web socket and instead may have returned a status code.
+ // The http request didn't upgrade to a web socket and instead may have returned an error status code.
+#if NET8_0_OR_GREATER
+ if ((int)socket.HttpStatusCode >= 400)
+ {
+ TunnelConnectionException.SetHttpStatusCode(wse, socket.HttpStatusCode);
+ }
+#else
+ // Socket.HttpStatusCode is not available in older versions of .NET.
// As a workaround, check for "'{actual response code}'" pattern in the exception message,
// which may look like this: "The server returned status code '403' when status code '101' was expected".
- // TODO: switch to ClientWebSocket.HttpStatusCode when we get to .NET CORE 7.0, see https://github.com/dotnet/runtime/issues/25918#issuecomment-1132039238
-
int i = wse.Message.IndexOf('\'');
if (i >= 0)
{
@@ -120,10 +125,9 @@ public static async Task ConnectToWebSocketAsync(Uri uri, Actio
statusCode != 101)
{
TunnelConnectionException.SetHttpStatusCode(wse, (HttpStatusCode)statusCode);
- socket.Dispose();
- throw wse;
}
}
+#endif
socket.Dispose();
throw;
diff --git a/cs/src/Contracts/DevTunnels.Contracts.csproj b/cs/src/Contracts/DevTunnels.Contracts.csproj
index 3326bd26..882716e1 100644
--- a/cs/src/Contracts/DevTunnels.Contracts.csproj
+++ b/cs/src/Contracts/DevTunnels.Contracts.csproj
@@ -3,7 +3,7 @@
Microsoft.DevTunnels.Contracts
Microsoft.DevTunnels.Contracts
- netcoreapp3.1;net6.0
+ net6.0;net8.0
true
true
false
diff --git a/cs/src/Directory.Build.targets b/cs/src/Directory.Build.targets
index 2e6dbb5e..4b938cae 100644
--- a/cs/src/Directory.Build.targets
+++ b/cs/src/Directory.Build.targets
@@ -6,9 +6,9 @@
-
+
@@ -19,7 +19,7 @@
-
+
Microsoft.DevTunnels.Management
Microsoft.DevTunnels.Management
- netcoreapp3.1;net6.0
+ net6.0;net8.0
true
true
false
@@ -11,8 +11,8 @@
CS1591
-
-
+
+
diff --git a/cs/src/Management/TunnelRequestOptions.cs b/cs/src/Management/TunnelRequestOptions.cs
index 56acbb2b..e092ed29 100644
--- a/cs/src/Management/TunnelRequestOptions.cs
+++ b/cs/src/Management/TunnelRequestOptions.cs
@@ -49,8 +49,7 @@ public class TunnelRequestOptions
///
/// Gets or sets additional http request options
- /// for HttpRequestMessage.Options
(in net6.0) or
- /// HttpRequestMessage.Properties
(in netcoreapp3.1).
+ /// for HttpRequestMessage.Options
.
///
public IEnumerable>? HttpRequestOptions { get; set; }
@@ -193,21 +192,13 @@ protected internal virtual string ToQueryString()
///
/// Set HTTP request options.
///
- ///
- /// On net 6.0+ it sets request.Options
.
- /// On netcoreapp 3.1 it sets request.Properties
.
- ///
/// Http request, not null.
internal void SetRequestOptions(HttpRequestMessage request)
{
Requires.NotNull(request, nameof(request));
foreach (var kvp in HttpRequestOptions ?? Enumerable.Empty>())
{
-#if NET6_0_OR_GREATER
request.Options.Set(new HttpRequestOptionsKey