From 744004a85cd20526eff39e86c01669f3d2d48cb6 Mon Sep 17 00:00:00 2001 From: "Edwin Clement (Windows - Adam)" Date: Wed, 6 Jul 2022 12:02:06 +0530 Subject: [PATCH 1/3] Added Source to binary argument string, Also updated example to .Net 4.8 --- BrowserStackLocal/BrowserStackLocal.sln | 16 ++++-- .../BrowserStackLocal.csproj | 1 + BrowserStackLocal/BrowserStackLocal/Local.cs | 54 +++++++++++++++++-- .../BrowserStackExample.csproj | 6 ++- .../BrowserStackExample/app.config | 3 ++ 5 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 BrowserStackLocalExample/BrowserStackExample/app.config diff --git a/BrowserStackLocal/BrowserStackLocal.sln b/BrowserStackLocal/BrowserStackLocal.sln index ead4ad6..64dba3f 100644 --- a/BrowserStackLocal/BrowserStackLocal.sln +++ b/BrowserStackLocal/BrowserStackLocal.sln @@ -1,13 +1,16 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32414.318 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrowserStackLocal", "BrowserStackLocal\BrowserStackLocal.csproj", "{F58E1C9A-5910-4DA8-B531-9F4A6B0AE8C8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserStackLocal", "BrowserStackLocal\BrowserStackLocal.csproj", "{F58E1C9A-5910-4DA8-B531-9F4A6B0AE8C8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrowserStackLocal Unit Tests", "BrowserStackLocal Unit Tests\BrowserStackLocal Unit Tests.csproj", "{FF1ABB6F-4A2C-48F4-B4DB-47DAD566D2F9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserStackLocal Unit Tests", "BrowserStackLocal Unit Tests\BrowserStackLocal Unit Tests.csproj", "{FF1ABB6F-4A2C-48F4-B4DB-47DAD566D2F9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrowserStackLocalIntegrationTests", "BrowserStackLocalIntegrationTests\BrowserStackLocalIntegrationTests.csproj", "{01FFB287-C79A-4476-AEDB-EE8DE80EB3B3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserStackLocalIntegrationTests", "BrowserStackLocalIntegrationTests\BrowserStackLocalIntegrationTests.csproj", "{01FFB287-C79A-4476-AEDB-EE8DE80EB3B3}" + ProjectSection(ProjectDependencies) = postProject + {F58E1C9A-5910-4DA8-B531-9F4A6B0AE8C8} = {F58E1C9A-5910-4DA8-B531-9F4A6B0AE8C8} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -31,4 +34,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3019DB30-CCF5-4543-B787-FCBBD97B21C8} + EndGlobalSection EndGlobal diff --git a/BrowserStackLocal/BrowserStackLocal/BrowserStackLocal.csproj b/BrowserStackLocal/BrowserStackLocal/BrowserStackLocal.csproj index f28c436..9c189f6 100644 --- a/BrowserStackLocal/BrowserStackLocal/BrowserStackLocal.csproj +++ b/BrowserStackLocal/BrowserStackLocal/BrowserStackLocal.csproj @@ -8,6 +8,7 @@ BrowserStackLocal C# Bindings for BrowserStack Local 2.0.0.0 + 2.0.0.0 2.0.0.0 BrowserStack BrowserStack diff --git a/BrowserStackLocal/BrowserStackLocal/Local.cs b/BrowserStackLocal/BrowserStackLocal/Local.cs index 26155bf..a3db0c8 100644 --- a/BrowserStackLocal/BrowserStackLocal/Local.cs +++ b/BrowserStackLocal/BrowserStackLocal/Local.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; +using System.Reflection; namespace BrowserStack { @@ -12,6 +13,8 @@ public class Local private string customLogPath = ""; private string argumentString = ""; private string customBinaryPath = ""; + private string bindingVersion = ""; + protected BrowserStackTunnel tunnel = null; private static KeyValuePair emptyStringPair = new KeyValuePair(); @@ -63,7 +66,11 @@ private void addArgs(string key, string value) { } - else + else if (key.Equals("source")) + { + + } + else { result = valueCommands.Find(pair => pair.Key == key); if (!result.Equals(emptyStringPair)) @@ -92,10 +99,50 @@ private void addArgs(string key, string value) } } } - + public static string GetVersionString(string pVersionString) + { + string tVersion = "Unknown"; + string[] aVersion; + + if (string.IsNullOrEmpty(pVersionString)) { return tVersion; } + aVersion = pVersionString.Split('.'); + if (aVersion.Length > 0) { tVersion = aVersion[0]; } + if (aVersion.Length > 1) { tVersion += "." + aVersion[1]; } + if (aVersion.Length > 2) { tVersion += "." + aVersion[2].PadLeft(4, '0'); } + if (aVersion.Length > 3) { tVersion += "." + aVersion[3].PadLeft(4, '0'); } + + return tVersion; + } + public static Assembly GetAssemblyEmbedded(string pAssemblyDisplayName) + { + Assembly tMyAssembly = null; + + if (string.IsNullOrEmpty(pAssemblyDisplayName)) { return tMyAssembly; } + try + { + tMyAssembly = Assembly.Load(pAssemblyDisplayName); + } + catch (Exception ex) + { + string m = ex.Message; + } + return tMyAssembly; + } + public static string GetVersionStringFromAssemblyEmbedded(string pAssemblyDisplayName) + { + string tVersion = "Unknown"; + Assembly tMyAssembly = null; + + tMyAssembly = GetAssemblyEmbedded(pAssemblyDisplayName); + if (tMyAssembly == null) { return tVersion; } + tVersion = GetVersionString(tMyAssembly.GetName().Version.ToString()); + return tVersion; + } + public Local() { - tunnel = new BrowserStackTunnel(); + bindingVersion = GetVersionStringFromAssemblyEmbedded("BrowserStackLocal"); + tunnel = new BrowserStackTunnel(); } public void start(List> options) { @@ -123,6 +170,7 @@ public void start(List> options) } argumentString += "-logFile \"" + customLogPath + "\" "; + argumentString += "--source \"c-sharp:" + bindingVersion + "\" "; tunnel.addBinaryPath(customBinaryPath); tunnel.addBinaryArguments(argumentString); while (true) { diff --git a/BrowserStackLocalExample/BrowserStackExample/BrowserStackExample.csproj b/BrowserStackLocalExample/BrowserStackExample/BrowserStackExample.csproj index f4bb522..b994146 100644 --- a/BrowserStackLocalExample/BrowserStackExample/BrowserStackExample.csproj +++ b/BrowserStackLocalExample/BrowserStackExample/BrowserStackExample.csproj @@ -9,7 +9,7 @@ Properties BrowserStackExample BrowserStackExample - v4.5 + v4.8 512 publish\ true @@ -26,6 +26,7 @@ false false true + AnyCPU @@ -83,6 +84,9 @@ + + +