Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions BrowserStackLocal/BrowserStackLocal.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -31,4 +34,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3019DB30-CCF5-4543-B787-FCBBD97B21C8}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Product>BrowserStackLocal</Product>
<Description>C# Bindings for BrowserStack Local</Description>
<Version>2.0.0.0</Version>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<Authors>BrowserStack</Authors>
<Company>BrowserStack</Company>
Expand Down
55 changes: 52 additions & 3 deletions BrowserStackLocal/BrowserStackLocal/Local.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Reflection;

namespace BrowserStack
{
Expand All @@ -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<string, string> emptyStringPair = new KeyValuePair<string, string>();

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -92,10 +99,51 @@ 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;
Console.Error.WriteLine(m);
}
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<KeyValuePair<string, string>> options)
{
Expand Down Expand Up @@ -123,6 +171,7 @@ public void start(List<KeyValuePair<string, string>> options)
}

argumentString += "-logFile \"" + customLogPath + "\" ";
argumentString += "--source \"c-sharp:" + bindingVersion + "\" ";
tunnel.addBinaryPath(customBinaryPath);
tunnel.addBinaryArguments(argumentString);
while (true) {
Expand Down