diff --git a/source/ChromeDevTools/ChromeProcess.cs b/source/ChromeDevTools/ChromeProcess.cs index 21dfbd1ea26d6b7aa6213b0194a60b9e201908ac..97181b30968a6fef3720d970bf6a217f33df84a3 100644 --- a/source/ChromeDevTools/ChromeProcess.cs +++ b/source/ChromeDevTools/ChromeProcess.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -35,10 +36,10 @@ namespace MasterDevs.ChromeDevTools public async Task<string[]> GetSessions() { var remoteSessionUrls = new List<string>(); - var webClient = new WebClient(); + var webClient = new HttpClient(); var uriBuilder = new UriBuilder(RemoteDebuggingUri); uriBuilder.Path = "/json"; - var remoteSessions = await webClient.DownloadStringTaskAsync(uriBuilder.Uri); + var remoteSessions = await webClient.GetStringAsync(uriBuilder.Uri); using (var stringReader = new StringReader(remoteSessions)) using (var jsonReader = new JsonTextReader(stringReader)) { diff --git a/source/ChromeDevTools/ChromeSession.cs b/source/ChromeDevTools/ChromeSession.cs index bb6ad0fc9e108bde148b6666fc66bdd977a78f18..3ad3cc4d443b71cc2bc9e30409704e600a1c448c 100644 --- a/source/ChromeDevTools/ChromeSession.cs +++ b/source/ChromeDevTools/ChromeSession.cs @@ -1,4 +1,5 @@ -using MasterDevs.ChromeDevTools.Serialization; +#if !NETSTANDARD1_5 +using MasterDevs.ChromeDevTools.Serialization; using Newtonsoft.Json; using System; using System.Collections.Concurrent; @@ -250,4 +251,5 @@ namespace MasterDevs.ChromeDevTools _openEvent.Set(); } } -} \ No newline at end of file +} +#endif diff --git a/source/ChromeDevTools/ChromeSessionFactory.cs b/source/ChromeDevTools/ChromeSessionFactory.cs index 343409e05d9719c229c0450289191829595e8c70..4aa60b63748a8e2227a1cc3993b6910594abc25b 100644 --- a/source/ChromeDevTools/ChromeSessionFactory.cs +++ b/source/ChromeDevTools/ChromeSessionFactory.cs @@ -1,4 +1,5 @@ -namespace MasterDevs.ChromeDevTools +#if !NETSTANDARD1_5 +namespace MasterDevs.ChromeDevTools { public class ChromeSessionFactory : IChromeSessionFactory { @@ -14,4 +15,5 @@ return session; } } -} \ No newline at end of file +} +#endif diff --git a/source/ChromeDevTools/Extensions/ObjectExtensions.cs b/source/ChromeDevTools/Extensions/ObjectExtensions.cs index a3ce9b949ec89245270c4276509ff4344903d62d..ba11a1ab17d75722952fa4b6d0f847ac0aaf62f7 100644 --- a/source/ChromeDevTools/Extensions/ObjectExtensions.cs +++ b/source/ChromeDevTools/Extensions/ObjectExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Reflection; namespace MasterDevs.ChromeDevTools { @@ -14,18 +15,18 @@ namespace MasterDevs.ChromeDevTools public static string GetMethod(this Type type) { if (null == type) return null; - var eventAttribute = type.GetCustomAttributes(typeof(EventAttribute), true) + var eventAttribute = type.GetTypeInfo().GetCustomAttributes(typeof(EventAttribute), true) .FirstOrDefault() as EventAttribute; if (null != eventAttribute) return eventAttribute.MethodName; - var commandAttribute = type.GetCustomAttributes(typeof(CommandAttribute), true) + var commandAttribute = type.GetTypeInfo().GetCustomAttributes(typeof(CommandAttribute), true) .FirstOrDefault() as CommandAttribute; if (null != commandAttribute) return commandAttribute.MethodName; - var commandResponseAttribute = type.GetCustomAttributes(typeof(CommandResponseAttribute), true) + var commandResponseAttribute = type.GetTypeInfo().GetCustomAttributes(typeof(CommandResponseAttribute), true) .FirstOrDefault() as CommandResponseAttribute; if (null != commandResponseAttribute) return commandResponseAttribute.MethodName; // maybe it's generic parameter has a method - if (type.IsGenericType) + if (type.GetTypeInfo().IsGenericType) { return type.GenericTypeArguments .FirstOrDefault() diff --git a/source/ChromeDevTools/MasterDevs.ChromeDevTools.csproj b/source/ChromeDevTools/MasterDevs.ChromeDevTools.csproj index 6cac82db348e692ee4452c4e13f7d465f5a35d28..eb6cc32e09e1abe10b59e03eb7cdb50f1b4e44c4 100644 --- a/source/ChromeDevTools/MasterDevs.ChromeDevTools.csproj +++ b/source/ChromeDevTools/MasterDevs.ChromeDevTools.csproj @@ -43,6 +43,9 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Net.Http"> + <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll</HintPath> + </Reference> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> diff --git a/source/ChromeDevTools/MethodTypeMap.cs b/source/ChromeDevTools/MethodTypeMap.cs index 4f1a66849dfc0bb032c4f620e04f4d9466a92757..3be2719e3b21d65239b966be40a09a7feccc1535 100644 --- a/source/ChromeDevTools/MethodTypeMap.cs +++ b/source/ChromeDevTools/MethodTypeMap.cs @@ -23,11 +23,11 @@ namespace MasterDevs.ChromeDevTools private void LoadMethodTypeMap(string alias) { - var assembly = Assembly.GetExecutingAssembly(); + var assembly = typeof(MethodTypeMap).GetTypeInfo().Assembly; var assemblyTypes = assembly.GetTypes(); foreach (var type in assemblyTypes) { - if (!type.IsClass) continue; + if (!type.GetTypeInfo().IsClass) continue; if (!type.Namespace.StartsWith($"MasterDevs.ChromeDevTools.Protocol.{alias}")) continue; @@ -54,7 +54,7 @@ namespace MasterDevs.ChromeDevTools private string GetMethodName<T>(Type type) where T : IMethodNameAttribute { - var attribute = type.GetCustomAttributes(typeof(T)) + var attribute = type.GetTypeInfo().GetCustomAttributes(typeof(T)) .FirstOrDefault(); if (null == attribute) return null; var methodNameAttribute = attribute as IMethodNameAttribute; diff --git a/source/ChromeDevTools/project.json b/source/ChromeDevTools/project.json new file mode 100644 index 0000000000000000000000000000000000000000..14e7284cdb1f065fa54360805235c360ab24cfa3 --- /dev/null +++ b/source/ChromeDevTools/project.json @@ -0,0 +1,36 @@ +{ + "version": "1.0.3-*", + "description": "Contains the classes and utilities used to interact with the Chrome Developer Tools", + "authors": [ "MasterDevs" ], + "packOptions": { + "projectUrl": "https://github.com/MasterDevs/ChromeDevTools", + "licenseUrl": "https://github.com/MasterDevs/ChromeDevTools/blob/master/LICENSE", + "iconUrl": "http://masterdevs.com/images/FavIcon_144.png" + }, + "buildOptions": {}, + "dependencies": { + "Newtonsoft.Json": "9.0.1" + }, + "frameworks": { + "netstandard15": { + "dependencies": { + "System.Reflection": "4.1.0", + "System.Runtime": "4.1.0", + "System.Collections.Concurrent": "4.0.12", + "System.IO.FileSystem": "4.0.1", + "System.Diagnostics.Process": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Net.Http": "4.1.0", + "System.Threading.Thread": "4.0.0" + } + }, + "net45": { + "dependencies": { + "WebSocket4Net": "0.14.1" + }, + "frameworkAssemblies": { + "System.Net.Http": "4.0.0.0" + } + } + } +}