From 05c3f687bfb3f6e6452cdce18d00bb2065bbdc60 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:52:00 +0300 Subject: [PATCH] netstandard as target framework --- src/Appium.Net/Appium.Net.csproj | 37 ++++---------- .../Appium/Service/AppiumLocalService.cs | 50 ++----------------- 2 files changed, 14 insertions(+), 73 deletions(-) diff --git a/src/Appium.Net/Appium.Net.csproj b/src/Appium.Net/Appium.Net.csproj index f6ae1bfb..69071b57 100644 --- a/src/Appium.Net/Appium.Net.csproj +++ b/src/Appium.Net/Appium.Net.csproj @@ -1,14 +1,14 @@ - net48;net6.0 - LICENSE.txt + netstandard2.0 OpenQA.Selenium + latest Appium Commiters Dotnet-Client false true Copyright © 2023 - https://github.com/appium/dotnet-client + https://appium.io https://github.com/appium/dotnet-client git true @@ -19,40 +19,25 @@ appium-icon.png Selenium Webdriver extension for Appium. Appium Webdriver device automation - - LICENSE.txt - - README.md - - true - - latest - + 1701;1702;1591 + 1701;1702;1591 - - 1701;1702;1591 - - - 1701;1702;1591 - + - - + - - - + all @@ -62,8 +47,4 @@ - - - - - \ No newline at end of file + diff --git a/src/Appium.Net/Appium/Service/AppiumLocalService.cs b/src/Appium.Net/Appium/Service/AppiumLocalService.cs index d8557f77..2ad47a63 100644 --- a/src/Appium.Net/Appium/Service/AppiumLocalService.cs +++ b/src/Appium.Net/Appium/Service/AppiumLocalService.cs @@ -20,9 +20,7 @@ using System.IO; using System.Linq; using System.Net; -#if NET using System.Net.Http; -#endif using System.Runtime.CompilerServices; using System.Threading.Tasks; @@ -39,9 +37,7 @@ public class AppiumLocalService : ICommandServer private readonly int Port; private readonly TimeSpan InitializationTimeout; private readonly IDictionary EnvironmentForProcess; -#if !NET48 private readonly HttpClient SharedHttpClient; -#endif private Process Service; private List ArgsList; @@ -65,24 +61,14 @@ internal AppiumLocalService( Port = port; InitializationTimeout = initializationTimeout; EnvironmentForProcess = environmentForProcess; -#if !NET48 - SharedHttpClient = CreateHttpClientInstance; -#endif + SharedHttpClient = CreateHttpClientInstance(); } -#if !NET48 - private HttpClient CreateHttpClientInstance + private static HttpClient CreateHttpClientInstance() { - get - { - SocketsHttpHandler handler = new SocketsHttpHandler - { - PooledConnectionLifetime = TimeSpan.FromMinutes(2) - }; - return new HttpClient(handler); - } + return new HttpClient() { Timeout = TimeSpan.FromMinutes(2) }; } -#endif + /// /// The base URL for the managed appium server. /// @@ -175,9 +161,7 @@ private void DestroyProcess() finally { Service?.Close(); -#if !NET48 SharedHttpClient.Dispose(); -#endif } } @@ -296,20 +280,12 @@ private async Task PingAsync(TimeSpan span) { try { -#if NET48 - HttpWebResponse response = await GetHttpResponseAsync(status).ConfigureAwait(false); - if (response.StatusCode == HttpStatusCode.OK) - { - return true; - } -#elif NET - HttpResponseMessage response = await GetHttpResponseAsync(status).ConfigureAwait(false); + using HttpResponseMessage response = await SharedHttpClient.GetAsync(status).ConfigureAwait(false); if (response.IsSuccessStatusCode) { return true; } -#endif } catch { @@ -318,21 +294,5 @@ private async Task PingAsync(TimeSpan span) } return pinged; } -#if NET48 - private async Task GetHttpResponseAsync(Uri status) - { - return await Task.Run(() => - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(status); - return (HttpWebResponse)request.GetResponse(); - }).ConfigureAwait(false); - } -#else - private async Task GetHttpResponseAsync(Uri status) - { - HttpResponseMessage response = await SharedHttpClient.GetAsync(status).ConfigureAwait(false); - return response; - } -#endif } } \ No newline at end of file