diff --git a/.appveyor/AppVeyorProperties.msbuild b/.appveyor/AppVeyorProperties.msbuild
index 0f84b4c..ed47e47 100644
--- a/.appveyor/AppVeyorProperties.msbuild
+++ b/.appveyor/AppVeyorProperties.msbuild
@@ -7,7 +7,7 @@
False
False
- MadBee
+ Managed.Adb
madb
camalot
@@ -16,7 +16,7 @@
UNKNOWN
UNKNOWN
$(APPVEYOR_ACCOUNT_NAME)/$(APPVEYOR_PROJECT_SLUG)
- UNKNOWN
+
False
False
False
diff --git a/.appveyor/DeployCodePlex.msbuild b/.appveyor/DeployCodePlex.msbuild
index 5cc5eee..ff162d2 100644
--- a/.appveyor/DeployCodePlex.msbuild
+++ b/.appveyor/DeployCodePlex.msbuild
@@ -23,7 +23,7 @@
120
1200
- $(MSBuildProjectDirectory)\..\.build\publish-changelog.txt
+ $(MSBuildProjectDirectory)\..\.build\publishChangelog.txt
$(MSBuildProjectDirectory)\codeplex-release.txt
@@ -105,6 +105,7 @@
+
diff --git a/.appveyor/appveyor.after-build.ps1 b/.appveyor/appveyor.after-build.ps1
index e69de29..fc25e7b 100644
--- a/.appveyor/appveyor.after-build.ps1
+++ b/.appveyor/appveyor.after-build.ps1
@@ -0,0 +1,49 @@
+
+## THIS IS HERE BECAUSE THE 'BEFORE-DEPLOYMENT' DOESNT WANT TO RUN UNLESS ONE OF THE DEPLOYMENTS EVALUATES TO TRUE
+## AND IT IS PISSING ME OFF
+
+$commitMessageRegex = "^\[deploy\:(pre-release|draft|release)\]$";
+
+
+# read the publishChangelog file
+if(-not $env:CI_RELEASE_DESCRIPTION) {
+ $env:CI_RELEASE_DESCRIPTION = (Get-Content -Path ".\.build\publishChangelog.txt" -Raw);
+}
+
+# Must come from master branch.
+# Must not have a PULL Request Number
+# Must match regex
+if ( $env:APPVEYOR_REPO_BRANCH -eq "master" ) {
+ # Any commit to master will be deployed!!!!
+ $env:CI_DEPLOY_NUGET = $true;
+ $env:CI_DEPLOY_GITHUB = $true;
+ $env:CI_DEPLOY_FTP = $false;
+ $env:CI_DEPLOY_WebHook = $true;
+ $env:CI_DEPLOY_WebDeploy = $true;
+ $env:CI_DEPLOY_CodePlex = $false;
+ $env:CI_DEPLOY_WEBAPI_RELEASE = $false;
+ $env:CI_DEPLOY_PUSHBULLET = $false;
+ $env:CI_DEPLOY = $true;
+} elseif ( $env:APPVEYOR_REPO_BRANCH -eq "develop" ) {
+ $env:CI_DEPLOY_NUGET = $true;
+ $env:CI_DEPLOY_GITHUB_PRE = $true;
+ $env:CI_DEPLOY_GITHUB = $false;
+ $env:CI_DEPLOY_FTP = $false;
+ $env:CI_DEPLOY_WebHook = $false;
+ $env:CI_DEPLOY_WebDeploy = $false;
+ $env:CI_DEPLOY_CodePlex = $false;
+ $env:CI_DEPLOY_WEBAPI_RELEASE = $false;
+ $env:CI_DEPLOY_PUSHBULLET = $false;
+ $env:CI_DEPLOY = $false;
+} else {
+ $env:CI_DEPLOY_NUGET = $false;
+ $env:CI_DEPLOY_GITHUB_PRE = $false;
+ $env:CI_DEPLOY_GITHUB = $false;
+ $env:CI_DEPLOY_FTP = $false;
+ $env:CI_DEPLOY_WebHook = $false;
+ $env:CI_DEPLOY_WebDeploy = $false;
+ $env:CI_DEPLOY_CodePlex = $false;
+ $env:CI_DEPLOY_WEBAPI_RELEASE = $false;
+ $env:CI_DEPLOY_PUSHBULLET = $false;
+ $env:CI_DEPLOY = $false;
+}
\ No newline at end of file
diff --git a/.appveyor/appveyor.after-deployment.ps1 b/.appveyor/appveyor.after-deployment.ps1
index c647677..b3eb764 100644
--- a/.appveyor/appveyor.after-deployment.ps1
+++ b/.appveyor/appveyor.after-deployment.ps1
@@ -1,87 +1,87 @@
-Import-Module "$env:APPVEYOR_BUILD_FOLDER\.appveyor\modules\Invoke-MsBuild.psm1";
-Import-Module "$env:APPVEYOR_BUILD_FOLDER\.appveyor\modules\Send-PushbulletMessage.psm1";
+#Import-Module "$env:APPVEYOR_BUILD_FOLDER\.appveyor\modules\Invoke-MsBuild.psm1";
+#Import-Module "$env:APPVEYOR_BUILD_FOLDER\.appveyor\modules\Send-PushbulletMessage.psm1";
-function Publish-Release {
- Param (
- [Parameter(Mandatory=$true)]
- [string] $HostName
- )
- $appId = $env:CI_PUBLISHAPPID;
- $appKey = $env:CI_PUBLISHKEY;
+#function Publish-Release {
+# Param (
+# [Parameter(Mandatory=$true)]
+# [string] $HostName
+# )
+# $appId = $env:CI_PUBLISHAPPID;
+# $appKey = $env:CI_PUBLISHKEY;
- $url = "http://$HostName/api/update/create/";
- $headers = @{};
- $headers["Authentication-Token"] = $appKey;
- $headers["Application-Identifier"] = $appId;
+# $url = "http://$HostName/api/update/create/";
+# $headers = @{};
+# $headers["Authentication-Token"] = $appKey;
+# $headers["Application-Identifier"] = $appId;
- if(Test-Path -Path "$env:APPVEYOR_BUILD_FOLDER\.build\publishchangelog.txt") {
- # read the publish text file
- $publishNotes = (Get-Content -Path "$env:APPVEYOR_BUILD_FOLDER\.build\publishchangelog.txt") | Out-String;
- }
+# if(Test-Path -Path "$env:APPVEYOR_BUILD_FOLDER\.build\publishchangelog.txt") {
+# # read the publish text file
+# $publishNotes = (Get-Content -Path "$env:APPVEYOR_BUILD_FOLDER\.build\publishchangelog.txt") | Out-String;
+# }
- $post = @{
- Id = $env:CP_RELEASE_ID;
- Version = $env:CI_BUILD_VERSION;
- Description = $publishNotes;
- Name = $env:CP_RELEASE_NAME;
- Url = "http://$env:CP_RELEASE_PROJECT.codeplex.com/releases/view/$env:CP_RELEASE_ID";
- };
- $contentType = "application/x-www-form-urlencoded";
- $method = "POST";
+# $post = @{
+# Id = $env:CP_RELEASE_ID;
+# Version = $env:CI_BUILD_VERSION;
+# Description = $publishNotes;
+# Name = $env:CP_RELEASE_NAME;
+# Url = "http://$env:CP_RELEASE_PROJECT.codeplex.com/releases/view/$env:CP_RELEASE_ID";
+# };
+# $contentType = "application/x-www-form-urlencoded";
+# $method = "POST";
- $response = Invoke-WebRequest -Uri $url -Method $method -Headers $headers -TimeoutSec 120 -Body $post -ContentType $contentType -UserAgent "AppVeyor Build Agent";
+# $response = Invoke-WebRequest -Uri $url -Method $method -Headers $headers -TimeoutSec 120 -Body $post -ContentType $contentType -UserAgent "AppVeyor Build Agent";
- return $response;
-}
+# return $response;
+#}
# trigger the codeplex deployment script
-if( $env:CI_DEPLOY_CODEPLEX -eq $true ) {
- Invoke-MsBuild -Path "$env:APPVEYOR_BUILD_FOLDER\.appveyor\DeployCodePlex.msbuild" -MsBuildParameters "/verbosity:detailed /p:CI_BUILD_VERSION=$env:CI_BUILD_VERSION /p:CI_BUILD_REVISION=$env:CI_BUILD_REVISION /p:CI_BUILD_MAJOR=$env:CI_BUILD_MAJOR /p:CI_BUILD_MINOR=$env:CI_BUILD_MINOR"
-} else {
- Write-Host -BackgroundColor Yellow -ForegroundColor Black "Skip `"CodePlex`" deployment as environment variable has not matched (`"CI_DEPLOY_CODEPLEX`" is `"$false`", should be `"$true`")";
-}
+#if( $env:CI_DEPLOY_CODEPLEX -eq $true ) {
+# Invoke-MsBuild -Path "$env:APPVEYOR_BUILD_FOLDER\.appveyor\DeployCodePlex.msbuild" -MsBuildParameters "/verbosity:detailed /p:CI_BUILD_VERSION=$env:CI_BUILD_VERSION /p:CI_BUILD_REVISION=$env:CI_BUILD_REVISION /p:CI_BUILD_MAJOR=$env:CI_BUILD_MAJOR /p:CI_BUILD_MINOR=$env:CI_BUILD_MINOR"
+#} else {
+# Write-Host -BackgroundColor Yellow -ForegroundColor Black "Skip `"CodePlex`" deployment as environment variable has not matched (`"CI_DEPLOY_CODEPLEX`" is `"$false`", should be `"$true`")";
+#}
# publish release
-if( $env:CI_DEPLOY_WEBAPI_RELEASE -eq $true -and $env:Platform -eq "x86" ) {
- # this only gets called for the x86 platform so it is called once, and because the env:vars may not exist for x64
- if( !$env:CP_RELEASE_NAME -or !$env:CP_RELEASE_ID -or !$env:CP_RELEASE_URL ) {
- Write-Host -BackgroundColor Red -ForegroundColor White "Unable to read the required values to create the release";
- $host.SetShouldExit(500);
- return;
- }
- @($env:DevelopmentApiDomain,$env:ProductionApiDomain) | foreach {
- $hostname = $_;
- Write-Host "[WebApiRelease] Publishing Release Information '$env:CP_RELEASE_NAME' to $hostname";
- $resp = Publish-Release -HostName $hostname;
- if($resp.StatusCode -ne 200) {
- Write-Host -BackgroundColor Red -ForegroundColor White $resp.StatusDescription;
- $host.SetShouldExit($resp.StatusCode);
- return;
- }
+#if( $env:CI_DEPLOY_WEBAPI_RELEASE -eq $true -and $env:Platform -eq "x86" ) {
+# # this only gets called for the x86 platform so it is called once, and because the env:vars may not exist for x64
+# if( !$env:CP_RELEASE_NAME -or !$env:CP_RELEASE_ID -or !$env:CP_RELEASE_URL ) {
+# Write-Host -BackgroundColor Red -ForegroundColor White "Unable to read the required values to create the release";
+# $host.SetShouldExit(500);
+# return;
+# }
+# @($env:DevelopmentApiDomain,$env:ProductionApiDomain) | foreach {
+# $hostname = $_;
+# Write-Host "[WebApiRelease] Publishing Release Information '$env:CP_RELEASE_NAME' to $hostname";
+# $resp = Publish-Release -HostName $hostname;
+# if($resp.StatusCode -ne 200) {
+# Write-Host -BackgroundColor Red -ForegroundColor White $resp.StatusDescription;
+# $host.SetShouldExit($resp.StatusCode);
+# return;
+# }
- }
-} else {
- Write-Host -BackgroundColor Yellow -ForegroundColor Black "Skip `"WebApiRelease`" deployment as environment variable has not matched (`"CI_DEPLOY_CODEPLEX`" is `"$false`", should be `"$true`")";
-}
+# }
+#} else {
+# Write-Host -BackgroundColor Yellow -ForegroundColor Black "Skip `"WebApiRelease`" deployment as environment variable has not matched (`"CI_DEPLOY_CODEPLEX`" is `"$false`", should be `"$true`")";
+#}
-if($env:PUSHBULLET_API_TOKEN) {
- $timestamp = (Get-Date).ToUniversalTime().ToString("MM/dd/yyyy hh:mm:ss");
- # this allows for multiple tokens, just separate with a comma.
- $env:PUSHBULLET_API_TOKEN.Split(",") | foreach {
- $pbtoken = $_;
- try {
- # Send a pushbullet message if there is an api token available
- Send-PushbulletMessage -apiKey $pbtoken -Type Message -Title "[Build] Managed.ADB $env:Platform v$env:CI_BUILD_VERSION Build Finished" -msg ("Build completed at $timestamp UTC");
+#if($env:PUSHBULLET_API_TOKEN) {
+# $timestamp = (Get-Date).ToUniversalTime().ToString("MM/dd/yyyy hh:mm:ss");
+# # this allows for multiple tokens, just separate with a comma.
+# $env:PUSHBULLET_API_TOKEN.Split(",") | foreach {
+# $pbtoken = $_;
+# try {
+# # Send a pushbullet message if there is an api token available
+# Send-PushbulletMessage -apiKey $pbtoken -Type Message -Title "[Build] Managed.ADB $env:Platform v$env:CI_BUILD_VERSION Build Finished" -msg ("Build completed at $timestamp UTC");
- if( $env:Platform -eq "x64" -and $env:CI_DEPLOY_PUSHBULLET -eq $true) {
- Send-PushbulletMessage -apiKey $pbtoken -Type Message -Title "[Deploy] Managed.ADB v$env:CI_BUILD_VERSION Deployed" -msg ("Deployment completed at $timestamp UTC");
- } else {
- Write-Host -BackgroundColor Yellow -ForegroundColor Black "Skip `"PushBullet`" deployment as environment variable has not matched (`"CI_DEPLOY_PUSHBULLET`" is `"$false`", should be `"$true`" and `"Platform`" is `"$env:Platform`", should be `"x64`")";
- }
- } catch [Exeption] {
- Write-Error ($_ -replace $pbtoken, "[`$env:PUSHBULLET_API_TOKEN]");
- }
- }
-}
+# if( $env:Platform -eq "x64" -and $env:CI_DEPLOY_PUSHBULLET -eq $true) {
+# Send-PushbulletMessage -apiKey $pbtoken -Type Message -Title "[Deploy] Managed.ADB v$env:CI_BUILD_VERSION Deployed" -msg ("Deployment completed at $timestamp UTC");
+# } else {
+# Write-Host -BackgroundColor Yellow -ForegroundColor Black "Skip `"PushBullet`" deployment as environment variable has not matched (`"CI_DEPLOY_PUSHBULLET`" is `"$false`", should be `"$true`" and `"Platform`" is `"$env:Platform`", should be `"x64`")";
+# }
+# } catch [Exeption] {
+# Write-Error ($_ -replace $pbtoken, "[`$env:PUSHBULLET_API_TOKEN]");
+# }
+# }
+#}
diff --git a/.appveyor/appveyor.after-test.ps1 b/.appveyor/appveyor.after-test.ps1
new file mode 100644
index 0000000..e69de29
diff --git a/.appveyor/appveyor.before-build.ps1 b/.appveyor/appveyor.before-build.ps1
index e3cc17e..e5658b4 100644
--- a/.appveyor/appveyor.before-build.ps1
+++ b/.appveyor/appveyor.before-build.ps1
@@ -7,9 +7,11 @@ try {
Import-Module "$env:APPVEYOR_BUILD_FOLDER\.appveyor\modules\Import-PfxCertificate.psm1";
Import-Module "$env:APPVEYOR_BUILD_FOLDER\.appveyor\modules\Set-BuildVersion.psm1";
-
-Import-PfxCertificate -pfx "$env:APPVEYOR_BUILD_FOLDER\Shared\madb.pfx" -password ((Get-Item Env:\MADB_PFX_KEY).Value) -containerName ((Get-Item Env:\VS_PFX_KEY).Value);
-
+if( (Test-Path -Path 'Env:\VS_PFX_KEY') -and (Test-Path -Path Env:\MADB_PFX_KEY) ) {
+ Import-PfxCertificate -pfx "$env:APPVEYOR_BUILD_FOLDER\Shared\madb.pfx" -password ((Get-Item Env:\MADB_PFX_KEY).Value) -containerName ((Get-Item Env:\VS_PFX_KEY).Value);
+} else {
+ "VS_PFX_KEY and MAD_PFX_KEY are missing; skipping PFX Certificate import." | Write-Warning;
+}
$env:CI_BUILD_DATE = ((Get-Date).ToUniversalTime().ToString("MM-dd-yyyy"));
$env:CI_BUILD_TIME = ((Get-Date).ToUniversalTime().ToString("hh:mm:ss"));
diff --git a/.appveyor/appveyor.before-deployment.ps1 b/.appveyor/appveyor.before-deployment.ps1
index d3f30bf..e69de29 100644
--- a/.appveyor/appveyor.before-deployment.ps1
+++ b/.appveyor/appveyor.before-deployment.ps1
@@ -1,33 +0,0 @@
-<#
- #
- #
- #>
-
-$commitMessageRegex = "^\[deploy\:(pre-release|draft|release)\]$";
-
-
-# Must come from master branch.
-# Must not have a PULL Request Number
-# Must match regex
-if ( ($env:APPVEYOR_REPO_BRANCH -eq "master") -and ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match $commitMessageRegex) ) {
- $env:CI_DEPLOY_NUGET = $true;
- $env:CI_DEPLOY_GITHUB = $true;
- $env:CI_DEPLOY_FTP = $false;
- $env:CI_DEPLOY_WebHook = $true;
- $env:CI_DEPLOY_WebDeploy = $true;
- $env:CI_DEPLOY_CodePlex = $false;
- $env:CI_DEPLOY_WEBAPI_RELEASE = $false;
- $env:CI_DEPLOY_PUSHBULLET = $true;
- $env:CI_DEPLOY = $true;
-} else {
- # Do not assign a release number or deploy
- $env:CI_DEPLOY_NUGET = $false;
- $env:CI_DEPLOY_GITHUB = $false;
- $env:CI_DEPLOY_FTP = $false;
- $env:CI_DEPLOY_WebHook = $false;
- $env:CI_DEPLOY_WebDeploy = $false;
- $env:CI_DEPLOY_CodePlex = $false;
- $env:CI_DEPLOY_WEBAPI_RELEASE = $false;
- $env:CI_DEPLOY_PUSHBULLET = $false;
- $env:CI_DEPLOY = $false;
-}
\ No newline at end of file
diff --git a/.appveyor/appveyor.before-test.ps1 b/.appveyor/appveyor.before-test.ps1
new file mode 100644
index 0000000..e69de29
diff --git a/.appveyor/appveyor.install.ps1 b/.appveyor/appveyor.install.ps1
index e6167f3..b3bcfcd 100644
--- a/.appveyor/appveyor.install.ps1
+++ b/.appveyor/appveyor.install.ps1
@@ -1,3 +1,7 @@
-choco install -y nuget.commandline --version 3.3.0;
+& choco install -y nuget.commandline -version 3.3.0;
-$env:PATH = "C:\ProgramData\chocolatey\lib\NuGet.CommandLine\tools;$env:PATH";
\ No newline at end of file
+$env:PATH = "C:\ProgramData\chocolatey\lib\NuGet.CommandLine\tools\;C:\Python34;C:\Python34\Scripts\;$env:PATH";
+
+& python -m pip install --upgrade pip;
+
+pip install codecov;
diff --git a/.appveyor/appveyor.test.ps1 b/.appveyor/appveyor.test.ps1
new file mode 100644
index 0000000..4b8093e
--- /dev/null
+++ b/.appveyor/appveyor.test.ps1
@@ -0,0 +1,5 @@
+# /noshadow /nologo /notrait category=IntegrationTest
+
+& "${ENV:APPVEYOR_BUILD_FOLDER}\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe" -log:All -register:user -target:`"${ENV:APPVEYOR_BUILD_FOLDER}\packages\xunit.runner.console.2.1.0\tools\xunit.console.x86.exe`" -filter:`"+[Managed.Adb]* -[Managed.Adb]Managed.Adb.Properties.*`" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -output:`"${ENV:APPVEYOR_BUILD_FOLDER}\managed.adb.coverage.xml`" -targetargs:`"`\`"${ENV:APPVEYOR_BUILD_FOLDER}\Managed.Adb.Tests\bin\x86\Debug\Managed.Adb.Tests.dll`\`" -verbose -noshadow `";
+
+codecov -f `"${ENV:APPVEYOR_BUILD_FOLDER}\managed.adb.coverage.xml`" -X gcov;
\ No newline at end of file
diff --git a/.build/BuildAll.msbuild b/.build/BuildAll.msbuild
index 84077c0..68a7acb 100644
--- a/.build/BuildAll.msbuild
+++ b/.build/BuildAll.msbuild
@@ -1,7 +1,6 @@
-
@@ -13,8 +12,17 @@
+
+
+
+
+
+
-
+
+
\ No newline at end of file
diff --git a/.build/SharedProperties.msbuild b/.build/SharedProperties.msbuild
index f28f8a4..be5d2ac 100644
--- a/.build/SharedProperties.msbuild
+++ b/.build/SharedProperties.msbuild
@@ -12,10 +12,10 @@
SharedProperties
False
- 0
- 10
+ 2
+ 1
$(APPVEYOR_BUILD_NUMBER)
- 0
+ 100
0
0
@@ -35,6 +35,9 @@
Tag
PullRequest
+ $(APPVEYOR_REPO_BRANCH)
+ feature/foo
+
$(CI_BUILD_MAJOR)
$(CI_BUILD_MINOR)
$(CI_BUILD_NUMBER)
@@ -81,11 +84,11 @@
PublishNuGet
$(MSBuildProjectDirectory)\..\.nuget
x86
- E:\Development\deploy\nuget
+ E:\Development\deploy\nuget
madbee
$(CI_PROJECT_FRIENDLY_NAME).$(Platform)
$(CI_PROJECT_FRIENDLY_NAME)
- $(MSBuildProjectDirectory)\Build\publish-changelog.txt
+ $(MSBuildProjectDirectory)\Build\publishChangelog.txt
$(CI_ARTIFACT_PATH)\$(Configuration)\nuget\
@@ -112,7 +115,7 @@
-
+
@@ -135,7 +138,7 @@
-
+
@@ -219,7 +222,15 @@
-
+
+
+
+
+
+
+
+
+
@@ -232,8 +243,8 @@
-
-
+
+
@@ -285,7 +296,15 @@
+ Value="$(CI_BUILD_VERSION)-alpha" Condition=" '$(CI_REPO_BRANCH)' != 'develop' AND '$(CI_REPO_BRANCH)' != 'master' "/>
+
+
bin\
True
- Configuration=$(Configuration);Platform=$(Platform);OutputPath=$(OutputPath);VisualStudioVersion=12.0;DefineConstants=MVC5
+ Configuration=$(Configuration);Platform=$(Platform);OutputPath=$(OutputPath);VisualStudioVersion=14.0;DefineConstants=MVC5
diff --git a/.build/publish-changelog.txt b/.build/publishChangelog.txt
similarity index 100%
rename from .build/publish-changelog.txt
rename to .build/publishChangelog.txt
diff --git a/.gitignore b/.gitignore
index 1a73de4..b075c30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
**/.vs/*
# Generated Version File:
*/VersionAssemblyInfo.cs
+**/*.coverage.xml
#nuget
[pP]ackages/*
diff --git a/Build/BuildAll.msbuild b/Build/BuildAll.msbuild
deleted file mode 100644
index 84077c0..0000000
--- a/Build/BuildAll.msbuild
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Build/BuildMadBee.msbuild b/Build/BuildMadBee.msbuild
deleted file mode 100644
index 98e524f..0000000
--- a/Build/BuildMadBee.msbuild
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
diff --git a/Build/InstallPfx.ps1 b/Build/InstallPfx.ps1
deleted file mode 100644
index 9186812..0000000
--- a/Build/InstallPfx.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-<#
-* Copyright (c) Inish Technology Ventures Limited. All rights reserved.
-*
-* This code is licensed under the BSD 3-Clause License included with this source
-*
-* ALSO SEE: https://github.com/SoftwarePotential/samples/wiki/License
-#>
-Param (
- [string] $pfx,
- [string] $password,
- [string] $containerName
-);
-
-$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
-$cert.Import($pfx, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
-$exportPrivateKeyInformation = $true
-$certXml = $cert.PrivateKey.ToXmlString($exportPrivateKeyInformation)
-
-$csp = New-Object System.Security.Cryptography.CspParameters
-$csp.KeyContainerName = $containerName
-$csp.Flags = [System.Security.Cryptography.CspProviderFlags]::UseMachineKeyStore -bor [System.Security.Cryptography.CspProviderFlags]::NoPrompt # -bor is biwise or
-$csp.KeyNumber = [System.Security.Cryptography.KeyNumber]::Signature
-
-$rsa = New-Object System.Security.Cryptography.RSACryptoServiceProvider $csp
-$rsa.FromXmlString($certXml)
-$rsa.Clear()
-
-"Sucesfully imported $pfx into StrongName CSP store";
diff --git a/Build/Old-NuGetPublish.msbuild b/Build/Old-NuGetPublish.msbuild
deleted file mode 100644
index 5995fd5..0000000
--- a/Build/Old-NuGetPublish.msbuild
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
- PublishNuGet
- madbee.nuspec
-
- $(MSBuildProjectDirectory)\..\3rdParty\msbuildtasks\MSBuild.Deployment.Tasks.Targets
-
-
-
- madb
- MadBee
-
- true
- true
- Beta
- 60
-
- True
- False
- $(ProjectFriendlyName) $(Version) $(Status)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Build/SharedProperties.msbuild b/Build/SharedProperties.msbuild
deleted file mode 100644
index 88e6d06..0000000
--- a/Build/SharedProperties.msbuild
+++ /dev/null
@@ -1,318 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- SharedProperties
-
- $(APPVEYOR_BUILD_NUMBER)
-
- 2
- 0
- $(CI_BUILD_NUMBER)
- 0
-
- $(MSBuildProjectDirectory)\..\Shared\VersionAssemblyInfo.txt
- False
- $(MSBuildProgramFiles32)
-
- $(ProgramFiles%28x86%29)
-
- $(ProgramFiles) (x86)
-
- $(ProgramFiles)
- Managed.Adb
- Managed.AndroidDebugBridge
-
- $(ProgramFiles32)\Git\bin
-
- Release
- Debug
- x86
- $(Platform)
- x86
-
- PLATFORMX86
- PLATFORMX64
- PLATFORMIA64
- PLATFORMX86
- WINDOWS
-
- false
- $(MSBuildProjectDirectory)\..\bin\
- $(MSBuildProjectDirectory)\..\
- $([System.DateTime]::UtcNow.ToString("MM-dd-yyyy"))
- $([System.DateTime]::UtcNow.ToString("hh:mm:ss"))
-
- True
- true
- $(CompileDependsOn)
- None
-
- $(CompileDependsOn)
-
- PublishNuGet
- $(MSBuildProjectDirectory)\..\.nuget
- x86
- E:\Development\deploy\nuget
- madbee
- $(CCNetProject).$(Platform)
- $(CCNetProject)
- $(MSBuildProjectDirectory)\Build\publish-changelog.txt
- $(CCNetArtifactDirectory)\$(Configuration)\nuget\
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Build/WebPublish.msbuild b/Build/WebPublish.msbuild
deleted file mode 100644
index 3476f98..0000000
--- a/Build/WebPublish.msbuild
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
- 12.0
- Madb.Site
-
- $(MSBuildProjectDirectory)\..\$(ProjectName)
- S:\deploy\$(ProjectName)
-
-
-
- Release
- AnyCPU
- bin\
-
- True
- Configuration=$(Configuration);Platform=$(Platform);OutputPath=$(OutputPath);VisualStudioVersion=12.0;DefineConstants=MVC5
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Build/appveyor-variables.txt b/Build/appveyor-variables.txt
deleted file mode 100644
index 2a31aba..0000000
--- a/Build/appveyor-variables.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-APPVEYOR - True if build runs in AppVeyor environment;
-CI - True if build runs in AppVeyor environment;
-APPVEYOR_API_URL - AppVeyor Build Agent API URL;
-APPVEYOR_ACCOUNT_NAME - account name;
-APPVEYOR_PROJECT_ID - AppVeyor unique project ID;
-APPVEYOR_PROJECT_NAME - project name;
-APPVEYOR_PROJECT_SLUG - project slug (as seen in project details URL);
-APPVEYOR_BUILD_FOLDER - path to clone directory;
-APPVEYOR_BUILD_ID - AppVeyor unique build ID;
-APPVEYOR_BUILD_NUMBER - build number;
-APPVEYOR_BUILD_VERSION - build version;
-APPVEYOR_PULL_REQUEST_NUMBER - GitHub Pull Request number;
-APPVEYOR_PULL_REQUEST_TITLE - GitHub Pull Request title
-APPVEYOR_JOB_ID - AppVeyor unique job ID;
-APPVEYOR_REPO_PROVIDER - GitHub, BitBucket or Kiln;
-APPVEYOR_REPO_SCM - git or mercurial;
-APPVEYOR_REPO_NAME - repository name in format owner-name/repo-name;
-APPVEYOR_REPO_BRANCH - build branch. For Pull Request commits it is base branch PR is merging into;
-APPVEYOR_REPO_TAG - true if build has started by pushed tag; otherwise false;
-APPVEYOR_REPO_TAG_NAME - contains tag name for builds started by tag; otherwise this variable is undefined;
-APPVEYOR_REPO_COMMIT - commit ID (SHA);
-APPVEYOR_REPO_COMMIT_AUTHOR - commit author's name;
-APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL - commit author's email address;
-APPVEYOR_REPO_COMMIT_TIMESTAMP - commit date/time;
-APPVEYOR_REPO_COMMIT_MESSAGE - commit message;
-APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED - the rest of commit message after line break (if exists);
-APPVEYOR_SCHEDULED_BUILD - True if the build runs by scheduler;
-APPVEYOR_FORCED_BUILD (True or undefined) - builds started by "New build" button or from the same API;
-APPVEYOR_RE_BUILD (True or undefined) - build started by "Re-build commit/PR" button of from the same API;
-PLATFORM - platform name set on Build tab of project settings (or through platform parameter in appveyor.yml);
-CONFIGURATION - configuration name set on Build tab of project settings (or through configuration parameter in appveyor.yml);
\ No newline at end of file
diff --git a/Build/appveyor.after-build.ps1 b/Build/appveyor.after-build.ps1
deleted file mode 100644
index 7ec0164..0000000
--- a/Build/appveyor.after-build.ps1
+++ /dev/null
@@ -1,4 +0,0 @@
-if( !(Test-Path -Path Env:\MADB_BUILD_VERSION) -and (Test-Path -Path .\VersionAssemblyInfo.txt) ) {
- $version = (Get-Content -Path .\VersionAssemblyInfo.txt)
- $env:MADB_BUILD_VERSION = $version;
-}
\ No newline at end of file
diff --git a/Build/appveyor.after-deployment.ps1 b/Build/appveyor.after-deployment.ps1
deleted file mode 100644
index 9818b72..0000000
--- a/Build/appveyor.after-deployment.ps1
+++ /dev/null
@@ -1,6 +0,0 @@
-# This cleans up any environment variables that may need to be reset
-# this probably isn't needed, but it doesn't hurt.
-
-if( (Test-Path -Path Env:\MADB_BUILD_VERSION) ) {
- $env:MADB_BUILD_VERSION = '';
-}
\ No newline at end of file
diff --git a/Build/appveyor.before-build.ps1 b/Build/appveyor.before-build.ps1
deleted file mode 100644
index 7663e9d..0000000
--- a/Build/appveyor.before-build.ps1
+++ /dev/null
@@ -1,8 +0,0 @@
-$rootLocation = ((Get-Item Env:\APPVEYOR_BUILD_FOLDER).Value);
-$trunk = "$rootLocation\trunk\Managed.AndroidDebugBridge";
-# change to the trunk
-$ignore = Set-Location $trunk;
-
-.\Build\InstallPfx.ps1 -pfx "$trunk\Shared\madb.pfx" -password ((Get-Item Env:\MADB_PFX_KEY).Value) -containerName ((Get-Item Env:\VS_PFX_KEY).Value);
-# Go back to the root folder
-$ignore = Set-Location ((Get-Item Env:\APPVEYOR_BUILD_FOLDER).Value);
\ No newline at end of file
diff --git a/Build/appveyor.before-deployment.ps1 b/Build/appveyor.before-deployment.ps1
deleted file mode 100644
index d01ca04..0000000
--- a/Build/appveyor.before-deployment.ps1
+++ /dev/null
@@ -1,41 +0,0 @@
-<#
- #
- #
- #>
-
-$commitMessageRegex = "^\[deploy\:(pre-release|draft|release)\]";
-
-# Must come from master branch.
-# Must not have a PULL Request Number
-# Must match regex
-
-
-Write-Host "$env:APPVEYOR_REPO_COMMIT_MESSAGE -match $commitMessageRegex";
-Write-Host "Branch: $env:APPVEYOR_REPO_BRANCH";
-
-if ( ($env:APPVEYOR_REPO_BRANCH -eq "master") -and ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match $commitMessageRegex) ) {
- $env:CI_RELEASE_DESCRIPTION = $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED
- $env:CI_DEPLOY_NUGET = $true;
- $env:CI_DEPLOY_GITHUB = $true;
- $env:CI_DEPLOY_FTP = $true;
- $env:CI_DEPLOY_WebHook = $true;
- $env:CI_DEPLOY_WebDeploy = $true;
-
- $env:CI_DEPLOY_GITHUB_ISDRAFT = "false";
- $env:CI_DEPLOY_GITHUB_ISPRERELEASE = "false";
-
- if($matches[1] -ieq "draft") {
- $env:CI_DEPLOY_GITHUB_ISDRAFT = "true";
- }
- if($matches[1] -ieq "pre-release") {
- $env:CI_DEPLOY_GITHUB_ISDRAFT = "false";
- }
-
-} else {
- # Do not assign a release number or deploy
- $env:CI_DEPLOY_NUGET = $false;
- $env:CI_DEPLOY_GITHUB = $false;
- $env:CI_DEPLOY_FTP = $false;
- $env:CI_DEPLOY_WebHook = $false;
- $env:CI_DEPLOY_WebDeploy = $false;
-}
\ No newline at end of file
diff --git a/Build/keyimport.bat b/Build/keyimport.bat
deleted file mode 100644
index 1c9cdcf..0000000
--- a/Build/keyimport.bat
+++ /dev/null
@@ -1 +0,0 @@
- sn -i ..\shared\madb.pfx VS_KEY_B66E4F208CF07E41
\ No newline at end of file
diff --git a/Build/madbee.nuspec b/Build/madbee.nuspec
deleted file mode 100644
index c50678a..0000000
--- a/Build/madbee.nuspec
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
- Managed.AndroidDebugBridge
- 1.0.0.0
- Ryan Conrad
- Ryan Conrad
- Managed Android Debug Bridge (MadBee)
- A managed library for communicating with the Android Debug Bridge. See more info @ https://github.com/camalot/madb
- This is a Managed port of the Android Debug Bridge to allow communication from .NET applications to Android devices. This wraps the same methods that the ddms uses to directly communicate with ADB. This gives more flexibility to the developer then launching an adb process and executing one of its build in commands.
- https://github.com/camalot/madb
- https://raw.githubusercontent.com/camalot/madb/master/license.md
- false
- http://i.imgur.com/OOliDq6.png
- android adb library
- en-US
-
- Copyright 2015 Ryan Conrad
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Build/publish-changelog.txt b/Build/publish-changelog.txt
deleted file mode 100644
index 0a7ff88..0000000
--- a/Build/publish-changelog.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-* builds against .net 4.5.1
-* removed the ilmerge. dependencies are now pulled from nuget
-* added reference to camalot.common (this lib has a hard version reference, will be fixed in the future)
-* removed some extensions that were duplicated from camalot.common
diff --git a/Build/set-environment-variable.ps1 b/Build/set-environment-variable.ps1
deleted file mode 100644
index 79bf2e7..0000000
--- a/Build/set-environment-variable.ps1
+++ /dev/null
@@ -1,6 +0,0 @@
-Param (
- [string] $Name,
- [string] $Value
-);
-
-(Set-Item -Path Env:\${Name} -Value $Value);
\ No newline at end of file
diff --git a/Madb.Site/Madb.Site.csproj b/Madb.Site/Madb.Site.csproj
index a0e3727..3eac823 100644
--- a/Madb.Site/Madb.Site.csproj
+++ b/Madb.Site/Madb.Site.csproj
@@ -62,8 +62,8 @@
..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll
-
- ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll
True
diff --git a/Madb.Site/Web.config b/Madb.Site/Web.config
index da7437e..6f658cf 100644
--- a/Madb.Site/Web.config
+++ b/Madb.Site/Web.config
@@ -71,7 +71,7 @@
-
+
diff --git a/Madb.Site/packages.config b/Madb.Site/packages.config
index 522e7c3..d77fa47 100644
--- a/Madb.Site/packages.config
+++ b/Madb.Site/packages.config
@@ -17,7 +17,7 @@
-
+
diff --git a/Managed.Adb.Tests/AdbHelperTests.cs b/Managed.Adb.Tests/AdbHelperTests.cs
deleted file mode 100644
index 5d20336..0000000
--- a/Managed.Adb.Tests/AdbHelperTests.cs
+++ /dev/null
@@ -1,326 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-using System.IO;
-using Managed.Adb.IO;
-using System.Drawing.Imaging;
-using Managed.Adb.Exceptions;
-
-namespace Managed.Adb.Tests {
- public class AdbHelperTests : BaseDeviceTests {
-
-
- [Fact]
- public void GetDevicesTest ( ) {
- List devices = AdbHelper.Instance.GetDevices ( AndroidDebugBridge.SocketAddress );
- Assert.True ( devices.Count >= 1 );
- foreach ( var item in devices ) {
- Console.WriteLine ( "{0}\t{1}{2}", item.SerialNumber, item.State, item.IsEmulator ? " - Emulator" : String.Empty );
- }
- }
-
- [Fact]
- public void KillAdbTest ( ) {
- var device = GetFirstDevice ( );
- AdbHelper.Instance.KillAdb ( AndroidDebugBridge.SocketAddress );
- }
-
- [Fact]
- public void DeviceGetMountPointsTest ( ) {
- Device device = GetFirstDevice ( );
- foreach ( var item in device.MountPoints.Keys ) {
- Console.WriteLine ( device.MountPoints[item] );
- }
-
- Assert.True ( device.MountPoints.ContainsKey ( "/system" ) );
- }
-
- [Fact]
- public void DeviceRemountMountPointTest ( ) {
- Device device = GetFirstDevice ( );
-
- Assert.True ( device.MountPoints.ContainsKey ( "/system" ), "Device does not contain mount point /system" );
- bool isReadOnly = device.MountPoints["/system"].IsReadOnly;
-
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- device.RemountMountPoint ( device.MountPoints["/system"], !isReadOnly );
- } ) );
-
- Assert.Equal ( !isReadOnly, device.MountPoints["/system"].IsReadOnly );
- Console.WriteLine ( "Successfully mounted /system as {0}", !isReadOnly ? "ro" : "rw" );
-
- // revert it back...
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- device.RemountMountPoint ( device.MountPoints["/system"], isReadOnly );
- } ) );
- Assert.Equal ( isReadOnly, device.MountPoints["/system"].IsReadOnly );
- Console.WriteLine ( "Successfully mounted /system as {0}", isReadOnly ? "ro" : "rw" );
-
- }
-
- [Fact]
- public void ExecuteRemoteCommandTest ( ) {
-
- Device device = GetFirstDevice ( );
- ConsoleOutputReceiver creciever = new ConsoleOutputReceiver ( );
-
-
- device.ExecuteShellCommand("pm list packages -f",creciever);
-
- Console.WriteLine ( "Executing 'ls':" );
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- try {
- device.ExecuteShellCommand ( "ls -lF --color=never", creciever );
- } catch ( UnknownOptionException ) {
- device.ExecuteShellCommand ( "ls -l", creciever );
- }
- } ) );
-
-
- Console.WriteLine ( "Executing 'busybox':" );
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- bool hasBB = false;
- try {
- device.ExecuteShellCommand ( "busybox", creciever );
- hasBB = true;
- } catch ( FileNotFoundException ) {
- hasBB = false;
- } finally {
- Console.WriteLine ( "Busybox enabled: {0}", hasBB );
- }
- } ) );
-
- Console.WriteLine ( "Executing 'unknowncommand':" );
- Assert.Throws ( new Assert.ThrowsDelegate ( delegate ( ) {
- device.ExecuteShellCommand ( "unknowncommand", creciever );
- } ) );
-
- Console.WriteLine ( "Executing 'ls /system/foo'" );
- Assert.Throws ( new Assert.ThrowsDelegate ( delegate ( ) {
- device.ExecuteShellCommand ("ls /system/foo", creciever );
- } ) );
-
- }
-
- [Fact]
- public void ExecuteRemoteRootCommandTest( ) {
- Device device = GetFirstDevice ( );
- ConsoleOutputReceiver creciever = new ConsoleOutputReceiver ( );
-
- Console.WriteLine ( "Executing 'ls':" );
- if ( device.CanSU ( ) ) {
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- try {
- device.ExecuteRootShellCommand ( "busybox ls -lFa --color=never", creciever );
- } catch ( UnknownOptionException ) {
- device.ExecuteRootShellCommand ( "ls -lF", creciever );
- }
- } ) );
- } else {
- // if the device doesn't have root, then we check that it is throwing the PermissionDeniedException
- Assert.Throws ( new Assert.ThrowsDelegate(delegate ( ) {
- try {
- device.ExecuteRootShellCommand ( "busybox ls -lFa --color=never", creciever );
- } catch ( UnknownOptionException ) {
- device.ExecuteRootShellCommand ( "ls -lF", creciever );
- }
- } ) );
- }
- }
-
- [Fact]
- public void GetRawImageTest ( ) {
- Device device = GetFirstDevice ( );
-
- RawImage rawImage = device.Screenshot;
-
- Assert.NotNull ( rawImage );
- Assert.Equal ( 32, rawImage.Bpp );
- Assert.Equal ( 480, rawImage.Width );
- Assert.Equal ( 800, rawImage.Height );
-
- rawImage.ToImage ( PixelFormat.Format32bppArgb ).Save ( @"c:\Users\Ryan\Desktop\file.png",ImageFormat.Png );
-
- }
-
- [Fact]
- public void FileListingServiceTest ( ) {
- Device device = GetFirstDevice ( );
- device.FileListingService.ForceBusyBox = true;
- FileEntry[] entries = device.FileListingService.GetChildren ( device.FileListingService.Root, false, null );
- foreach ( var item in entries ) {
- Console.WriteLine ( item.FullPath );
- }
- }
-
- [Fact]
- public void SyncServicePullFileTest ( ) {
- Device device = GetFirstDevice ( );
- using ( SyncService sync = device.SyncService ) {
- String rfile = "/sdcard/bootanimations/bootanimation-cm.zip";
- FileEntry rentry = device.FileListingService.FindFileEntry ( rfile );
-
- String lpath = Environment.GetFolderPath ( Environment.SpecialFolder.DesktopDirectory );
- String lfile = Path.Combine ( lpath, LinuxPath.GetFileName ( rfile ) );
- FileInfo lfi = new FileInfo ( lfile );
- SyncResult result = sync.PullFile ( rfile, lfile, new FileSyncProgressMonitor ( ) );
-
- Assert.True ( lfi.Exists );
- Assert.True ( ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString ( result.Code ) );
- lfi.Delete ( );
-
- result = sync.PullFile ( rentry, lfile, new FileSyncProgressMonitor ( ) );
- Assert.True ( lfi.Exists );
- Assert.True ( ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString ( result.Code ) );
- lfi.Delete ( );
-
- }
- }
-
- [Fact]
- public void SyncServicePushFileTest ( ) {
- String testFile = CreateTestFile ( );
- FileInfo localFile = new FileInfo ( testFile );
- String remoteFile = String.Format ( "/sdcard/{0}", Path.GetFileName ( testFile ) );
- Device device = GetFirstDevice ( );
-
-
- using ( SyncService sync = device.SyncService ) {
- SyncResult result = sync.PushFile ( localFile.FullName, remoteFile, new FileSyncProgressMonitor ( ) );
- Assert.True ( ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString ( result.Code ) );
- FileEntry remoteEntry = null;
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- remoteEntry = device.FileListingService.FindFileEntry ( remoteFile );
- } ) );
-
- // check the size
- Assert.Equal ( localFile.Length, remoteEntry.Size );
-
- // clean up temp file on sdcard
- device.ExecuteShellCommand ( String.Format ( "rm {0}", remoteEntry.FullEscapedPath ), new ConsoleOutputReceiver ( ) );
- }
- }
-
- [Fact]
- public void SyncServicePullFilesTest ( ) {
- Device device = GetFirstDevice ( );
- using ( SyncService sync = device.SyncService ) {
- String lpath = Path.Combine ( Environment.GetFolderPath ( Environment.SpecialFolder.DesktopDirectory ), "apps" );
- String rpath = "/system/app/";
- DirectoryInfo ldir = new DirectoryInfo ( lpath );
- if ( !ldir.Exists ) {
- ldir.Create ( );
- }
- FileEntry fentry = device.FileListingService.FindFileEntry ( rpath );
- Assert.True ( fentry.IsDirectory );
-
- FileEntry[] entries = device.FileListingService.GetChildren ( fentry, false, null );
- SyncResult result = sync.Pull ( entries, ldir.FullName, new FileSyncProgressMonitor ( ) );
-
- Assert.True ( ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString ( result.Code ) );
- }
- }
-
- [Fact]
- public void DeviceInstallPackageTest ( ) {
- Device device = GetFirstDevice ( );
- String package = Path.Combine ( Environment.GetFolderPath ( Environment.SpecialFolder.DesktopDirectory ), "com.camalotdesigns.httpdump.apk" );
- Assert.True ( File.Exists ( package ) );
-
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- device.InstallPackage ( package, false );
- } ) );
- }
-
- [Fact]
- public void DeviceUninstallPackageTest ( ) {
- Device device = GetFirstDevice ( );
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- device.UninstallPackage ( "com.camalotdesigns.httpdump" );
- } ) );
- }
-
- [Fact]
- public void DeviceEnvironmentVariablesTest ( ) {
- Device device = GetFirstDevice ( );
- foreach ( var key in device.EnvironmentVariables.Keys ) {
- Console.WriteLine ( "{0}={1}", key, device.EnvironmentVariables[key] );
- }
-
- Assert.True ( device.EnvironmentVariables.Count > 0 );
- Assert.True ( device.EnvironmentVariables.ContainsKey ( "ANDROID_ROOT" ) );
- }
-
- [Fact]
- public void DevicePropertiesTest ( ) {
- Device device = GetFirstDevice ( );
- foreach ( var key in device.Properties.Keys ) {
- Console.WriteLine ( "[{0}]: {1}", key, device.Properties[key] );
- }
-
- Assert.True ( device.Properties.Count > 0 );
- Assert.True ( device.Properties.ContainsKey ( "ro.product.device" ) );
- }
-
-
-
-
- private String CreateTestFile ( ) {
- String tfile = Path.GetTempFileName ( );
- Random r = new Random ( (int)DateTime.Now.Ticks );
-
- using ( var fs = new FileStream ( tfile, System.IO.FileMode.Create, FileAccess.Write ) ) {
- for ( int i = 0; i < 1024; i++ ) {
- byte[] buffer = new byte[1024];
- r.NextBytes ( buffer );
- fs.Write ( buffer, 0, buffer.Length );
- }
- }
- return tfile;
- }
-
-
- public class FileListingServiceReceiver : IListingReceiver {
-
- public void SetChildren ( FileEntry entry, FileEntry[] children ) {
- entry.Children.Clear ( );
- entry.Children.AddRange ( children );
- }
-
- public void RefreshEntry ( FileEntry entry ) {
- entry.FetchTime = 0;
- }
- }
-
- public class FileSyncProgressMonitor : ISyncProgressMonitor {
-
- public void Start ( long totalWork ) {
- Console.WriteLine ( "Starting Transfer" );
- this.TotalWork = this.Remaining = totalWork;
- Transfered = 0;
- }
-
- public void Stop ( ) {
- IsCanceled = true;
- }
-
- public bool IsCanceled { get; private set; }
-
- public void StartSubTask ( String source, String destination ) {
- Console.WriteLine ( "Syncing {0} -> {1}", source, destination );
- }
-
- public void Advance ( long work ) {
- Transfered += work;
- Remaining -= work;
- Console.WriteLine ( "Transfered {0} of {1} - {2} remaining", Transfered, TotalWork, Remaining );
- }
-
- public long TotalWork { get; set; }
- public long Remaining { get; set; }
- public long Transfered { get; set; }
- }
- }
-}
diff --git a/Managed.Adb.Tests/AndroidDebugBridgeTests.cs b/Managed.Adb.Tests/AndroidDebugBridgeTests.cs
deleted file mode 100644
index 72d6206..0000000
--- a/Managed.Adb.Tests/AndroidDebugBridgeTests.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-using System.IO;
-using MoreLinq;
-namespace Managed.Adb.Tests {
- public class AndroidDebugBridgeTests : BaseDeviceTests {
-
- [Fact]
- public void CreateBridgeTest ( ) {
- try {
- AndroidDebugBridge adb = CreateBridge ( @"d:\android\android-sdk\platform-tools\adb.exe" );
- bool result = adb.Start ( );
- Assert.True ( result, "Failed to start ADB" );
-
- adb.Devices.ForEach ( d => {
- Console.WriteLine ( "{0}\t{1}", d.SerialNumber, d.State );
- } );
-
- adb.Stop ( );
- } catch ( Exception ex ) {
- Console.WriteLine ( ex.ToString ( ) );
- throw;
- }
- }
-
- private AndroidDebugBridge CreateBridge ( String location ) {
- AndroidDebugBridge adb = AndroidDebugBridge.CreateBridge ( location, false );
- return adb;
- }
- }
-}
diff --git a/Managed.Adb.Tests/BaseDeviceTests.cs b/Managed.Adb.Tests/BaseDeviceTests.cs
deleted file mode 100644
index 0138bf4..0000000
--- a/Managed.Adb.Tests/BaseDeviceTests.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-
-namespace Managed.Adb.Tests {
- public class BaseDeviceTests {
- protected Device GetFirstDevice( ) {
- List devices = AdbHelper.Instance.GetDevices ( AndroidDebugBridge.SocketAddress );
- Assert.True ( devices.Count >= 1 );
- return devices[0];
- }
-
- }
-}
diff --git a/Managed.Adb.Tests/BatteryInfoTests.cs b/Managed.Adb.Tests/BatteryInfoTests.cs
deleted file mode 100644
index 4d26bfc..0000000
--- a/Managed.Adb.Tests/BatteryInfoTests.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-
-namespace Managed.Adb.Tests {
- public class BatteryInfoTests : BaseDeviceTests {
-
- [Fact]
- public void GetBatteryInfoTest ( ) {
- Device device = GetFirstDevice ( );
- Assert.NotNull ( device );
-
- var batteryInfo = device.GetBatteryInfo ( );
- Assert.True ( batteryInfo.Present );
- Console.WriteLine ( batteryInfo.ToString ( ) );
- }
-
- }
-}
diff --git a/Managed.Adb.Tests/BusyBoxTests.cs b/Managed.Adb.Tests/BusyBoxTests.cs
deleted file mode 100644
index 41d0135..0000000
--- a/Managed.Adb.Tests/BusyBoxTests.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.IO;
-using Xunit;
-
-namespace Managed.Adb.Tests {
- public class BusyBoxTests : BaseDeviceTests {
-
- [Fact]
- public void GetCommandsTest( ) {
- Device device = GetFirstDevice ( );
- bool avail = device.BusyBox.Available;
- Assert.True ( avail, "BusyBox is not available" );
-
-
- foreach ( var item in device.BusyBox.Commands ) {
- Console.Write ( "{0},", item );
- }
-
- Assert.True ( avail && device.BusyBox.Commands.Count > 0 );
- }
-
- [Fact]
- public void InstallTest( ) {
- Device device = GetFirstDevice ( );
- bool avail = device.BusyBox.Available;
- if ( !avail ) {
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- bool result = device.BusyBox.Install ( "/sdcard/busybox" );
- Assert.True ( result, "BusyBox Install returned false" );
- } ) );
- }
-
- device.ExecuteShellCommand ( "printenv", new ConsoleOutputReceiver ( ) );
-
- Assert.True ( device.BusyBox.Available, "BusyBox is not installed" );
- }
-
- [Fact]
- public void ExecuteRemoteCommandTest( ) {
- Device device = GetFirstDevice ( );
- ConsoleOutputReceiver creciever = new ConsoleOutputReceiver ( );
-
- Console.WriteLine ( "Executing 'busybox':" );
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- bool hasBB = false;
- try {
- device.ExecuteShellCommand ( "busybox", creciever );
- hasBB = true;
- } catch ( FileNotFoundException ) {
- hasBB = false;
- } finally {
- Console.WriteLine ( "Busybox enabled: {0}", hasBB );
- }
- } ) );
-
-
- Console.WriteLine ( "Executing 'busybox ls': " );
- Assert.DoesNotThrow ( new Assert.ThrowsDelegate ( delegate ( ) {
- try {
- device.BusyBox.ExecuteShellCommand ( "ls", creciever );
- } catch ( Exception ex) {
- Console.WriteLine ( ex.Message );
- throw;
- }
- } ) );
- }
-
- }
-}
diff --git a/Managed.Adb.Tests/DeviceTests.cs b/Managed.Adb.Tests/DeviceTests.cs
deleted file mode 100644
index 936548d..0000000
--- a/Managed.Adb.Tests/DeviceTests.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-
-namespace Managed.Adb.Tests {
- public class DeviceTests : BaseDeviceTests {
- [Fact]
- public void CanBackupTest ( ) {
- var device = GetFirstDevice ( );
-
- Assert.True ( device.CanBackup ( ) );
- }
-
- [Fact]
- public void BackupTest ( ) {
- var device = GetFirstDevice ( );
- device.Backup ( );
- }
- }
-}
diff --git a/Managed.Adb.Tests/FileEntryTests.cs b/Managed.Adb.Tests/FileEntryTests.cs
deleted file mode 100644
index 7319b22..0000000
--- a/Managed.Adb.Tests/FileEntryTests.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-
-namespace Managed.Adb.Tests {
- public class FileEntryTests : BaseDeviceTests {
-
- [Fact]
- public void FindEntryTest ( ) {
- Device device = GetFirstDevice ( );
-
- FileEntry fe = FileEntry.Find ( device, "/system/" );
-
- fe = FileEntry.Find ( device, "/" );
-
-
- fe = FileEntry.Find ( device, "/system/bin/" );
-
- fe = FileEntry.Find ( device, "/mnt/sdcard/Android/data/com.camalotdesigns.myandroider/Injector.jar" );
- // test links
- fe = FileEntry.Find ( device, "/sdcard/Android/data/com.camalotdesigns.myandroider/Injector.jar" );
-
- }
-
-
- [Fact]
- public void FindOrCreateTest( ) {
- Device device = GetFirstDevice ( );
- var path ="/mnt/sdcard/test/delete/";
- FileEntry fe = FileEntry.FindOrCreate ( device, path );
- Assert.True ( fe.Exists );
- device.FileSystem.Delete ( fe.FullResolvedPath );
- }
-
-
- }
-}
diff --git a/Managed.Adb.Tests/FileSystemTests.cs b/Managed.Adb.Tests/FileSystemTests.cs
deleted file mode 100644
index 994f234..0000000
--- a/Managed.Adb.Tests/FileSystemTests.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
-using MoreLinq;
-using Camalot.Common.Extensions;
-
-namespace Managed.Adb.Tests {
- public class FileSystemTests : BaseDeviceTests {
- [Fact]
- public void GetDeviceBlocksTest( ) {
- Device d = GetFirstDevice ( );
- IEnumerable blocks = d.FileSystem.DeviceBlocks;
- blocks.ForEach ( b => {
- Console.WriteLine ( b.ToString ( ) );
- } );
- Assert.True ( blocks.Count() > 0 );
- }
-
- [Fact]
- public void MakeDirectory( ) {
- Device d = GetFirstDevice ( );
- var testPath = "/mnt/sdcard/test/delete/";
- Console.WriteLine ( "Making directory: {0}", testPath );
- d.FileSystem.MakeDirectory ( testPath );
- Assert.True ( d.FileSystem.Exists ( testPath ) );
- Console.WriteLine ( "Deleting {0}", testPath );
- d.FileSystem.Delete(testPath);
- Assert.True ( !d.FileSystem.Exists ( testPath ) );
-
- Console.WriteLine ( "Making directory (forced): {0}", testPath );
- d.FileSystem.MakeDirectory ( testPath,true );
- Assert.True ( d.FileSystem.Exists ( testPath ) );
- Console.WriteLine ( "Deleting {0}", testPath );
- d.FileSystem.Delete ( testPath );
- Assert.True ( !d.FileSystem.Exists ( testPath ) );
- }
-
- [Fact]
- public void ResolveLink ( ) {
- Device d = GetFirstDevice ( );
- var vendor = d.FileSystem.ResolveLink ( "/vendor" );
- Assert.Equal ( vendor, "/system/vendor" );
- Console.WriteLine ( "/vendor -> {0}".With ( vendor ) );
-
- var nonsymlink = d.FileSystem.ResolveLink ( "/system" );
- Assert.Equal ( nonsymlink, "/system" );
- Console.WriteLine ( "/system -> {0}".With ( nonsymlink ) );
-
-
- var legacy = "/storage/emulated/legacy";
- var sdcard0 = "/storage/sdcard0";
-
- var sdcard = d.FileSystem.ResolveLink ( "/sdcard" );
- // depending on the version of android
- Assert.True ( sdcard.Equals ( legacy ) || sdcard.Equals ( sdcard0 ) );
- Console.WriteLine ( "/sdcard -> {0}".With ( sdcard ) );
-
- }
- }
-}
diff --git a/Managed.Adb.Tests/ForIO/ForByteOrder/ByteOrder.cs b/Managed.Adb.Tests/ForIO/ForByteOrder/ByteOrder.cs
new file mode 100644
index 0000000..ed700c7
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForByteOrder/ByteOrder.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIO.ForByteOrder {
+ public class ByteOrder {
+ [Fact]
+ public void WhenBigEdianName_ShouldReturnBigEdian ( ) {
+ var fixture = new Fixture ( );
+
+ var be = IO.ByteOrder.BIG_ENDIAN;
+ Assert.Equal ( be.Name, "BIG_ENDIAN" );
+ }
+
+ [Fact]
+ public void WhenBigEdianToString_ShouldReturnBigEdian ( ) {
+ var fixture = new Fixture ( );
+
+ var be = IO.ByteOrder.BIG_ENDIAN;
+ Assert.Equal ( be.ToString(), "BIG_ENDIAN" );
+ }
+
+
+ [Fact]
+ public void WhenLittleEdianName_ShouldReturnBigEdian ( ) {
+ var fixture = new Fixture ( );
+
+ var be = IO.ByteOrder.LITTLE_ENDIAN;
+ Assert.Equal ( be.Name, "LITTLE_ENDIAN" );
+ }
+
+ [Fact]
+ public void WhenLittleEdianToString_ShouldReturnBigEdian ( ) {
+ var fixture = new Fixture ( );
+
+ var be = IO.ByteOrder.LITTLE_ENDIAN;
+ Assert.Equal ( be.ToString ( ), "LITTLE_ENDIAN" );
+ }
+
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/ChangeExtensionTests.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/ChangeExtensionTests.cs
new file mode 100644
index 0000000..b6b8d6f
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/ChangeExtensionTests.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class ChangeExtensionTests {
+
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull () {
+ string result = LinuxPath.ChangeExtension ( null, "ext" );
+ Assert.Null ( result );
+ }
+
+ ///
+ /// Whens the path contains invalid character_ should throw argument exception.
+ ///
+ [Fact]
+ public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.ChangeExtension ("/my-invalid-path/f-{0}".With ( LinuxPathConsts.InvalidPathChars[x]), "ext" );
+ } catch (ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+ }
+
+ [Fact]
+ public void WhenPathLengthIsZero_ShouldReturnEmpty () {
+ string result = LinuxPath.ChangeExtension ( string.Empty, "ext" );
+ Assert.Equal ( string.Empty, result );
+ }
+
+ [Fact]
+ public void WhenExtensionIsEmpty_ShouldReturnPath ( ) {
+ string result = LinuxPath.ChangeExtension ( "/my-path/to/file.ext1", string.Empty );
+ Assert.Equal ( "/my-path/to/file.ext1", result );
+ }
+
+ [Fact]
+ public void WhenExtensionDoesNotStartWithDot_ShouldReturnChangedExtensionWithDot () {
+ string result = LinuxPath.ChangeExtension ( "/my-path/to/file.ext1", "ext2" );
+ Assert.Equal ( "/my-path/to/file.ext2", result );
+ }
+
+ [Fact]
+ public void WhenExtensionStartsWithDot_ShouldReturnChangedExtension ( ) {
+ string result = LinuxPath.ChangeExtension ( "/my-path/to/file.ext1", ".ext2" );
+ Assert.Equal ( "/my-path/to/file.ext2", result );
+ }
+
+ [Fact]
+ public void WhenPathHasNoExtension_ShouldReturnPathWithExtension ( ) {
+ string result = LinuxPath.ChangeExtension ( "/my-path/to/file", ".ext2" );
+ Assert.Equal ( "/my-path/to/file.ext2", result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/CombineTests.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/CombineTests.cs
new file mode 100644
index 0000000..1bb0cb1
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/CombineTests.cs
@@ -0,0 +1,347 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class CombineTests {
+ [Fact]
+ public void When2ArgsAndPath1IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( null, fixture.Create ( "path2" ) );
+ } );
+ }
+ [Fact]
+ public void When2ArgsAndPath2IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( fixture.Create ( "path1" ), null );
+ } );
+ }
+
+ [Fact]
+ public void When2ArgsAndPath1IsEmpty_ShouldReturnRelativePath2 ( ) {
+ var fixture = new Fixture ( );
+ var p2 = fixture.Create ( "path2-" );
+ var result = LinuxPath.Combine ( string.Empty, p2 );
+ Assert.Equal ( "./{0}/".With ( p2 ), result );
+ }
+
+ [Fact]
+ public void When2ArgsAndPath1IsEmptyAndPath2IsRooted_ShouldReturnRootedPath2 ( ) {
+ var fixture = new Fixture ( );
+ var p2 = fixture.Create ( "/path2-" );
+ var result = LinuxPath.Combine ( string.Empty, p2 );
+ Assert.Equal ( "/{0}/".With ( p2 ).REReplace ( "//", "/" ), result );
+ }
+
+ [Fact]
+ public void When2ArgsAndPath2IsEmpty_ShouldReturnRelativePath1 ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "path1-" );
+ var p2 = string.Empty;
+ var result = LinuxPath.Combine ( p1, p2 );
+ Assert.Equal ( "./{0}/".With ( p1 ), result );
+ }
+
+ [Fact]
+ public void When2ArgsAndPath2IsEmptyAndPath2IsRooted_ShouldReturnRootedPath1 ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = string.Empty;
+ var result = LinuxPath.Combine ( p1, p2 );
+ Assert.Equal ( "/{0}/".With ( p1 ).REReplace ( "//", "/" ), result );
+ }
+
+ [Fact]
+ public void When2ArgsAndPath1ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}-{1}".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "path1" ) ), fixture.Create ( "path2" ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When2ArgsAndPath2ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}".With ( fixture.Create ( "path1" ) ), "{0}-{1}".With ( fixture.Create ( "path2" ), LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When2Args_ShouldReturnCombined ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1" );
+ var p2 = fixture.Create ( "path2" );
+ var result = LinuxPath.Combine ( p1, p2 );
+ Assert.Equal ( "{0}/{1}".With ( p1, p2 ), result );
+ }
+
+ [Fact]
+ public void When2ArgsAndPathsHaveSeparators_ShouldReturnCombined ( ) {
+ var fixture = new Fixture ( );
+ var p1 = "{0}/".With ( fixture.Create ( "/path1" ) );
+ var p2 = fixture.Create ( "path2" );
+ var result = LinuxPath.Combine ( p1, p2 );
+ Assert.Equal ( "{0}/{1}".With ( p1, p2 ).REReplace ( "//", "/" ), result );
+ }
+
+ [Fact]
+ public void When2ArgsAndPath2IsRooted_ShouldReturnPath2 ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = fixture.Create ( "/path2-" );
+ var result = LinuxPath.Combine ( p1, p2 );
+ Assert.Equal ( "{0}/".With ( p2 ), result );
+ }
+
+ [Fact]
+ public void When3ArgsAndPath1IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( null, fixture.Create ( "path2" ), fixture.Create ( "path3" ) );
+ } );
+ }
+
+ [Fact]
+ public void When3ArgsAndPath2IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( fixture.Create ( "path1" ), null, fixture.Create ( "path3" ) );
+ } );
+ }
+
+ [Fact]
+ public void When3ArgsAndPath3IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( fixture.Create ( "path1" ), fixture.Create ( "path2" ), null );
+ } );
+ }
+
+ [Fact]
+ public void When3ArgsAndPath1ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}-{1}".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "path1" ) ), fixture.Create ( "path2" ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When3ArgsAndPath2ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}".With ( fixture.Create ( "path1" ) ), "{0}-{1}".With ( fixture.Create ( "path2" ), LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When3ArgsAndPath3ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}".With ( fixture.Create ( "path1" ) ), fixture.Create ( "path2" ), "{0}-{1}".With ( fixture.Create ( "path3" ), LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When3Args_ShouldReturnCombined ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1" );
+ var p2 = fixture.Create ( "path2" );
+ var p3 = fixture.Create ( "path3" );
+ var result = LinuxPath.Combine ( p1, p2, p3 );
+ Assert.Equal ( "{0}/{1}/{2}".With ( p1, p2, p3 ), result );
+ }
+
+ [Fact]
+ public void When4ArgsAndPath1IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( null, fixture.Create ( "path2" ), fixture.Create ( "path3" ), fixture.Create ( "path4" ) );
+ } );
+ }
+
+ [Fact]
+ public void When4ArgsAndPath2IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( fixture.Create ( "path1" ), null, fixture.Create ( "path3" ), fixture.Create ( "path4" ) );
+ } );
+ }
+
+ [Fact]
+ public void When4ArgsAndPath3IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( fixture.Create ( "path1" ), fixture.Create ( "path2" ), null, fixture.Create ( "path4" ) );
+ } );
+ }
+ [Fact]
+ public void When4ArgsAndPath4IsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ Assert.Throws ( ( ) => {
+ var result = LinuxPath.Combine ( fixture.Create ( "path1" ), fixture.Create ( "path2" ), fixture.Create ( "path3" ), null );
+ } );
+ }
+
+ [Fact]
+ public void When4ArgsAndPath1ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}-{1}".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "path1" ) ), fixture.Create ( "path2" ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When4ArgsAndPath2ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}".With ( fixture.Create ( "path1" ) ), "{0}-{1}".With ( fixture.Create ( "path2" ), LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When4ArgsAndPath3ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}".With ( fixture.Create ( "path1" ) ), fixture.Create ( "path2" ), "{0}-{1}".With ( fixture.Create ( "path3" ), LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When4ArgsAndPath4ContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.Combine ( "/{0}".With ( fixture.Create ( "path1" ) ), fixture.Create ( "path2" ), fixture.Create ( "path3" ), "{0}-{1}".With ( fixture.Create ( "path4" ), LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+
+ [Fact]
+ public void When4Args_ShouldReturnCombined ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1" );
+ var p2 = fixture.Create ( "path2/" );
+ var p3 = fixture.Create ( "./path3" );
+ var p4 = fixture.Create ( "path4/" );
+ var result = LinuxPath.Combine ( p1, p2, p3, p4 );
+ Assert.Equal ( "{0}/{1}/{2}/{3}".With ( p1, p2, p3, p4 ), result );
+ }
+
+ [Fact]
+ public void WhenArgsArray_ShouldReturnCombined ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1" );
+ var p2 = fixture.Create ( "path2" );
+ var p3 = fixture.Create ( "path3" );
+ var p4 = fixture.Create ( "path4" );
+ var p5 = fixture.Create ( "path5" );
+ var result = LinuxPath.Combine ( p1, p2, p3, p4, p5 );
+ var expected = "{0}/{1}/{2}/{3}/{4}".With ( p1, p2, p3, p4, p5 );
+ Assert.Equal ( expected, result );
+ }
+
+ [Fact]
+ public void WhenArgsArrayIsNull_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ string[] args = null;
+ Assert.Throws ( ( ) => {
+ LinuxPath.Combine ( args );
+ } );
+ }
+
+ [Fact]
+ public void WhenArgsArrayContainsNullItem_ShouldThrowArgumentNullException ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1" );
+ string p2 = null;
+ var p3 = fixture.Create ( "path3" );
+ var p4 = fixture.Create ( "path4" );
+ var p5 = fixture.Create ( "path5" );
+ Assert.Throws ( ( ) => {
+ LinuxPath.Combine ( p1, p2, p3, p4, p5 );
+ } );
+
+ }
+
+
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/Escape.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/Escape.cs
new file mode 100644
index 0000000..6865a0c
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/Escape.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class Escape {
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnThrowArgumentNullException () {
+ Assert.Throws(() => {
+ LinuxPath.Escape ( null );
+ } );
+ }
+
+ [Fact]
+ public void WhenPathIsEmpty_ShouldReturnThrowArgumentNullException ( ) {
+ Assert.Throws ( ( ) => {
+ LinuxPath.Escape ( string.Empty );
+ } );
+ }
+
+
+ [Fact]
+ public void WhenPathDoesNotContainCharactersToEscape_ShouldReturnPathUnchanged ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "p1-" );
+ var result = LinuxPath.Escape ( p1 );
+ Assert.Equal ( p1, result );
+ }
+
+ [Fact]
+ public void WhenPathContiansCharacterToEscape_ShouldReturnEscapedString ( ) {
+ var chars = @"\()*+?""'#/".ToCharArray();
+ var fixture = new Fixture ( );
+
+ foreach ( var c in chars ) {
+ var b = "before-";
+ var a = "-after";
+ var check = "{0}{1}{2}".With ( b, c, a);
+ var result = LinuxPath.Escape ( check );
+ Assert.Equal ( "{0}\\{1}{2}".With ( b, c, a ), result );
+ }
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetDirectoryNameTests.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetDirectoryNameTests.cs
new file mode 100644
index 0000000..deba284
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetDirectoryNameTests.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetDirectoryNameTests {
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull ( ) {
+ var result = LinuxPath.GetDirectoryName ( null );
+ Assert.Null ( result );
+ }
+
+
+ [Fact]
+ public void WhenPathContainsInvalidCharacters_ShouldThrowException ( ) {
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.GetDirectoryName ( "/my-invalid-path/f-{0}".With ( LinuxPathConsts.InvalidPathChars[x] ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+ }
+
+ [Fact]
+ public void WhenPathLengthIs1_ShouldReturnRelativePath ( ) {
+ string result = LinuxPath.GetDirectoryName ( "a" );
+ Assert.Equal ( "./a/", result );
+ }
+
+ [Fact]
+ public void WhenPathLengthIsRoot_ShouldReturnRootPath ( ) {
+ string result = LinuxPath.GetDirectoryName ( "/" );
+ Assert.Equal ( "/", result );
+ }
+
+ [Fact]
+ public void WhenPathRelative_ShouldReturnRelativePath ( ) {
+ var fixture = new Fixture ( );
+ var p = fixture.Create ( "path" );
+ string result = LinuxPath.GetDirectoryName ( p );
+ Assert.Equal ( "./{0}/".With ( p ), result );
+ }
+
+ [Fact]
+ public void WhenPathRelativeWithFileWithExtension_ShouldReturnDirectoryRelativePath ( ) {
+ var fixture = new Fixture ( );
+ var p = fixture.Create ( "path" );
+ var pf = "{0}/file.ext".With ( p );
+ string result = LinuxPath.GetDirectoryName ( pf );
+ Assert.Equal ( "./{0}/".With ( p ), result );
+ }
+
+
+ [Fact]
+ public void WhenPathRelativeWithFileWithoutExtension_ShouldReturnDirectoryRelativePath ( ) {
+ var fixture = new Fixture ( );
+ var p = fixture.Create ( "path" );
+ var pf = "{0}/file".With ( p );
+ string result = LinuxPath.GetDirectoryName ( pf );
+ Assert.Equal ( "./{0}/".With ( p ), result );
+ }
+
+ [Fact]
+ public void WhenPathRootedWithFileWithExtension_ShouldReturnDirectoryRootedPath ( ) {
+ var fixture = new Fixture ( );
+ var p = fixture.Create ( "path" );
+ var pf = "/{0}/file.ext".With ( p );
+ string result = LinuxPath.GetDirectoryName ( pf );
+ Assert.Equal ( "/{0}/".With ( p ), result );
+ }
+
+
+ [Fact]
+ public void WhenPathRootedWithFileWithoutExtension_ShouldReturnDirectoryRootedPath ( ) {
+ var fixture = new Fixture ( );
+ var p = fixture.Create ( "path" );
+ var pf = "/{0}/file".With ( p );
+ string result = LinuxPath.GetDirectoryName ( pf );
+ Assert.Equal ( "/{0}/".With ( p ), result );
+ }
+
+ [Fact]
+ public void WhenPathRooted_ShouldReturnRootPath ( ) {
+ var fixture = new Fixture ( );
+ var p = "/{0}/".With ( fixture.Create ( "path" ) );
+ string result = LinuxPath.GetDirectoryName ( p );
+ Assert.Equal ( p, result );
+ }
+
+ [Fact]
+ public void WhenPathIsLevels_ShouldReturnRootPath ( ) {
+ var fixture = new Fixture ( );
+ var pname = fixture.Create ( "path" );
+ var p = "/some/path/deep/{0}/".With ( pname );
+ string result = LinuxPath.GetDirectoryName ( p );
+ Assert.Equal ( "{0}".With ( p ), result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetExtension.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetExtension.cs
new file mode 100644
index 0000000..6326437
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetExtension.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetExtension {
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull () {
+ Assert.Null ( LinuxPath.GetExtension ( null ) );
+ }
+
+ [Fact]
+ public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException () {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.GetExtension ( "/some/path/{0}-{1}.ext".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "file-" ) ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+ }
+
+ [Fact]
+ public void WhenFilePathContainsExtension_ShouldReturnExtension () {
+ var fixture = new Fixture ( );
+ string result = LinuxPath.GetExtension ( "/some/path/{0}.ext".With (fixture.Create ( "file-" ) ) );
+ Assert.Equal ( ".ext", result );
+ }
+
+ [Fact]
+ public void WhenFilePathDoesNotContainsExtension_ShouldReturnEmpty ( ) {
+ var fixture = new Fixture ( );
+ string result = LinuxPath.GetExtension ( "/some/path/{0}".With ( fixture.Create ( "file-" ) ) );
+ Assert.Equal ( string.Empty, result );
+ }
+
+ [Fact]
+ public void WhenFilePathEndsWithDot_ShouldReturnEmpty ( ) {
+ var fixture = new Fixture ( );
+ string result = LinuxPath.GetExtension ( "/some/path/{0}.".With ( fixture.Create ( "file-" ) ) );
+ Assert.Equal ( string.Empty, result );
+ }
+
+ [Fact]
+ public void WhenPathDoesNotFile_ShouldReturnEmpty ( ) {
+ var fixture = new Fixture ( );
+ string result = LinuxPath.GetExtension ( "/some/path/{0}/".With ( fixture.Create ( "path-" ) ) );
+ Assert.Equal ( string.Empty, result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetFileName.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetFileName.cs
new file mode 100644
index 0000000..f2824d1
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetFileName.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetFileName {
+
+ [Fact]
+ public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.GetFileName ( "/some/path/{0}-{1}.ext".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "file-" ) ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+ }
+
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull ( ) {
+ var fixture = new Fixture ( );
+ var result = LinuxPath.GetFileName ( null );
+ Assert.Null ( result );
+ }
+
+ [Fact]
+ public void WhenPathIsDirectory_ShouldReturnEmpty ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = "{0}/".With ( fixture.Create ( "path2-" ) );
+ var p = LinuxPath.Combine ( p1, p2 );
+ var result = LinuxPath.GetFileName ( p );
+ Assert.Equal ( string.Empty, result );
+ }
+
+ [Fact]
+ public void WhenPathIsFileWithExtension_ShouldReturnFileWithExtension ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = "{0}/".With ( fixture.Create ( "path2-" ) );
+ var f = "{0}{1}".With ( fixture.Create ( "file-" ), ".ext1" );
+ var p = LinuxPath.Combine ( p1, p2, f );
+ var result = LinuxPath.GetFileName ( p );
+ Assert.Equal ( f, result );
+ }
+
+ [Fact]
+ public void WhenPathIsFileWithoutExtension_ShouldReturnFileWithoutExtension ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = "{0}/".With ( fixture.Create ( "path2-" ) );
+ var f = "{0}".With ( fixture.Create ( "file-" ) );
+ var p = LinuxPath.Combine ( p1, p2, f );
+ var result = LinuxPath.GetFileName ( p );
+ Assert.Equal ( f, result );
+ }
+ }
+}
+
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetFileNameWithoutExtension.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetFileNameWithoutExtension.cs
new file mode 100644
index 0000000..285796b
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetFileNameWithoutExtension.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetFileNameWithoutExtension {
+ [Fact]
+ public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.GetFileNameWithoutExtension ( "/some/path/{0}-{1}.ext".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "file-" ) ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+ }
+
+
+
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull ( ) {
+ var fixture = new Fixture ( );
+ var result = LinuxPath.GetFileNameWithoutExtension ( null );
+ Assert.Null ( result );
+ }
+
+ [Fact]
+ public void WhenPathIsDirectory_ShouldReturnEmpty ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = "{0}/".With ( fixture.Create ( "path2-" ) );
+ var p = LinuxPath.Combine ( p1, p2 );
+ var result = LinuxPath.GetFileNameWithoutExtension ( p );
+ Assert.Equal ( string.Empty, result );
+ }
+
+ [Fact]
+ public void WhenPathHasFileWithExtension_ShouldReturnFileWithoutExtension ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = "{0}/".With ( fixture.Create ( "path2-" ) );
+ var f = fixture.Create ( "file-" );
+ var fext = "{0}{1}".With ( f, ".ext1" );
+ var p = LinuxPath.Combine ( p1, p2, fext );
+ var result = LinuxPath.GetFileNameWithoutExtension ( p );
+ Assert.Equal ( f, result );
+ }
+
+ [Fact]
+ public void WhenPathHasFileWithoutExtension_ShouldReturnFileWithoutExtension ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "/path1-" );
+ var p2 = "{0}/".With ( fixture.Create ( "path2-" ) );
+ var f = "{0}".With ( fixture.Create ( "file-" ) );
+ var p = LinuxPath.Combine ( p1, p2, f );
+ var result = LinuxPath.GetFileNameWithoutExtension ( p );
+ Assert.Equal ( f, result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetInvalidFileNameChars.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetInvalidFileNameChars.cs
new file mode 100644
index 0000000..34b0d6e
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetInvalidFileNameChars.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Managed.Adb.IO;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetInvalidFileNameChars {
+ [Fact]
+ public void WhenGetttingInvalidFileNameChars_ShouldEqualExpected () {
+ var result = LinuxPath.GetInvalidFileNameChars ( );
+ Assert.Equal ( LinuxPathConsts.InvalidFileNameChars, result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetInvalidPathChars.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetInvalidPathChars.cs
new file mode 100644
index 0000000..3c16a24
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetInvalidPathChars.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Managed.Adb.IO;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetInvalidPathChars {
+ [Fact]
+ public void WhenGetttingInvalidPathChars_ShouldEqualExpected ( ) {
+ var result = LinuxPath.GetInvalidPathChars ( );
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars, result );
+ }
+
+
+
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetPathRoot.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetPathRoot.cs
new file mode 100644
index 0000000..f342b6a
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetPathRoot.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetPathRoot {
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull () {
+ var result = LinuxPath.GetPathRoot ( null );
+ Assert.Null ( result );
+ }
+
+ [Fact]
+ public void WhenPathEmpty_ShouldReturnRelativeCurrentPath ( ) {
+ var result = LinuxPath.GetPathRoot ( string.Empty );
+ Assert.Equal ( "./", result );
+ }
+
+ [Fact]
+ public void WhenPathIsRooted_ShouldReturnRootPath () {
+ var fixture = new Fixture ( );
+ var path = fixture.Create ( "/path-" );
+ var result = LinuxPath.GetPathRoot ( path );
+ Assert.Equal ( "/", result );
+ }
+
+ [Fact]
+ public void WhenPathIsRelative_ShouldReturnRelativeCurrentPath ( ) {
+ var fixture = new Fixture ( );
+ var path = fixture.Create ( "path-" );
+ var result = LinuxPath.GetPathRoot ( path );
+ Assert.Equal ( "./", result );
+ }
+
+ }
+
+
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/GetPathWithoutFile.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetPathWithoutFile.cs
new file mode 100644
index 0000000..51aa265
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/GetPathWithoutFile.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class GetPathWithoutFile {
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnNull() {
+ Assert.Null ( LinuxPath.GetPathWithoutFile ( null ) );
+ }
+
+ [Fact]
+ public void WhenPathContainsFile_ShouldReturnPath ( ) {
+ var fixture = new Fixture ( );
+ var p1 = fixture.Create ( "path1-" );
+ var p2 = fixture.Create ( "path2-" );
+ var f1 = fixture.Create ( "file-" );
+ var p = "/{0}/{1}/{2}".With ( p1, p2, f1 );
+ var result = LinuxPath.GetPathWithoutFile ( p );
+ Assert.Equal ( "/{0}/{1}/".With ( p1, p2 ), result );
+ }
+
+ [Fact]
+ public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException ( ) {
+ var fixture = new Fixture ( );
+ int errorCount = 0;
+ for ( var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x ) {
+ try {
+ string result = LinuxPath.GetPathWithoutFile ( "/{0}-{1}/".With ( LinuxPathConsts.InvalidPathChars[x], fixture.Create ( "path1" ) ) );
+ } catch ( ArgumentException ) {
+ errorCount++;
+ }
+ }
+
+ Assert.Equal ( LinuxPathConsts.InvalidPathChars.Length, errorCount );
+
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/HasExtension.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/HasExtension.cs
new file mode 100644
index 0000000..8bfd9c8
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/HasExtension.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class HasExtension {
+ [Fact]
+ public void WhenPathIsNull_ShouldReturnFalse () {
+ var result = LinuxPath.HasExtension ( null );
+ Assert.False ( result );
+ }
+
+ [Fact]
+ public void WhenPathIsEmpty_ShouldReturnFalse ( ) {
+ var result = LinuxPath.HasExtension ( string.Empty );
+ Assert.False ( result );
+ }
+
+ [Fact]
+ public void WhenPathDoesNotHaveFile_ShouldReturnFalse ( ) {
+ var fixture = new Fixture ( );
+ var path = "/path/to/file/";
+ var result = LinuxPath.HasExtension ( path );
+ Assert.False ( result );
+ }
+
+ [Fact]
+ public void WhenPathHasExtension_ShouldReturnTrue ( ) {
+ var fixture = new Fixture ( );
+ var file = fixture.Create ( "file-" );
+ var path = "/path/to/file/{0}.ext".With ( file );
+ var result = LinuxPath.HasExtension ( path );
+ Assert.True ( result );
+ }
+
+ [Fact]
+ public void WhenPathDoesNotHaveExtension_ShouldReturnFalse ( ) {
+ var fixture = new Fixture ( );
+ var file = fixture.Create ( "file-" );
+ var path = "/path/to/file/{0}".With ( file );
+ var result = LinuxPath.HasExtension ( path );
+ Assert.False ( result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/LinuxPathConsts.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/LinuxPathConsts.cs
new file mode 100644
index 0000000..55a074d
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/LinuxPathConsts.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ internal class LinuxPathConsts {
+ internal static readonly char[] InvalidPathChars = new char[] {
+ '"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
+ '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
+ '\x001c', '\x001d', '\x001e', '\x001f'
+ };
+
+ internal static readonly char[] InvalidFileNameChars = new char[] {
+ '"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
+ '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
+ '\x001c', '\x001d', '\x001e', '\x001f', '*', '?', '\\', '/'
+ };
+
+ }
+}
diff --git a/Managed.Adb.Tests/ForIO/ForLinuxPath/Quote.cs b/Managed.Adb.Tests/ForIO/ForLinuxPath/Quote.cs
new file mode 100644
index 0000000..f6263dd
--- /dev/null
+++ b/Managed.Adb.Tests/ForIO/ForLinuxPath/Quote.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Camalot.Common.Extensions;
+using Managed.Adb.IO;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForIOLinuxPath {
+ public class Quote {
+ [Fact]
+ public void WhenValueIsNull_ShouldReturnNull ( ) {
+ var result = LinuxPath.Quote ( null );
+ Assert.Null ( result );
+ }
+
+ [Fact]
+ public void WhenValueIsEmpty_ShouldReturnEmpty () {
+ var result = LinuxPath.Quote ( string.Empty );
+ Assert.Equal ( string.Empty, result );
+ }
+ [Fact]
+ public void WhenValueHasSpace_ShouldReturnQuotedValue() {
+ var fixture = new Fixture ( );
+
+ var val = fixture.Create ( "value " );
+ var result = LinuxPath.Quote ( val );
+ Assert.Equal ( "\"{0}\"".With ( val ), result );
+ }
+
+ [Fact]
+ public void WhenValueDoesNotHaveSpace_ShouldReturnValue ( ) {
+ var fixture = new Fixture ( );
+
+ var val = fixture.Create ( "value-" );
+ var result = LinuxPath.Quote ( val );
+ Assert.Equal ( val , result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForManagedAdbExtenstions/Swap32bitFromArray.cs b/Managed.Adb.Tests/ForManagedAdbExtenstions/Swap32bitFromArray.cs
new file mode 100644
index 0000000..e4f545a
--- /dev/null
+++ b/Managed.Adb.Tests/ForManagedAdbExtenstions/Swap32bitFromArray.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForManagedAdbExtenstions {
+ public class Swap32bitFromArray {
+ [Fact]
+ public void WhenValueIsPositive_ShouldReturnInteger ( ) {
+ var fixture = new Fixture ( );
+ var value = fixture.Create ( );
+ var offset = fixture.Create ( );
+ var dest = new byte[offset + 4];
+ Assert.True ( offset >= 0 );
+ ManagedAdbExtenstions.Swap32bitsToArray ( value, dest, offset );
+
+ var result = ManagedAdbExtenstions.Swap32bitFromArray ( dest, offset );
+ Assert.Equal ( value, result );
+ }
+
+
+ [Fact]
+ public void WhenValueIsZero_ShouldReturnInteger ( ) {
+ var fixture = new Fixture ( );
+ var value = 0;
+ var offset = fixture.Create ( );
+ var dest = new byte[offset + 4];
+ Assert.True ( offset >= 0 );
+ ManagedAdbExtenstions.Swap32bitsToArray ( value, dest, offset );
+
+ var result = ManagedAdbExtenstions.Swap32bitFromArray ( dest, offset );
+ Assert.Equal ( value, result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/ForManagedAdbExtenstions/Swap32bitsToArray.cs b/Managed.Adb.Tests/ForManagedAdbExtenstions/Swap32bitsToArray.cs
new file mode 100644
index 0000000..daa0745
--- /dev/null
+++ b/Managed.Adb.Tests/ForManagedAdbExtenstions/Swap32bitsToArray.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForManagedAdbExtenstions {
+ public class Swap32bitsToArray {
+ [Fact]
+ public void WhenValueIsPositive_ShouldReturnSwapped() {
+ var fixture = new Fixture ( );
+ var value = fixture.Create ( );
+ var offset = fixture.Create ( );
+ var dest = new byte[offset + 4];
+ Assert.True ( offset >= 0 );
+
+ ManagedAdbExtenstions.Swap32bitsToArray ( value, dest, offset );
+ Assert.True ( dest.Length == offset + 4 );
+ Assert.True ( dest[offset] == (byte)( value & 0x000000FF ) );
+ Assert.True ( dest[offset + 1] == (byte)( value & 0x0000FF00 ) >> 8 );
+ Assert.True ( dest[offset + 2] == (byte)( value & 0x00FF0000 ) >> 16 );
+ Assert.True ( dest[offset + 3] == (byte)( value & 0xFF000000 ) >> 24 );
+ }
+
+ [Fact]
+ public void WhenValueIsZero_ShouldReturnSwapped ( ) {
+ var fixture = new Fixture ( );
+ var value = 0;
+ var offset = fixture.Create ( );
+ var dest = new byte[offset + 4];
+ Assert.True ( offset >= 0 );
+
+ ManagedAdbExtenstions.Swap32bitsToArray ( value, dest, offset );
+ Assert.True ( dest.Length == offset + 4 );
+ Assert.True ( dest[offset] == (byte)( value & 0x000000FF ) );
+ Assert.True ( dest[offset + 1] == (byte)( value & 0x0000FF00 ) >> 8 );
+ Assert.True ( dest[offset + 2] == (byte)( value & 0x00FF0000 ) >> 16 );
+ Assert.True ( dest[offset + 3] == (byte)( value & 0xFF000000 ) >> 24 );
+ }
+
+ }
+}
diff --git a/Managed.Adb.Tests/ForManagedAdbExtenstions/SwapU16bitFromArray.cs b/Managed.Adb.Tests/ForManagedAdbExtenstions/SwapU16bitFromArray.cs
new file mode 100644
index 0000000..71e1c84
--- /dev/null
+++ b/Managed.Adb.Tests/ForManagedAdbExtenstions/SwapU16bitFromArray.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Ploeh.AutoFixture;
+using Xunit;
+
+namespace Managed.Adb.Tests.ForManagedAdbExtenstions {
+ public class SwapU16bitFromArray {
+ [Fact]
+ public void WhenValueIsPositive_ShouldReturnInteger ( ) {
+ var fixture = new Fixture ( );
+ var value = fixture.Create ( );
+ var offset = fixture.Create ( );
+ var dest = new byte[offset + 4];
+ Assert.True ( offset >= 0 );
+ ManagedAdbExtenstions.Swap32bitsToArray ( value, dest, offset );
+
+ var result = ManagedAdbExtenstions.SwapU16bitFromArray ( dest, offset );
+ Assert.Equal ( value, result );
+ }
+
+
+ [Fact]
+ public void WhenValueIsZero_ShouldReturnInteger ( ) {
+ var fixture = new Fixture ( );
+ var value = 0;
+ var offset = fixture.Create ( );
+ var dest = new byte[offset + 4];
+ Assert.True ( offset >= 0 );
+ ManagedAdbExtenstions.Swap32bitsToArray ( value, dest, offset );
+
+ var result = ManagedAdbExtenstions.SwapU16bitFromArray ( dest, offset );
+ Assert.Equal ( value, result );
+ }
+ }
+}
diff --git a/Managed.Adb.Tests/LinuxPathTests.cs b/Managed.Adb.Tests/LinuxPathTests.cs
deleted file mode 100644
index 55f7606..0000000
--- a/Managed.Adb.Tests/LinuxPathTests.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Managed.Adb.IO;
-using Xunit;
-
-namespace Managed.Adb.Tests {
- public class LinuxPathTests {
-
- [Fact]
- public void CombineTest ( ) {
- String result = LinuxPath.Combine ( "/system", "busybox" );
- Assert.Equal ( "/system/busybox", result );
-
- result = LinuxPath.Combine ( "/system/", "busybox" );
- Assert.Equal ( "/system/busybox", result );
-
- result = LinuxPath.Combine ( "/system/xbin", "busybox" );
- Assert.Equal ( "/system/xbin/busybox", result );
-
- result = LinuxPath.Combine ( "/system/xbin/", "busybox" );
- Assert.Equal ( "/system/xbin/busybox", result );
-
- result = LinuxPath.Combine ( "/system//xbin", "busybox" );
- Assert.Equal ( "/system/xbin/busybox", result );
-
- result = LinuxPath.Combine ( "/system","xbin", "busybox" );
- Assert.Equal ( "/system/xbin/busybox", result );
-
- result = LinuxPath.Combine ( "/system", "xbin", "really", "long", "path" ,"to", "nothing" );
- Assert.Equal ( "/system/xbin/really/long/path/to/nothing", result );
- }
-
- [Fact]
- public void GetDirectoryNameTest ( ) {
- String result = LinuxPath.GetDirectoryName ( "/system/busybox" );
- Assert.Equal ( "/system/", result );
-
- result = LinuxPath.GetDirectoryName ( "/" );
- Assert.Equal ( "/", result );
-
- result = LinuxPath.GetDirectoryName ( "/system/xbin/" );
- Assert.Equal ( "/system/xbin/", result );
- }
-
- [Fact]
- public void GetFileNameTest ( ) {
- String result = LinuxPath.GetFileName ( "/system/busybox" );
- Assert.Equal ( "busybox", result );
-
- result = LinuxPath.GetFileName ( "/" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetFileName ( "/system/xbin/" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetFileName ( "/system/xbin/file.ext" );
- Assert.Equal ( "file.ext", result );
- }
-
-
- [Fact]
- public void GetFileNameExtensionTest ( ) {
- String result = LinuxPath.GetExtension ( "/system/busybox" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetExtension ( "/" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetExtension ( "/system/xbin/" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetExtension ( "/system/xbin/file.ext" );
- Assert.Equal ( ".ext", result );
- }
-
- [Fact]
- public void GetFileNameWithoutExtensionTest ( ) {
- String result = LinuxPath.GetFileNameWithoutExtension ( "/system/busybox" );
- Assert.Equal ( "busybox", result );
-
- result = LinuxPath.GetFileNameWithoutExtension ( "/" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetFileNameWithoutExtension ( "/system/xbin/" );
- Assert.Equal ( "", result );
-
- result = LinuxPath.GetFileNameWithoutExtension ( "/system/xbin/file.ext" );
- Assert.Equal ( "file", result );
- }
-
- [Fact]
- public void ChangeExtensionTest ( ) {
- String result = LinuxPath.ChangeExtension ( "/system/busybox", "foo" );
- Assert.Equal ( "/system/busybox.foo", result );
-
- result = LinuxPath.ChangeExtension ( "/system/xbin/file.ext", "myext" );
- Assert.Equal ( "/system/xbin/file.myext", result );
-
- result = LinuxPath.ChangeExtension ( "/system/xbin/file.ext", "" );
- Assert.Equal ( "/system/xbin/file", result );
-
- result = LinuxPath.ChangeExtension ( "/system/busybox.foo", "" );
- Assert.Equal ( "/system/busybox", result );
- }
-
- [Fact]
- public void GetPathWithoutFileTest ( ) {
- String result = LinuxPath.GetPathWithoutFile ( "/system/busybox" );
- Assert.Equal ( "/system/", result );
-
- result = LinuxPath.GetPathWithoutFile ( "/system/xbin/" );
- Assert.Equal ( "/system/xbin/", result );
-
- result = LinuxPath.GetPathWithoutFile ( "/system/xbin/file.ext");
- Assert.Equal ( "/system/xbin/", result );
- }
-
- [Fact]
- public void GetPathRootTest ( ) {
- String result = LinuxPath.GetPathRoot ( "/system/busybox" );
- Assert.Equal ( "/", result );
-
- result = LinuxPath.GetPathRoot ( "/system/xbin/" );
- Assert.Equal ( "/", result );
-
- result = LinuxPath.GetPathRoot ( "/system/xbin/file.ext" );
- Assert.Equal ( "/", result );
- }
-
-
- [Fact]
- public void IsPathRootedTest ( ) {
- bool result = LinuxPath.IsPathRooted ( "/system/busybox" );
- Assert.Equal ( true, result );
-
- result = LinuxPath.IsPathRooted ( "/system/xbin/" );
- Assert.Equal ( true, result );
-
- result = LinuxPath.IsPathRooted ( "system/xbin/" );
- Assert.Equal ( false, result );
- }
-
- [Fact]
- public void HasExtensionTest ( ) {
- bool result = LinuxPath.HasExtension ( "/system/busybox" );
- Assert.Equal ( false, result );
-
- result = LinuxPath.HasExtension ( "/system/xbin.foo/" );
- Assert.Equal ( false, result );
-
- result = LinuxPath.HasExtension ( "system/xbin/file.ext" );
- Assert.Equal ( true, result );
- }
- }
-}
diff --git a/Managed.Adb.Tests/Managed.Adb.Tests.csproj b/Managed.Adb.Tests/Managed.Adb.Tests.csproj
index 6a75857..7cbb2be 100644
--- a/Managed.Adb.Tests/Managed.Adb.Tests.csproj
+++ b/Managed.Adb.Tests/Managed.Adb.Tests.csproj
@@ -1,133 +1,169 @@
+
+
Debug
- AnyCPU
- 8.0.30703
- 2.0
- {2C43B828-BE5E-47B6-93BB-A624B6B36633}
+ x86
+ {2E3DF5C2-8A38-4A03-86D7-8D463C917E47}
Library
Properties
Managed.Adb.Tests
Managed.Adb.Tests
v4.5.1
512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+ b0edf53b
- %24/madb/trunk/Managed.AndroidDebugBridge/Managed.Adb.Tests
- .
- https://tfs.codeplex.com/tfs/tfs02
- {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
- ..\
- true
-
-
true
+ TRACE;DEBUG;PLATFORMX86
full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\Release\
- TRACE
+ true
+ GlobalSuppressions.cs
prompt
- 4
- false
+ false
+ AllRules.ruleset
+ true
+ bin\$(Platform)\$(Configuration)\
- true
bin\x64\Debug\
- DEBUG;TRACE
- full
+ TRACE;DEBUG;PLATFORMX64
x64
- prompt
- true
- true
- false
bin\x64\Release\
- TRACE
- true
- pdbonly
- AnyCPU
- prompt
- true
- true
- false
+ TRACE;PLATFORMX64
+ x64
+
+
+ bin\x86\Debug\
+ TRACE;DEBUG;PLATFORMX86
+ x86
+
+
+ bin\x86\Release\
+ TRACE;PLATFORMX86
+ x86
..\packages\Camalot.Common.1.0.5937.17275\lib\net45\Camalot.Common.dll
True
-
- ..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll
+
+ ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll
+ True
+
+
+ ..\packages\morelinq.1.0\lib\net35\MoreLinq.dll
+ True
+
+
+ ..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+ ..\packages\AutoFixture.3.43.0\lib\net40\Ploeh.AutoFixture.dll
+ True
-
- ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\AutoFixture.Xunit2.3.43.0\lib\net45\Ploeh.AutoFixture.Xunit2.dll
True
-
-
-
-
-
-
- ..\3rdParty\xunit\xunit.dll
+
+ ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll
+ True
+
+
+ ..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll
+ True
+
+
+ ..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll
+ True
+
+
+
+
+
+
+
+
-
- Properties\SharedAssemblyInfo.cs
-
-
- Properties\AssemblyVersionInfo.cs
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
- {65473257-E70F-410B-9269-D0C0F771EA87}
+ {65473257-e70f-410b-9269-d0c0f771ea87}
Managed.Adb
-
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
-
This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
+
- " + Client.ClientData/*.Pid*/
diff --git a/Managed.AndroidDebugBridge/Device.cs b/Managed.AndroidDebugBridge/Device.cs
index 4c846fe..ffaf6c6 100644
--- a/Managed.AndroidDebugBridge/Device.cs
+++ b/Managed.AndroidDebugBridge/Device.cs
@@ -47,8 +47,17 @@ public enum DeviceState {
///
///
public sealed class Device : IDevice {
+ ///
+ /// The mnt external storage
+ ///
public const String MNT_EXTERNAL_STORAGE = "EXTERNAL_STORAGE";
+ ///
+ /// mnt data
+ ///
public const String MNT_DATA = "ANDROID_DATA";
+ ///
+ /// The mnt root
+ ///
public const String MNT_ROOT = "ANDROID_ROOT";
///
@@ -95,7 +104,7 @@ public sealed class Device : IDevice {
public const String FIRST_EMULATOR_SN = "emulator-5554";
/** @deprecated Use {@link #PROP_BUILD_API_LEVEL}. */
- [Obsolete("Use PROP_BUILD_API_LEVEL")]
+ [Obsolete ( "Use PROP_BUILD_API_LEVEL" )]
public const String PROP_BUILD_VERSION_NUMBER = PROP_BUILD_API_LEVEL;
///
@@ -116,11 +125,10 @@ public sealed class Device : IDevice {
private const int BATTERY_TIMEOUT = 2 * 1000; //2 seconds
private const int GETPROP_TIMEOUT = 2 * 1000; //2 seconds
private const int INSTALL_TIMEOUT = 2 * 60 * 1000; // 2 minutes
- ///
- ///
- ///
+ ///
+ ///
+ ///
private string _avdName;
- private IPEndPoint _endpoint;
private bool _canSU = false;
private BatteryInfo _lastBatteryInfo = null;
private DateTime _lastBatteryCheckTime = DateTime.MinValue;
@@ -133,30 +141,30 @@ public sealed class Device : IDevice {
/// The model.
/// The product.
/// The device.
- public Device(string serial, DeviceState state, string model, string product, string device) {
+ public Device ( string serial, DeviceState state, string model, string product, string device ) {
this.SerialNumber = serial;
this.State = state;
- MountPoints = new Dictionary();
- Properties = new Dictionary();
- EnvironmentVariables = new Dictionary();
- Clients = new List();
- FileSystem = new FileSystem(this);
- BusyBox = new BusyBox(this);
+ MountPoints = new Dictionary ( );
+ Properties = new Dictionary ( );
+ EnvironmentVariables = new Dictionary ( );
+ Clients = new List ( );
+ FileSystem = new FileSystem ( this );
+ BusyBox = new BusyBox ( this );
Model = model;
Product = product;
DeviceProperty = device;
- RetrieveDeviceInfo();
+ RetrieveDeviceInfo ( );
}
///
/// Retrieves the device info.
///
- private void RetrieveDeviceInfo() {
- RefreshMountPoints();
- RefreshEnvironmentVariables();
- RefreshProperties();
+ private void RetrieveDeviceInfo ( ) {
+ RefreshMountPoints ( );
+ RefreshEnvironmentVariables ( );
+ RefreshProperties ( );
}
///
@@ -164,19 +172,19 @@ private void RetrieveDeviceInfo() {
///
/// The device state string
///
- private static DeviceState GetStateFromString(String state) {
+ private static DeviceState GetStateFromString ( String state ) {
String tstate = state;
- if(String.Compare(state, "device", false) == 0) {
+ if ( String.Compare ( state, "device", false ) == 0 ) {
tstate = "online";
}
- if(Enum.IsDefined(typeof(DeviceState), tstate)) {
- return (DeviceState)Enum.Parse(typeof(DeviceState), tstate, true);
+ if ( Enum.IsDefined ( typeof ( DeviceState ), tstate ) ) {
+ return (DeviceState)Enum.Parse ( typeof ( DeviceState ), tstate, true );
} else {
- foreach(var fi in typeof(DeviceState).GetFields()) {
- if(string.Compare(fi.Name, tstate, true) == 0) {
- return (DeviceState)fi.GetValue(null);
+ foreach ( var fi in typeof ( DeviceState ).GetFields ( ) ) {
+ if ( string.Compare ( fi.Name, tstate, true ) == 0 ) {
+ return (DeviceState)fi.GetValue ( null );
}
}
}
@@ -190,16 +198,16 @@ private static DeviceState GetStateFromString(String state) {
///
/// the line data for the device
///
- public static Device CreateFromAdbData(String data) {
- Regex re = new Regex(RE_DEVICELIST_INFO, RegexOptions.Compiled | RegexOptions.IgnoreCase);
- Match m = re.Match(data);
- if(m.Success) {
+ public static Device CreateFromAdbData ( String data ) {
+ Regex re = new Regex ( RE_DEVICELIST_INFO, RegexOptions.Compiled | RegexOptions.IgnoreCase );
+ Match m = re.Match ( data );
+ if ( m.Success ) {
if ( m.Groups[2].Value != "host" ) {
return new Device ( m.Groups[1].Value, GetStateFromString ( m.Groups[2].Value ), m.Groups[4].Value, m.Groups[3].Value, m.Groups[5].Value );
}
return null;
} else {
- throw new ArgumentException("Invalid device list data");
+ throw new ArgumentException ( "Invalid device list data" );
}
}
@@ -209,25 +217,26 @@ public static Device CreateFromAdbData(String data) {
///
/// true if this device can perform a backup; otherwise, false.
///
- public bool CanBackup() {
- return this.FileSystem.Exists("/system/bin/bu");
+ public bool CanBackup ( ) {
+ return this.FileSystem.Exists ( "/system/bin/bu" );
}
///
/// Backups this device.
///
- public void Backup() {
- AdbHelper.Instance.Backup(AndroidDebugBridge.SocketAddress);
+#pragma warning disable 618
+ public void Backup ( ) {
+ AdbHelper.Instance.Backup ( AndroidDebugBridge.SocketAddress );
}
-
+#pragma warning restore
///
/// Determines whether this instance can use the SU shell.
///
///
/// true if this instance can use the SU shell; otherwise, false.
///
- public bool CanSU() {
- if(_canSU) {
+ public bool CanSU ( ) {
+ if ( _canSU ) {
return _canSU;
}
@@ -236,11 +245,11 @@ public bool CanSU() {
// this now checks if permission was denied and accounts for that.
// The nulloutput receiver is fine here because it doesn't need to send the output anywhere,
// the execute command can still handle the output with the null output receiver.
- this.ExecuteRootShellCommand("echo \\\"I can haz root\\\"", NullOutputReceiver.Instance);
+ this.ExecuteRootShellCommand ( "echo \\\"I can haz root\\\"", NullOutputReceiver.Instance );
_canSU = true;
- } catch(PermissionDeniedException) {
+ } catch ( PermissionDeniedException ) {
_canSU = false;
- } catch(FileNotFoundException) {
+ } catch ( FileNotFoundException ) {
_canSU = false;
}
@@ -268,6 +277,12 @@ public bool CanSU() {
///
public IPEndPoint Endpoint { get; private set; }
+ ///
+ /// Gets the type of the transport used to connect to this device.
+ ///
+ ///
+ /// The type of the transport.
+ ///
public TransportType TransportType { get; private set; }
@@ -277,8 +292,8 @@ public bool CanSU() {
public String AvdName {
get { return _avdName; }
set {
- if(!IsEmulator) {
- throw new ArgumentException("Cannot set the AVD name of the device is not an emulator");
+ if ( !IsEmulator ) {
+ throw new ArgumentException ( "Cannot set the AVD name of the device is not an emulator" );
}
_avdName = value;
}
@@ -337,8 +352,8 @@ public String AvdName {
///
/// the value or null
if the property does not exist.
///
- public String GetProperty(String name) {
- return GetProperty(new String[] { name });
+ public String GetProperty ( String name ) {
+ return GetProperty ( new String[] { name } );
}
///
@@ -346,9 +361,9 @@ public String GetProperty(String name) {
///
/// The array of property names.
///
- public String GetProperty(params String[] name) {
- foreach(var item in name) {
- if(Properties.ContainsKey(item)) {
+ public String GetProperty ( params String[] name ) {
+ foreach ( var item in name ) {
+ if ( Properties.ContainsKey ( item ) ) {
return Properties[item];
}
}
@@ -382,7 +397,7 @@ public bool IsOnline {
/// true if this device is emulator; otherwise, false.
public bool IsEmulator {
get {
- return Regex.Match(SerialNumber, RE_EMULATOR_SN).Success;
+ return Regex.Match ( SerialNumber, RE_EMULATOR_SN ).Success;
}
}
@@ -423,10 +438,10 @@ public bool IsRecovery {
///
/// The mount point.
/// if set to true the mount poine will be set to read-only.
- public void RemountMountPoint(MountPoint mnt, bool readOnly) {
- String command = String.Format("mount -o {0},remount -t {1} {2} {3}", readOnly ? "ro" : "rw", mnt.FileSystem, mnt.Block, mnt.Name);
- this.ExecuteShellCommand(command, NullOutputReceiver.Instance);
- RefreshMountPoints();
+ public void RemountMountPoint ( MountPoint mnt, bool readOnly ) {
+ String command = String.Format ( "mount -o {0},remount -t {1} {2} {3}", readOnly ? "ro" : "rw", mnt.FileSystem, mnt.Block, mnt.Name );
+ this.ExecuteShellCommand ( command, NullOutputReceiver.Instance );
+ RefreshMountPoints ( );
}
///
@@ -435,12 +450,12 @@ public void RemountMountPoint(MountPoint mnt, bool readOnly) {
/// the mount point
/// if set to true the mount poine will be set to read-only.
/// Throws if the mount point does not exist.
- public void RemountMountPoint(String mountPoint, bool readOnly) {
- if(MountPoints.ContainsKey(mountPoint)) {
+ public void RemountMountPoint ( String mountPoint, bool readOnly ) {
+ if ( MountPoints.ContainsKey ( mountPoint ) ) {
MountPoint mnt = MountPoints[mountPoint];
- RemountMountPoint(mnt, readOnly);
+ RemountMountPoint ( mnt, readOnly );
} else {
- throw new IOException("Invalid mount point");
+ throw new IOException ( "Invalid mount point" );
}
}
@@ -448,11 +463,11 @@ public void RemountMountPoint(String mountPoint, bool readOnly) {
///
/// Refreshes the mount points.
///
- public void RefreshMountPoints() {
- if(!IsOffline) {
+ public void RefreshMountPoints ( ) {
+ if ( !IsOffline ) {
try {
- this.ExecuteShellCommand(MountPointReceiver.MOUNT_COMMAND, new MountPointReceiver(this));
- } catch(AdbException) {
+ this.ExecuteShellCommand ( MountPointReceiver.MOUNT_COMMAND, new MountPointReceiver ( this ) );
+ } catch ( AdbException ) {
}
}
@@ -461,11 +476,11 @@ public void RefreshMountPoints() {
///
/// Refreshes the environment variables.
///
- public void RefreshEnvironmentVariables() {
- if(!IsOffline) {
+ public void RefreshEnvironmentVariables ( ) {
+ if ( !IsOffline ) {
try {
- this.ExecuteShellCommand(EnvironmentVariablesReceiver.ENV_COMMAND, new EnvironmentVariablesReceiver(this));
- } catch(AdbException) {
+ this.ExecuteShellCommand ( EnvironmentVariablesReceiver.ENV_COMMAND, new EnvironmentVariablesReceiver ( this ) );
+ } catch ( AdbException ) {
}
}
@@ -474,12 +489,12 @@ public void RefreshEnvironmentVariables() {
///
/// Refreshes the properties.
///
- public void RefreshProperties() {
- if(!IsOffline) {
+ public void RefreshProperties ( ) {
+ if ( !IsOffline ) {
try {
- this.ExecuteShellCommand(GetPropReceiver.GETPROP_COMMAND, new GetPropReceiver(this));
- } catch(AdbException aex) {
- Log.w(LOG_TAG, aex);
+ this.ExecuteShellCommand ( GetPropReceiver.GETPROP_COMMAND, new GetPropReceiver ( this ) );
+ } catch ( AdbException aex ) {
+ Log.w ( LOG_TAG, aex );
}
}
}
@@ -488,23 +503,23 @@ public void RefreshProperties() {
/// Reboots the device in to the specified state
///
/// The reboot state
- public void Reboot(String into) {
- AdbHelper.Instance.Reboot(into, AndroidDebugBridge.SocketAddress, this);
+ public void Reboot ( String into ) {
+ AdbHelper.Instance.Reboot ( into, AndroidDebugBridge.SocketAddress, this );
}
///
/// Reboots the device in to the specified state
///
- public void Reboot() {
- Reboot(String.Empty);
+ public void Reboot ( ) {
+ Reboot ( String.Empty );
}
///
/// Gets the battery level.
///
///
- public BatteryInfo GetBatteryInfo() {
- return GetBatteryInfo(5 * 60 * 1000);
+ public BatteryInfo GetBatteryInfo ( ) {
+ return GetBatteryInfo ( 5 * 60 * 1000 );
}
///
@@ -512,13 +527,13 @@ public BatteryInfo GetBatteryInfo() {
///
/// The freshness.
///
- public BatteryInfo GetBatteryInfo(long freshness) {
- if(_lastBatteryInfo != null
- && this._lastBatteryCheckTime > (DateTime.Now.AddMilliseconds(-freshness))) {
+ public BatteryInfo GetBatteryInfo ( long freshness ) {
+ if ( _lastBatteryInfo != null
+ && this._lastBatteryCheckTime > ( DateTime.Now.AddMilliseconds ( -freshness ) ) ) {
return _lastBatteryInfo;
}
- var receiver = new BatteryReceiver();
- ExecuteShellCommand("dumpsys battery", receiver, BATTERY_TIMEOUT);
+ var receiver = new BatteryReceiver ( );
+ ExecuteShellCommand ( "dumpsys battery", receiver, BATTERY_TIMEOUT );
_lastBatteryInfo = receiver.BatteryInfo;
_lastBatteryCheckTime = DateTime.Now;
return _lastBatteryInfo;
@@ -553,8 +568,8 @@ public bool HasClients {
/// Throws IOException if the connection with adb failed.
public SyncService SyncService {
get {
- SyncService syncService = new SyncService(AndroidDebugBridge.SocketAddress, this);
- if(syncService.Open()) {
+ SyncService syncService = new SyncService ( AndroidDebugBridge.SocketAddress, this );
+ if ( syncService.Open ( ) ) {
return syncService;
}
@@ -567,7 +582,7 @@ public SyncService SyncService {
///
public PackageManager PackageManager {
get {
- return new PackageManager(this);
+ return new PackageManager ( this );
}
}
@@ -577,7 +592,7 @@ public PackageManager PackageManager {
///
public FileListingService FileListingService {
get {
- return new FileListingService(this);
+ return new FileListingService ( this );
}
}
@@ -587,7 +602,7 @@ public FileListingService FileListingService {
/// The screenshot.
public RawImage Screenshot {
get {
- return AdbHelper.Instance.GetFrameBuffer(AndroidDebugBridge.SocketAddress, this);
+ return AdbHelper.Instance.GetFrameBuffer ( AndroidDebugBridge.SocketAddress, this );
}
}
@@ -596,8 +611,8 @@ public RawImage Screenshot {
///
/// The command to execute
/// The receiver object getting the result from the command.
- public void ExecuteShellCommand(String command, IShellOutputReceiver receiver) {
- ExecuteShellCommand(command, receiver, new object[] { });
+ public void ExecuteShellCommand ( String command, IShellOutputReceiver receiver ) {
+ ExecuteShellCommand ( command, receiver, new object[] { } );
}
///
@@ -606,8 +621,8 @@ public void ExecuteShellCommand(String command, IShellOutputReceiver receiver) {
/// The command.
/// The receiver.
/// The timeout.
- public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, int timeout) {
- ExecuteShellCommand(command, receiver, new object[] { });
+ public void ExecuteShellCommand ( String command, IShellOutputReceiver receiver, int timeout ) {
+ ExecuteShellCommand ( command, receiver, new object[] { } );
}
@@ -617,8 +632,8 @@ public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, i
/// The command.
/// The receiver.
/// The command args.
- public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs) {
- AdbHelper.Instance.ExecuteRemoteCommand(AndroidDebugBridge.SocketAddress, string.Format(command, commandArgs), this, receiver);
+ public void ExecuteShellCommand ( String command, IShellOutputReceiver receiver, params object[] commandArgs ) {
+ AdbHelper.Instance.ExecuteRemoteCommand ( AndroidDebugBridge.SocketAddress, string.Format ( command, commandArgs ), this, receiver );
}
///
@@ -628,8 +643,8 @@ public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, p
/// The receiver.
/// The timeout.
/// The command args.
- public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs) {
- AdbHelper.Instance.ExecuteRemoteCommand(AndroidDebugBridge.SocketAddress, string.Format(command, commandArgs), this, receiver);
+ public void ExecuteShellCommand ( String command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs ) {
+ AdbHelper.Instance.ExecuteRemoteCommand ( AndroidDebugBridge.SocketAddress, string.Format ( command, commandArgs ), this, receiver );
}
@@ -638,8 +653,9 @@ public void ExecuteShellCommand(String command, IShellOutputReceiver receiver, i
///
/// The command.
/// The receiver.
- public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, int timeout) {
- ExecuteRootShellCommand(command, receiver, timeout, new object[] { });
+ /// The timeout.
+ public void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver, int timeout ) {
+ ExecuteRootShellCommand ( command, receiver, timeout, new object[] { } );
}
///
@@ -647,8 +663,8 @@ public void ExecuteRootShellCommand(String command, IShellOutputReceiver receive
///
/// The command to execute
/// The receiver object getting the result from the command.
- public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver) {
- ExecuteRootShellCommand(command, receiver, int.MaxValue);
+ public void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver ) {
+ ExecuteRootShellCommand ( command, receiver, int.MaxValue );
}
///
@@ -657,8 +673,8 @@ public void ExecuteRootShellCommand(String command, IShellOutputReceiver receive
/// The command.
/// The receiver.
/// The command args.
- public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs) {
- ExecuteRootShellCommand(command, receiver, int.MaxValue, commandArgs);
+ public void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver, params object[] commandArgs ) {
+ ExecuteRootShellCommand ( command, receiver, int.MaxValue, commandArgs );
}
///
@@ -668,8 +684,8 @@ public void ExecuteRootShellCommand(String command, IShellOutputReceiver receive
/// The receiver.
/// The timeout.
/// The command args.
- public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs) {
- AdbHelper.Instance.ExecuteRemoteRootCommand(AndroidDebugBridge.SocketAddress, string.Format(command, commandArgs), this, receiver, timeout);
+ public void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver, int timeout, params object[] commandArgs ) {
+ AdbHelper.Instance.ExecuteRemoteRootCommand ( AndroidDebugBridge.SocketAddress, string.Format ( command, commandArgs ), this, receiver, timeout );
}
@@ -677,8 +693,8 @@ public void ExecuteRootShellCommand(String command, IShellOutputReceiver receive
/// Runs the event log service.
///
/// The receiver.
- public void RunEventLogService(LogReceiver receiver) {
- AdbHelper.Instance.RunEventLogService(AndroidDebugBridge.SocketAddress, this, receiver);
+ public void RunEventLogService ( LogReceiver receiver ) {
+ AdbHelper.Instance.RunEventLogService ( AndroidDebugBridge.SocketAddress, this, receiver );
}
///
@@ -686,8 +702,8 @@ public void RunEventLogService(LogReceiver receiver) {
///
/// The logname.
/// The receiver.
- public void RunLogService(String logname, LogReceiver receiver) {
- AdbHelper.Instance.RunLogService(AndroidDebugBridge.SocketAddress, this, logname, receiver);
+ public void RunLogService ( String logname, LogReceiver receiver ) {
+ AdbHelper.Instance.RunLogService ( AndroidDebugBridge.SocketAddress, this, logname, receiver );
}
///
@@ -696,26 +712,44 @@ public void RunLogService(String logname, LogReceiver receiver) {
/// the local port to forward
/// the remote port.
/// true
if success.
- public bool CreateForward(int localPort, int remotePort) {
+ public bool CreateForward ( int localPort, int remotePort ) {
try {
- return AdbHelper.Instance.CreateForward(AndroidDebugBridge.SocketAddress, this, localPort, remotePort);
- } catch(IOException e) {
- Log.w("ddms", e);
+ return AdbHelper.Instance.CreateForward ( AndroidDebugBridge.SocketAddress, this, localPort, remotePort );
+ } catch ( IOException e ) {
+ Log.w ( "ddms", e );
return false;
}
}
-
+
+
+ ///
+ /// Creates a reverse port forwarding between a local and a remote port.
+ ///
+ /// the remote port to forward
+ /// the local port.
+ /// true
if success.
+ public bool CreateReverseForward ( int remotePort, int localPort )
+ {
+ try {
+ return AdbHelper.Instance.CreateReverseForward(AndroidDebugBridge.SocketAddress, this, remotePort, localPort);
+ } catch(IOException e) {
+ Log.w("ddms", e);
+ return false;
+ }
+ }
+
///
/// Removes a port forwarding between a local and a remote port.
///
/// the local port to forward
- /// the remote port.
- /// true
if success.
- public bool RemoveForward(int localPort) {
+ ///
+ /// true
if success.
+ ///
+ public bool RemoveForward ( int localPort ) {
try {
- return AdbHelper.Instance.RemoveForward(AndroidDebugBridge.SocketAddress, this, localPort);
- } catch(IOException e) {
- Log.w("ddms", e);
+ return AdbHelper.Instance.RemoveForward ( AndroidDebugBridge.SocketAddress, this, localPort );
+ } catch ( IOException e ) {
+ Log.w ( "ddms", e );
return false;
}
}
@@ -789,10 +823,10 @@ void Update ( Client client, int changeMask ) {
///
/// the absolute file system path to file on local host to install
/// set to true
if re-install of app should be performed
- public void InstallPackage(String packageFilePath, bool reinstall) {
- String remoteFilePath = SyncPackageToDevice(packageFilePath);
- InstallRemotePackage(remoteFilePath, reinstall);
- RemoveRemotePackage(remoteFilePath);
+ public void InstallPackage ( String packageFilePath, bool reinstall ) {
+ String remoteFilePath = SyncPackageToDevice ( packageFilePath );
+ InstallRemotePackage ( remoteFilePath, reinstall );
+ RemoveRemotePackage ( remoteFilePath );
}
///
@@ -801,30 +835,30 @@ public void InstallPackage(String packageFilePath, bool reinstall) {
/// the absolute path to file on local host
/// destination path on device for file
/// if fatal error occurred when pushing file
- public String SyncPackageToDevice(String localFilePath) {
+ public String SyncPackageToDevice ( String localFilePath ) {
try {
- String packageFileName = Path.GetFileName(localFilePath);
+ String packageFileName = Path.GetFileName ( localFilePath );
// only root has access to /data/local/tmp/... not sure how adb does it then...
// workitem: 16823
// workitem: 19711
- String remoteFilePath = LinuxPath.Combine(TEMP_DIRECTORY_FOR_INSTALL, packageFileName);
- Log.d(packageFileName, String.Format("Uploading {0} onto device '{1}'", packageFileName, SerialNumber));
+ String remoteFilePath = LinuxPath.Combine ( TEMP_DIRECTORY_FOR_INSTALL, packageFileName );
+ Log.d ( packageFileName, String.Format ( "Uploading {0} onto device '{1}'", packageFileName, SerialNumber ) );
SyncService sync = SyncService;
- if(sync != null) {
- String message = String.Format("Uploading file onto device '{0}'", SerialNumber);
- Log.d(LOG_TAG, message);
- SyncResult result = sync.PushFile(localFilePath, remoteFilePath, SyncService.NullProgressMonitor);
+ if ( sync != null ) {
+ String message = String.Format ( "Uploading file onto device '{0}'", SerialNumber );
+ Log.d ( LOG_TAG, message );
+ SyncResult result = sync.PushFile ( localFilePath, remoteFilePath, SyncService.NullProgressMonitor );
- if(result.Code != ErrorCodeHelper.RESULT_OK) {
- throw new IOException(String.Format("Unable to upload file: {0}", result.Message));
+ if ( result.Code != ErrorCodeHelper.RESULT_OK ) {
+ throw new IOException ( String.Format ( "Unable to upload file: {0}", result.Message ) );
}
} else {
- throw new IOException("Unable to open sync connection!");
+ throw new IOException ( "Unable to open sync connection!" );
}
return remoteFilePath;
- } catch(IOException e) {
- Log.e(LOG_TAG, String.Format("Unable to open sync connection! reason: {0}", e.Message));
+ } catch ( IOException e ) {
+ Log.e ( LOG_TAG, String.Format ( "Unable to open sync connection! reason: {0}", e.Message ) );
throw;
}
}
@@ -834,14 +868,14 @@ public String SyncPackageToDevice(String localFilePath) {
///
/// absolute file path to package file on device
/// set to true
if re-install of app should be performed
- public void InstallRemotePackage(String remoteFilePath, bool reinstall) {
- InstallReceiver receiver = new InstallReceiver();
- FileEntry entry = FileListingService.FindFileEntry(remoteFilePath);
- String cmd = String.Format("pm install {1}{0}", entry.FullEscapedPath, reinstall ? "-r " : String.Empty);
- ExecuteShellCommand(cmd, receiver);
+ public void InstallRemotePackage ( String remoteFilePath, bool reinstall ) {
+ InstallReceiver receiver = new InstallReceiver ( );
+ FileEntry entry = FileListingService.FindFileEntry ( remoteFilePath );
+ String cmd = String.Format ( "pm install {1}{0}", entry.FullEscapedPath, reinstall ? "-r " : String.Empty );
+ ExecuteShellCommand ( cmd, receiver );
- if(!String.IsNullOrEmpty(receiver.ErrorMessage)) {
- throw new PackageInstallationException(receiver.ErrorMessage);
+ if ( !String.IsNullOrEmpty ( receiver.ErrorMessage ) ) {
+ throw new PackageInstallationException ( receiver.ErrorMessage );
}
}
@@ -851,12 +885,12 @@ public void InstallRemotePackage(String remoteFilePath, bool reinstall) {
///
/// path on device of file to remove
/// if file removal failed
- public void RemoveRemotePackage(String remoteFilePath) {
+ public void RemoveRemotePackage ( String remoteFilePath ) {
// now we delete the app we sync'ed
try {
- ExecuteShellCommand("rm " + remoteFilePath, NullOutputReceiver.Instance);
- } catch(IOException e) {
- Log.e(LOG_TAG, String.Format("Failed to delete temporary package: {0}", e.Message));
+ ExecuteShellCommand ( "rm " + remoteFilePath, NullOutputReceiver.Instance );
+ } catch ( IOException e ) {
+ Log.e ( LOG_TAG, String.Format ( "Failed to delete temporary package: {0}", e.Message ) );
throw e;
}
}
@@ -865,14 +899,13 @@ public void RemoveRemotePackage(String remoteFilePath) {
/// Uninstall an package from the device.
///
/// Name of the package.
+ ///
///
- ///
- ///
- public void UninstallPackage(String packageName) {
- InstallReceiver receiver = new InstallReceiver();
- ExecuteShellCommand(String.Format("pm uninstall {0}", packageName), receiver);
- if(!String.IsNullOrEmpty(receiver.ErrorMessage)) {
- throw new PackageInstallationException(receiver.ErrorMessage);
+ public void UninstallPackage ( String packageName ) {
+ InstallReceiver receiver = new InstallReceiver ( );
+ ExecuteShellCommand ( String.Format ( "pm uninstall {0}", packageName ), receiver );
+ if ( !String.IsNullOrEmpty ( receiver.ErrorMessage ) ) {
+ throw new PackageInstallationException ( receiver.ErrorMessage );
}
}
@@ -880,9 +913,9 @@ public void UninstallPackage(String packageName) {
/// Raises the event.
///
/// The instance containing the event data.
- internal void OnStateChanged(EventArgs e) {
- if(this.StateChanged != null) {
- this.StateChanged(this, e);
+ internal void OnStateChanged ( EventArgs e ) {
+ if ( this.StateChanged != null ) {
+ this.StateChanged ( this, e );
}
}
@@ -890,9 +923,9 @@ internal void OnStateChanged(EventArgs e) {
/// Raises the event.
///
/// The instance containing the event data.
- internal void OnBuildInfoChanged(EventArgs e) {
- if(this.BuildInfoChanged != null) {
- this.BuildInfoChanged(this, e);
+ internal void OnBuildInfoChanged ( EventArgs e ) {
+ if ( this.BuildInfoChanged != null ) {
+ this.BuildInfoChanged ( this, e );
}
}
@@ -900,9 +933,9 @@ internal void OnBuildInfoChanged(EventArgs e) {
/// Raises the event.
///
/// The instance containing the event data.
- internal void OnClientListChanged(EventArgs e) {
- if(this.ClientListChanged != null) {
- this.ClientListChanged(this, e);
+ internal void OnClientListChanged ( EventArgs e ) {
+ if ( this.ClientListChanged != null ) {
+ this.ClientListChanged ( this, e );
}
}
}
diff --git a/Managed.AndroidDebugBridge/DeviceEventArgs.cs b/Managed.AndroidDebugBridge/DeviceEventArgs.cs
index dab43d4..848b873 100644
--- a/Managed.AndroidDebugBridge/DeviceEventArgs.cs
+++ b/Managed.AndroidDebugBridge/DeviceEventArgs.cs
@@ -4,7 +4,11 @@
using System.Text;
namespace Managed.Adb {
- public class DeviceEventArgs : EventArgs {
+ ///
+ ///
+ ///
+ ///
+ public class DeviceEventArgs : EventArgs {
///
/// Initializes a new instance of the class.
diff --git a/Managed.AndroidDebugBridge/DeviceMonitor.cs b/Managed.AndroidDebugBridge/DeviceMonitor.cs
index a680cd6..d76a223 100644
--- a/Managed.AndroidDebugBridge/DeviceMonitor.cs
+++ b/Managed.AndroidDebugBridge/DeviceMonitor.cs
@@ -401,6 +401,10 @@ private void QueryNewDeviceForInfo( Device device ) {
}
}
+ ///
+ /// Queries the new device for environment variables.
+ ///
+ /// The device.
private void QueryNewDeviceForEnvironmentVariables( Device device ) {
try {
if ( device.State != DeviceState.Offline && device.State != DeviceState.Unknown ) {
@@ -411,6 +415,10 @@ private void QueryNewDeviceForEnvironmentVariables( Device device ) {
}
}
+ ///
+ /// Queries the new device for mounting point.
+ ///
+ /// The device.
private void QueryNewDeviceForMountingPoint( Device device ) {
try {
if ( device.State != DeviceState.Offline && device.State != DeviceState.Unknown ) {
@@ -421,6 +429,11 @@ private void QueryNewDeviceForMountingPoint( Device device ) {
}
}
+ ///
+ /// Starts the monitoring device.
+ ///
+ /// The device.
+ ///
private bool StartMonitoringDevice( Device device ) {
Socket socket = OpenAdbConnection ( );
@@ -451,7 +464,7 @@ private bool StartMonitoringDevice( Device device ) {
try {
// attempt to close the socket if needed.
socket.Close ( );
- } catch ( IOException e1 ) {
+ } catch ( IOException ) {
// we can ignore that one. It may already have been closed.
}
Log.d ( TAG, "Connection Failure when starting to monitor device '{0}' : {1}", device, e.Message );
@@ -461,6 +474,9 @@ private bool StartMonitoringDevice( Device device ) {
return false;
}
+ ///
+ /// Starts the device monitor thread.
+ ///
private void StartDeviceMonitorThread( ) {
//Selector = Selector.Open();
Thread t = new Thread ( new ThreadStart ( DeviceClientMonitorLoop ) );
@@ -468,6 +484,9 @@ private void StartDeviceMonitorThread( ) {
t.Start ( );
}
+ ///
+ /// Devices the client monitor loop.
+ ///
private void DeviceClientMonitorLoop( ) {
do {
try {
@@ -555,7 +574,7 @@ private void DeviceClientMonitorLoop( ) {
}
}
}*/
- } catch ( IOException e ) {
+ } catch ( IOException ) {
if ( !IsRunning ) {
}
@@ -724,7 +743,7 @@ private int ReadLength( Socket socket, byte[] buffer ) {
try {
int len = int.Parse ( msg, System.Globalization.NumberStyles.HexNumber );
return len;
- } catch ( FormatException nfe ) {
+ } catch ( FormatException ) {
// we'll throw an exception below.
}
}
@@ -739,7 +758,7 @@ private int ReadLength( Socket socket, byte[] buffer ) {
/// The socket.
/// The data.
///
- private String Read( Socket socket, byte[] data ) {
+ private string Read( Socket socket, byte[] data ) {
int count = -1;
int totalRead = 0;
diff --git a/Managed.AndroidDebugBridge/ErrorCodeHelper.cs b/Managed.AndroidDebugBridge/ErrorCodeHelper.cs
index 55ef5d1..5d3d029 100644
--- a/Managed.AndroidDebugBridge/ErrorCodeHelper.cs
+++ b/Managed.AndroidDebugBridge/ErrorCodeHelper.cs
@@ -4,6 +4,10 @@
using System.Text;
namespace Managed.Adb {
+ ///
+ ///
+ ///
+ /// true
public static class ErrorCodeHelper {
/** Result code for transfer success. */
public const int RESULT_OK = 0;
@@ -37,6 +41,11 @@ public static class ErrorCodeHelper {
public const int RESULT_BUFFER_OVERRUN = 14;
+ ///
+ /// Errors the code to string.
+ ///
+ /// The code.
+ ///
public static String ErrorCodeToString ( int code ) {
switch ( code ) {
case RESULT_OK:
diff --git a/Managed.AndroidDebugBridge/Exceptions/AdbCommandRejectedException.cs b/Managed.AndroidDebugBridge/Exceptions/AdbCommandRejectedException.cs
index d74f8f9..01dc914 100644
--- a/Managed.AndroidDebugBridge/Exceptions/AdbCommandRejectedException.cs
+++ b/Managed.AndroidDebugBridge/Exceptions/AdbCommandRejectedException.cs
@@ -9,17 +9,38 @@ namespace Managed.Adb.Exceptions {
/// Exception thrown when adb refuses a command.
///
public class AdbCommandRejectedException : AdbException {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message.
public AdbCommandRejectedException ( String message )
: base ( message ) {
IsDeviceOffline = message.Equals ( "device offline" );
WasErrorDuringDeviceSelection = false;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message.
+ /// if set to true [error during device selection].
public AdbCommandRejectedException ( String message, bool errorDuringDeviceSelection )
: base ( message ) {
WasErrorDuringDeviceSelection = errorDuringDeviceSelection;
IsDeviceOffline = message.Equals ( "device offline" );
}
+ ///
+ /// Gets a value indicating whether this instance is device offline.
+ ///
+ ///
+ /// true if this instance is device offline; otherwise, false.
+ ///
public bool IsDeviceOffline { get; private set; }
+ ///
+ /// Gets a value indicating whether [was error during device selection].
+ ///
+ ///
+ /// true if [was error during device selection]; otherwise, false.
+ ///
public bool WasErrorDuringDeviceSelection { get; private set; }
}
}
diff --git a/Managed.AndroidDebugBridge/Exceptions/PermissionDeniedException.cs b/Managed.AndroidDebugBridge/Exceptions/PermissionDeniedException.cs
index 94b521f..ddcf7a7 100644
--- a/Managed.AndroidDebugBridge/Exceptions/PermissionDeniedException.cs
+++ b/Managed.AndroidDebugBridge/Exceptions/PermissionDeniedException.cs
@@ -5,6 +5,10 @@
using System.Runtime.Serialization;
namespace Managed.Adb.Exceptions {
+ ///
+ ///
+ ///
+ ///
public class PermissionDeniedException : Exception {
///
diff --git a/Managed.AndroidDebugBridge/Exceptions/ShellCommandUnresponsiveException.cs b/Managed.AndroidDebugBridge/Exceptions/ShellCommandUnresponsiveException.cs
index 51e86f5..cd52e27 100644
--- a/Managed.AndroidDebugBridge/Exceptions/ShellCommandUnresponsiveException.cs
+++ b/Managed.AndroidDebugBridge/Exceptions/ShellCommandUnresponsiveException.cs
@@ -4,7 +4,14 @@
using System.Text;
namespace Managed.Adb.Exceptions {
+ ///
+ ///
+ ///
+ ///
public class ShellCommandUnresponsiveException : AdbException {
+ ///
+ /// Initializes a new instance of the class.
+ ///
public ShellCommandUnresponsiveException ( ) : base("The shell command has become unresponsive"){
}
diff --git a/Managed.AndroidDebugBridge/Extensions/IntegerHelper.cs b/Managed.AndroidDebugBridge/Extensions/IntegerHelper.cs
index 886b6d1..7b9183f 100644
--- a/Managed.AndroidDebugBridge/Extensions/IntegerHelper.cs
+++ b/Managed.AndroidDebugBridge/Extensions/IntegerHelper.cs
@@ -117,67 +117,6 @@ public static T ToEnum ( this sbyte value ){
return (T)Enum.ToObject ( typeof ( T ), value );
}
- /*// reverse byte order (16-bit)
- ///
- /// reverse byte order (16-bit)
- ///
- /// The value.
- ///
- public static UInt16 ReverseBytes ( this UInt16 value ) {
- return (UInt16)( ( value & 0xFFU ) << 8 | ( value & 0xFF00U ) >> 8 );
- }
-
- // reverse byte order (32-bit)
- ///
- /// reverse byte order (32-bit)
- ///
- /// The value.
- ///
- public static UInt32 ReverseBytes ( this UInt32 value ) {
- return ( value & 0x000000FFU ) << 24 | ( value & 0x0000FF00U ) << 8 |
- ( value & 0x00FF0000U ) >> 8 | ( value & 0xFF000000U ) >> 24;
- }
-
- ///
- /// reverse byte order (32-bit)
- ///
- /// The value.
- ///
- public static Int32 ReverseBytes ( this Int32 value ) {
- return BitConverter.ToInt32 ( ReverseByteArray ( BitConverter.GetBytes ( value ) ), 0 );
- }
-
- ///
- /// reverse byte order (16-bit)
- ///
- /// The value.
- ///
- public static Int16 ReverseBytes ( this Int16 value ) {
- return BitConverter.ToInt16 ( ReverseByteArray ( BitConverter.GetBytes ( value ) ), 0 );
- }
-
- ///
- /// reverse byte order (64-bit)
- ///
- /// The value.
- ///
- public static Int64 ReverseBytes ( this Int64 value ) {
- return BitConverter.ToInt16 ( ReverseByteArray ( BitConverter.GetBytes ( value ) ), 0 );
- }
-
- // reverse byte order (64-bit)
- ///
- /// reverse byte order (64-bit)
- ///
- /// The value.
- ///
- public static UInt64 ReverseBytes ( this UInt64 value ) {
- return ( value & 0x00000000000000FFUL ) << 56 | ( value & 0x000000000000FF00UL ) << 40 |
- ( value & 0x0000000000FF0000UL ) << 24 | ( value & 0x00000000FF000000UL ) << 8 |
- ( value & 0x000000FF00000000UL ) >> 8 | ( value & 0x0000FF0000000000UL ) >> 24 |
- ( value & 0x00FF000000000000UL ) >> 40 | ( value & 0xFF00000000000000UL ) >> 56;
- }*/
-
///
/// Reverses the byte array.
///
diff --git a/Managed.AndroidDebugBridge/Extensions/PathHelper.cs b/Managed.AndroidDebugBridge/Extensions/PathHelper.cs
deleted file mode 100644
index 04d1bad..0000000
--- a/Managed.AndroidDebugBridge/Extensions/PathHelper.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace Managed.Adb {
- /// true
- public static partial class ManagedAdbExtenstions {
-
- ///
- /// Combines the specified paths.
- ///
- /// This wraps the normal System.IO.Path.Combine to allow for an unlimited list of paths to combine
- /// The paths.
- ///
- public static String Combine ( params String[] paths ) {
- String lastPath = String.Empty;
-
- foreach ( var item in paths ) {
- lastPath = Path.Combine ( lastPath, item );
- }
-
- return lastPath;
- }
-
- }
-}
diff --git a/Managed.AndroidDebugBridge/Extensions/StringHelper.cs b/Managed.AndroidDebugBridge/Extensions/StringHelper.cs
index ad93dd8..770a000 100644
--- a/Managed.AndroidDebugBridge/Extensions/StringHelper.cs
+++ b/Managed.AndroidDebugBridge/Extensions/StringHelper.cs
@@ -8,15 +8,6 @@
namespace Managed.Adb {
/// true
public static partial class ManagedAdbExtenstions {
- ///
- /// To the argument safe quoted string.
- ///
- /// The s.
- ///
- public static string ToArgumentSafe ( this string s ) {
- return "{0}{1}{0}".With ( s.Contains ( " " ) ? "\"" : string.Empty, s );
- }
-
///
/// Gets the bytes from a string.
///
diff --git a/Managed.AndroidDebugBridge/Extensions/ThrowIf.cs b/Managed.AndroidDebugBridge/Extensions/ThrowIf.cs
index a1a67c5..048443c 100644
--- a/Managed.AndroidDebugBridge/Extensions/ThrowIf.cs
+++ b/Managed.AndroidDebugBridge/Extensions/ThrowIf.cs
@@ -19,18 +19,34 @@ internal static void ThrowIfNonPositive ( this int argument, Expression
+ /// Throws if null.
+ ///
+ ///
+ /// The argument.
+ /// The function.
public static void ThrowIfNull ( this T argument, Expression> func ) where T : class {
if ( argument == null ) {
ThrowException ( s => new ArgumentNullException ( s ), func );
}
}
+ ///
+ /// Throws if null or empty.
+ ///
+ /// The argument.
+ /// The function.
public static void ThrowIfNullOrEmpty ( this String argument, Expression> func ) {
if ( String.IsNullOrEmpty(argument) ) {
ThrowException ( s => new ArgumentNullException ( s ), func );
}
}
+ ///
+ /// Throws if null or white space.
+ ///
+ /// The argument.
+ /// The function.
public static void ThrowIfNullOrWhiteSpace ( this String argument, Expression> func ) {
if ( String.IsNullOrEmpty ( argument ) || String.IsNullOrEmpty(argument.Trim()) ) {
ThrowException ( s => new ArgumentNullException ( s ), func );
diff --git a/Managed.AndroidDebugBridge/FilePermission.cs b/Managed.AndroidDebugBridge/FilePermission.cs
index ab1c993..544477a 100644
--- a/Managed.AndroidDebugBridge/FilePermission.cs
+++ b/Managed.AndroidDebugBridge/FilePermission.cs
@@ -4,12 +4,23 @@
using System.Text;
namespace Managed.Adb {
+ ///
+ ///
+ ///
public class FilePermissions {
+ ///
+ /// Initializes a new instance of the class.
+ ///
public FilePermissions ( ) : this("---------") {
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The permissions.
+ ///
public FilePermissions ( String permissions ) {
if ( permissions.Length > 9 ) {
permissions = permissions.Substring ( 1,9 );
@@ -24,14 +35,38 @@ public FilePermissions ( String permissions ) {
Other = new FilePermission ( permissions.Substring ( 6, 3 ) );
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The user.
+ /// The group.
+ /// The other.
public FilePermissions ( FilePermission user, FilePermission group, FilePermission other ) {
User = user;
Group = group;
Other = other;
- }
+ }
+ ///
+ /// Gets or sets the user permission.
+ ///
+ ///
+ /// The user.
+ ///
public FilePermission User { get; set; }
+ ///
+ /// Gets or sets the group permission.
+ ///
+ ///
+ /// The group.
+ ///
public FilePermission Group { get; set; }
+ ///
+ /// Gets or sets the other permission.
+ ///
+ ///
+ /// The other.
+ ///
public FilePermission Other { get; set; }
@@ -129,7 +164,13 @@ public FilePermission ( string linuxPermissions ) {
///
public bool CanDelete { get; private set; }
- public String ToString ( ) {
+ ///
+ /// Returns a string that represents the current object.
+ ///
+ ///
+ /// A string that represents the current object.
+ ///
+ public override string ToString ( ) {
StringBuilder perm = new StringBuilder ( );
return perm.AppendFormat ( "{0}", CanRead ? "r" : "-" ).AppendFormat ( "{0}", CanWrite ? "w" : "-" ).AppendFormat ( "{0}", CanExecute ? CanDelete ? "x" : "t" : "-" ).ToString ( );
}
diff --git a/Managed.AndroidDebugBridge/FileSystem.cs b/Managed.AndroidDebugBridge/FileSystem.cs
index fdb73cb..68c59d1 100644
--- a/Managed.AndroidDebugBridge/FileSystem.cs
+++ b/Managed.AndroidDebugBridge/FileSystem.cs
@@ -8,6 +8,9 @@
using System.Text.RegularExpressions;
namespace Managed.Adb {
+ ///
+ ///
+ ///
public class FileSystem {
///
@@ -83,7 +86,7 @@ public bool Exists ( String path ) {
try {
FileEntry fe = Device.FileListingService.FindFileEntry ( path );
return fe != null;
- } catch ( FileNotFoundException e ) {
+ } catch ( FileNotFoundException ) {
return false;
}
} else {
@@ -259,12 +262,9 @@ public void Delete(String path) {
///
/// The file entry.
/// If the command fails.
+ /// If device is null or if path is null or empty.
+
public void Delete ( FileEntry fileEntry ) {
- ///
- /// If device is null
- /// or
- /// If path is null or empty.
- ///
Device.ThrowIfNull("Device");
fileEntry.ThrowIfNull ( "fileEntry" );
if ( fileEntry.Exists ) {
@@ -428,7 +428,7 @@ public String ResolveLink ( String path ) {
return ( string.IsNullOrWhiteSpace ( cresult.Result ) ) ? path : cresult.Result;
}
return cresult.Result;
- } catch ( Exception e ) {
+ } catch ( Exception ) {
// if the command doesn't exist then we just return the path.
}
return path;
diff --git a/Managed.AndroidDebugBridge/IClient.cs b/Managed.AndroidDebugBridge/IClient.cs
index 17223c0..22ed9c4 100644
--- a/Managed.AndroidDebugBridge/IClient.cs
+++ b/Managed.AndroidDebugBridge/IClient.cs
@@ -5,76 +5,312 @@
using System.Net.Sockets;
namespace Managed.Adb {
- [Flags]
+ ///
+ ///
+ ///
+ [Flags]
public enum ClientChangeState {
- Name = 0x0001,
- DebuggerStatus = 0x0002,
- Port = 0x0004,
- ThreadMode = 0x0008,
- ThreadData = 0x0010,
- HeapMode = 0x0020,
- HeapData = 0x0040,
- NativeHeapData = 0x0080,
- ThreadStackTrace = 0x0100,
- HeapAllocations = 0x0200,
- HeapAllocationStatus = 0x0400,
- MethodProfilingStatus = 0x0800,
- Info = Name | DebuggerStatus | Port,
+ ///
+ /// The name
+ ///
+ Name = 0x0001,
+ ///
+ /// The debugger status
+ ///
+ DebuggerStatus = 0x0002,
+ ///
+ /// The port
+ ///
+ Port = 0x0004,
+ ///
+ /// The thread mode
+ ///
+ ThreadMode = 0x0008,
+ ///
+ /// The thread data
+ ///
+ ThreadData = 0x0010,
+ ///
+ /// The heap mode
+ ///
+ HeapMode = 0x0020,
+ ///
+ /// The heap data
+ ///
+ HeapData = 0x0040,
+ ///
+ /// The native heap data
+ ///
+ NativeHeapData = 0x0080,
+ ///
+ /// The thread stack trace
+ ///
+ ThreadStackTrace = 0x0100,
+ ///
+ /// The heap allocations
+ ///
+ HeapAllocations = 0x0200,
+ ///
+ /// The heap allocation status
+ ///
+ HeapAllocationStatus = 0x0400,
+ ///
+ /// The method profiling status
+ ///
+ MethodProfilingStatus = 0x0800,
+ ///
+ /// The information
+ ///
+ Info = Name | DebuggerStatus | Port,
}
- public enum ClientConnectionState {
- Init = 1,
- NotJDWP = 2,
- AwaitShake = 10,
- NeedDDMPacket = 11,
- NotDDM = 12,
- Ready = 13,
- Error = 20,
- Disconnected = 21,
+ ///
+ ///
+ ///
+ public enum ClientConnectionState {
+ ///
+ /// The initialize
+ ///
+ Init = 1,
+ ///
+ /// The not JDWP
+ ///
+ NotJDWP = 2,
+ ///
+ /// The await shake
+ ///
+ AwaitShake = 10,
+ ///
+ /// The need DDM packet
+ ///
+ NeedDDMPacket = 11,
+ ///
+ /// The not DDM
+ ///
+ NotDDM = 12,
+ ///
+ /// The ready
+ ///
+ Ready = 13,
+ ///
+ /// The error
+ ///
+ Error = 20,
+ ///
+ /// The disconnected
+ ///
+ Disconnected = 21,
}
+ ///
+ ///
+ ///
+ ///
public interface IClient : IPacketConsumer {
+ ///
+ /// Gets the state of the connection.
+ ///
+ ///
+ /// The state of the connection.
+ ///
ClientConnectionState ConnectionState { get; }
+ ///
+ /// Gets the state of the change.
+ ///
+ ///
+ /// The state of the change.
+ ///
ClientChangeState ChangeState { get; }
+ ///
+ /// Gets or sets the channel.
+ ///
+ ///
+ /// The channel.
+ ///
Socket Channel { get; set; }
+ ///
+ /// Gets the device.
+ ///
+ ///
+ /// The device.
+ ///
IDevice Device { get; }
+ ///
+ /// Gets the device implementation.
+ ///
+ ///
+ /// The device implementation.
+ ///
Device DeviceImplementation { get; }
+ ///
+ /// Gets the debugger listen port.
+ ///
+ ///
+ /// The debugger listen port.
+ ///
int DebuggerListenPort { get; }
+ ///
+ /// Gets a value indicating whether this instance is DDM aware.
+ ///
+ ///
+ /// true if this instance is DDM aware; otherwise, false.
+ ///
bool IsDdmAware { get; }
+ ///
+ /// Gets a value indicating whether this instance is debugger attached.
+ ///
+ ///
+ /// true if this instance is debugger attached; otherwise, false.
+ ///
bool IsDebuggerAttached { get; }
+ ///
+ /// Gets the debugger.
+ ///
+ ///
+ /// The debugger.
+ ///
Debugger Debugger { get; }
+ ///
+ /// Gets the client data.
+ ///
+ ///
+ /// The client data.
+ ///
ClientData ClientData { get; }
+ ///
+ /// Gets or sets a value indicating whether this instance is thread update enabled.
+ ///
+ ///
+ /// true if this instance is thread update enabled; otherwise, false.
+ ///
bool IsThreadUpdateEnabled { get; set; }
+ ///
+ /// Gets or sets a value indicating whether this instance is heap update enabled.
+ ///
+ ///
+ /// true if this instance is heap update enabled; otherwise, false.
+ ///
bool IsHeapUpdateEnabled { get; set; }
+ ///
+ /// Gets or sets a value indicating whether this instance is selected client.
+ ///
+ ///
+ /// true if this instance is selected client; otherwise, false.
+ ///
bool IsSelectedClient { get; set; }
+ ///
+ /// Returns true if ... is valid.
+ ///
+ ///
+ /// true if this instance is valid; otherwise, false.
+ ///
bool IsValid { get; }
+ ///
+ /// Executes the garbage collector.
+ ///
void ExecuteGarbageCollector ( );
+ ///
+ /// Dumps the hprof.
+ ///
void DumpHprof ( );
+ ///
+ /// Toggles the method profiling.
+ ///
void ToggleMethodProfiling ( );
+ ///
+ /// Requests the method profiling status.
+ ///
void RequestMethodProfilingStatus ( );
+ ///
+ /// Requests the thread update.
+ ///
void RequestThreadUpdate ( );
+ ///
+ /// Requests the thread stack trace.
+ ///
+ /// The thread identifier.
void RequestThreadStackTrace ( int threadID );
+ ///
+ /// Requests the native heap information.
+ ///
+ ///
bool RequestNativeHeapInformation ( );
+ ///
+ /// Enables the allocation tracker.
+ ///
+ /// if set to true [enable].
void EnableAllocationTracker ( bool enable );
+ ///
+ /// Requests the allocation status.
+ ///
void RequestAllocationStatus ( );
+ ///
+ /// Requests the allocation details.
+ ///
void RequestAllocationDetails ( );
+ ///
+ /// Kills this instance.
+ ///
void Kill ( );
// TODO: Define Selector
+ ///
+ /// Registers the specified selector.
+ ///
+ /// The selector.
void Register ( /*Selector*/ Object selector );
+ ///
+ /// Listens for debugger.
+ ///
+ /// The listen port.
void ListenForDebugger ( int listenPort );
// TODO: JdwpPacket
+ ///
+ /// Sends the and consume.
+ ///
+ /// The packet.
+ /// The reply handler.
void SendAndConsume ( /*JdwpPacket*/ Object packet, ChunkHandler replyHandler );
+ ///
+ /// Adds the request identifier.
+ ///
+ /// The identifier.
+ /// The handler.
void AddRequestId ( int id, ChunkHandler handler );
+ ///
+ /// Removes the request identifier.
+ ///
+ /// The identifier.
void RemoveRequestId ( int id );
+ ///
+ /// Determines whether [is response to us] [the specified identifier].
+ ///
+ /// The identifier.
+ ///
ChunkHandler IsResponseToUs ( int id );
// TODO: JdwpPacket
+ ///
+ /// Packets the failed.
+ ///
+ /// The packet.
void PacketFailed ( /*JdwpPacket*/ Object packet );
+ ///
+ /// DDMs the seen.
+ ///
+ ///
bool DdmSeen ( );
+ ///
+ /// Closes the specified notify.
+ ///
+ /// if set to true [notify].
void Close ( bool notify );
+ ///
+ /// Updates the specified change mask.
+ ///
+ /// The change mask.
void Update ( ClientChangeMask changeMask );
}
}
diff --git a/Managed.AndroidDebugBridge/IDebugPortProvider.cs b/Managed.AndroidDebugBridge/IDebugPortProvider.cs
index a6d78f2..6cc1746 100644
--- a/Managed.AndroidDebugBridge/IDebugPortProvider.cs
+++ b/Managed.AndroidDebugBridge/IDebugPortProvider.cs
@@ -4,6 +4,9 @@
using System.Text;
namespace Managed.Adb {
+ ///
+ ///
+ ///
public interface IDebugPortProvider {
///
/// Returns a non-random debugger port for the specified application running on the specified Device.
diff --git a/Managed.AndroidDebugBridge/IDevice.cs b/Managed.AndroidDebugBridge/IDevice.cs
index eefb42f..d1e37a6 100644
--- a/Managed.AndroidDebugBridge/IDevice.cs
+++ b/Managed.AndroidDebugBridge/IDevice.cs
@@ -45,7 +45,7 @@ public interface IDevice {
/// Gets the serial number of the device.
///
/// The serial number.
- String SerialNumber { get; }
+ string SerialNumber { get; }
///
/// Gets the TCP endpoint defined when the transport is TCP.
///
@@ -73,19 +73,19 @@ public interface IDevice {
/// if there isn't any.
///
/// The name of the avd.
- String AvdName { get; set; }
+ string AvdName { get; set; }
///
/// Gets the environment variables.
///
/// The environment variables.
- Dictionary EnvironmentVariables { get; }
+ Dictionary EnvironmentVariables { get; }
///
/// Gets the mount points.
///
/// The mount points.
- Dictionary MountPoints { get; }
+ Dictionary MountPoints { get; }
///
/// Gets the state.
@@ -98,7 +98,7 @@ public interface IDevice {
/// Returns the device properties. It contains the whole output of 'getprop'
///
/// The properties.
- Dictionary Properties { get; }
+ Dictionary Properties { get; }
///
/// Gets the property value.
@@ -107,7 +107,7 @@ public interface IDevice {
///
/// the value or null
if the property does not exist.
///
- String GetProperty ( String name );
+ string GetProperty ( string name );
///
/// Gets the first property that exists in the array of property names.
///
@@ -115,7 +115,7 @@ public interface IDevice {
///
/// the value or null
if the property does not exist.
///
- String GetProperty ( params String[] name );
+ string GetProperty ( params string[] name );
///
/// Gets a value indicating whether the device is online.
@@ -149,7 +149,7 @@ public interface IDevice {
///
bool IsBootLoader { get; }
- /**
+ /*
* Returns whether the {@link Device} has {@link Client}s.
*/
//bool HasClients { get; }
@@ -159,7 +159,7 @@ public interface IDevice {
///
List Clients { get; }
- /**
+ /*
* Returns a {@link Client} by its application name.
* @param applicationName the name of the application
* @return the Client
object or null
if no match was found.
@@ -167,18 +167,24 @@ public interface IDevice {
//Client GetClient(String applicationName);
///
- /// Returns a object to push / pull files to and from the device.
+ /// Returns a object to push / pull files to and from the device.
///
+ ///
+ /// The synchronize service.
+ ///
+ /// Throws IOException if the connection with adb failed.
///
/// null
if the SyncService couldn't be created. This can happen if adb
/// refuse to open the connection because the {@link IDevice} is invalid (or got disconnected).
///
- /// Throws IOException if the connection with adb failed.
SyncService SyncService { get; }
///
- /// Returns a for this device.
+ /// Returns a for this device.
///
+ ///
+ /// The file listing service.
+ ///
FileListingService FileListingService { get; }
@@ -193,15 +199,14 @@ public interface IDevice {
///
/// The command to execute
/// The receiver object getting the result from the command.
- void ExecuteShellCommand ( String command, IShellOutputReceiver receiver );
+ void ExecuteShellCommand ( string command, IShellOutputReceiver receiver );
///
/// Executes a shell command on the device, and sends the result to a receiver.
///
- ///
/// The command to execute
/// The receiver object getting the result from the command.
/// The max time to output response.
- void ExecuteShellCommand ( String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse );
+ void ExecuteShellCommand ( string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse );
///
/// Executes a shell command on the device, and sends the result to a receiver.
@@ -209,7 +214,7 @@ public interface IDevice {
/// The command to execute
/// The receiver object getting the result from the command.
/// The command args.
- void ExecuteShellCommand ( String command, IShellOutputReceiver receiver, params object[] commandArgs );
+ void ExecuteShellCommand ( string command, IShellOutputReceiver receiver, params object[] commandArgs );
///
/// Executes a shell command on the device, and sends the result to a receiver.
@@ -218,7 +223,7 @@ public interface IDevice {
/// The receiver object getting the result from the command.
/// The max time to output response.
/// The command args.
- void ExecuteShellCommand ( String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse, params object[] commandArgs );
+ void ExecuteShellCommand ( string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse, params object[] commandArgs );
///
@@ -227,7 +232,7 @@ public interface IDevice {
/// The command to execute
/// The receiver object getting the result from the command.
/// The command args.
- void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver, params object[] commandArgs );
+ void ExecuteRootShellCommand ( string command, IShellOutputReceiver receiver, params object[] commandArgs );
///
/// Executes a shell command on the device as root, and sends the result to a receiver.
@@ -236,14 +241,14 @@ public interface IDevice {
/// The receiver object getting the result from the command.
/// The max time to output response.
/// The command args.
- void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse, params object[] commandArgs );
+ void ExecuteRootShellCommand ( string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse, params object[] commandArgs );
///
/// Executes a shell command on the device as root, and sends the result to a receiver.
///
/// The command to execute
/// The receiver object getting the result from the command.
- void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver );
+ void ExecuteRootShellCommand ( string command, IShellOutputReceiver receiver );
///
/// Executes a shell command on the device as root, and sends the result to a receiver.
@@ -251,15 +256,15 @@ public interface IDevice {
/// The command to execute
/// The receiver object getting the result from the command.
/// The max time to output response.
- void ExecuteRootShellCommand ( String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse );
- /**
+ void ExecuteRootShellCommand ( string command, IShellOutputReceiver receiver, int maxTimeToOutputResponse );
+ /*
* Runs the event log service and outputs the event log to the {@link LogReceiver}.
* @param receiver the receiver to receive the event log entries.
* @throws IOException
*/
//void RunEventLogService(LogReceiver receiver);
- /**
+ /*
* Runs the log service for the given log and outputs the log to the {@link LogReceiver}.
* @param logname the logname of the log to read from.
* @param receiver the receiver to receive the event log entries.
@@ -275,6 +280,14 @@ public interface IDevice {
/// true
if success.
bool CreateForward(int localPort, int remotePort);
+ ///
+ /// Creates a reverse port forwarding between a local and a remote port.
+ ///
+ /// the remote port to forward
+ /// the local port.
+ /// true
if success.
+ bool CreateReverseForward ( int remotePort, int localPort );
+
///
/// Removes a port forwarding between a local and a remote port.
///
@@ -282,7 +295,7 @@ public interface IDevice {
/// true
if success.
bool RemoveForward ( int localPort );
- /**
+ /*
* Returns the name of the client by pid or null
if pid is unknown
* @param pid the pid of the client.
*/
@@ -295,38 +308,40 @@ public interface IDevice {
///
/// the absolute file system path to file on local host to install
/// set to true
if re-install of app should be performed
- void InstallPackage ( String packageFilePath, bool reinstall );
+ void InstallPackage ( string packageFilePath, bool reinstall );
///
/// Pushes a file to device
///
/// the absolute path to file on local host
- /// destination path on device for file
- /// if fatal error occurred when pushing file
- String SyncPackageToDevice ( String localFilePath );
+ ///
+ /// destination path on device for file
+ ///
+ /// if fatal error occurred when pushing file
+ string SyncPackageToDevice ( string localFilePath );
///
/// Installs the application package that was pushed to a temporary location on the device.
///
/// absolute file path to package file on device
/// set to true
if re-install of app should be performed
- void InstallRemotePackage(String remoteFilePath, bool reinstall);
+ void InstallRemotePackage( string remoteFilePath, bool reinstall);
///
/// Remove a file from device
///
/// path on device of file to remove
- /// if file removal failed
- void RemoveRemotePackage(String remoteFilePath);
+ /// if file removal failed
+ void RemoveRemotePackage(string remoteFilePath);
///
/// Uninstall an package from the device.
///
/// Name of the package.
- ///
- ///
- void UninstallPackage(String packageName) ;
+ ///
+ ///
+ void UninstallPackage (string packageName) ;
///
/// Refreshes the environment variables.
diff --git a/Managed.AndroidDebugBridge/IO/BEBinaryReader.cs b/Managed.AndroidDebugBridge/IO/BEBinaryReader.cs
deleted file mode 100644
index 362f40f..0000000
--- a/Managed.AndroidDebugBridge/IO/BEBinaryReader.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-#region Copyright
-//
-// This library is based on dcm4che see http://www.sourceforge.net/projects/dcm4che
-// Copyright (c) 2002 by TIANI MEDGRAPH AG. All rights reserved.
-//
-// Modifications Copyright (C) 2002 Fang Yang. All rights reserved.
-//
-// This file is part of dicomcs, see http://www.sourceforge.net/projects/dicom-cs
-//
-// This library is free software; you can redistribute it and/or modify it
-// under the terms of the GNU Lesser General Public License as published
-// by the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Fang Yang (yangfang@email.com)
-//
-#endregion
-
-using System;
-using System.IO;
-using System.Net;
-namespace Managed.Adb.IO {
- ///
- /// Big-Endian Binary Reader
- ///
- /// true
- public class BEBinaryReader : BinaryReader {
- public BEBinaryReader ( MemoryStream s )
- : base ( s ) {
- }
-
- ///
- /// Reads a 2-byte signed integer from the current stream and advances the
- /// current position of the stream by two bytes.
- ///
- ///
- public override short ReadInt16 ( ) {
- return IPAddress.NetworkToHostOrder ( base.ReadInt16 ( ) );
- }
-
- ///
- /// Reads a 4-byte signed integer from the current stream and advances the
- /// current position of the stream by four bytes.
- ///
- ///
- public override int ReadInt32 ( ) {
- return IPAddress.NetworkToHostOrder ( base.ReadInt32 ( ) );
- }
-
- ///
- /// Reads an 8-byte signed integer from the current stream and advances
- /// the current position of the stream by four bytes.
- ///
- ///
- public override long ReadInt64 ( ) {
- return IPAddress.NetworkToHostOrder ( base.ReadInt64 ( ) );
- }
-
- ///
- /// Reads a 4-byte floating point value from the current stream and
- /// advances the current position of the stream by four bytes.
- ///
- ///
- public override float ReadSingle ( ) {
- byte[] temp = BitConverter.GetBytes ( base.ReadSingle ( ) );
- Array.Reverse ( temp );
- float returnVal = BitConverter.ToSingle ( temp, 0 );
- return returnVal;
- }
-
- ///
- /// Reads an 8-byte floating point value from the current stream and
- /// advances the current position of the stream by eight bytes.
- ///
- ///
- public override double ReadDouble ( ) {
- byte[] temp = BitConverter.GetBytes ( base.ReadDouble ( ) );
- Array.Reverse ( temp );
- double returnVal = BitConverter.ToDouble ( temp, 0 );
- return returnVal;
- }
- }
-}
diff --git a/Managed.AndroidDebugBridge/IO/BEBinaryWriter.cs b/Managed.AndroidDebugBridge/IO/BEBinaryWriter.cs
deleted file mode 100644
index 0f5411a..0000000
--- a/Managed.AndroidDebugBridge/IO/BEBinaryWriter.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-#region Copyright
-//
-// This library is based on dcm4che see http://www.sourceforge.net/projects/dcm4che
-// Copyright (c) 2002 by TIANI MEDGRAPH AG. All rights reserved.
-//
-// Modifications Copyright (C) 2002 Fang Yang. All rights reserved.
-//
-// This file is part of dicomcs, see http://www.sourceforge.net/projects/dicom-cs
-//
-// This library is free software; you can redistribute it and/or modify it
-// under the terms of the GNU Lesser General Public License as published
-// by the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Fang Yang (yangfang@email.com)
-//
-#endregion
-
-namespace Managed.Adb.IO {
- using System;
- using System.IO;
- using System.Net;
-
- ///
- /// Big-Endian Binary Writer
- ///
- /// true
- public class BEBinaryWriter : BinaryWriter {
- public BEBinaryWriter ( MemoryStream s )
- : base ( s ) {
- }
-
- ///
- /// Writes a two-byte signed integer to the current stream and advances the stream
- /// position by two bytes.
- ///
- ///
- public override void Write ( short value ) {
- base.Write ( IPAddress.HostToNetworkOrder ( value ) );
- }
-
- ///
- /// Writes a four-byte signed integer to the current stream and advances the stream
- /// position by four bytes.
- ///
- ///
- public override void Write ( int value ) {
- base.Write ( IPAddress.HostToNetworkOrder ( value ) );
- }
-
- ///
- /// Writes an eight-byte signed integer to the current stream and advances the stream
- /// position by eight bytes.
- ///
- ///
- public override void Write ( long value ) {
- base.Write ( IPAddress.HostToNetworkOrder ( value ) );
- }
-
- ///
- /// Writes a four-byte floating-point value to the current stream and advances the
- /// stream position by four bytes.
- ///
- ///
- public override void Write ( float value ) {
- byte[] temp = BitConverter.GetBytes ( value );
- Array.Reverse ( temp );
- base.Write ( BitConverter.ToSingle ( temp, 0 ) );
- }
-
- ///
- /// Writes an eight-byte floating-point value to the current stream and advances
- /// the stream position by eight bytes.
- ///
- ///
- public override void Write ( double value ) {
- byte[] temp = BitConverter.GetBytes ( value );
- Array.Reverse ( temp );
- base.Write ( BitConverter.ToDouble ( temp, 0 ) );
- }
- }
-}
diff --git a/Managed.AndroidDebugBridge/IO/ByteBuffer.cs b/Managed.AndroidDebugBridge/IO/ByteBuffer.cs
deleted file mode 100644
index 9a0e27f..0000000
--- a/Managed.AndroidDebugBridge/IO/ByteBuffer.cs
+++ /dev/null
@@ -1,357 +0,0 @@
-#region Copyright
-//
-// This library is based on dcm4che see http://www.sourceforge.net/projects/dcm4che
-// Copyright (c) 2002 by TIANI MEDGRAPH AG. All rights reserved.
-//
-// Modifications Copyright (C) 2002 Fang Yang. All rights reserved.
-//
-// This file is part of dicomcs, see http://www.sourceforge.net/projects/dicom-cs
-//
-// This library is free software; you can redistribute it and/or modify it
-// under the terms of the GNU Lesser General Public License as published
-// by the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Fang Yang (yangfang@email.com)
-//
-#endregion
-
-namespace Managed.Adb.IO {
- using System;
- using System.IO;
- using System.Text;
-
- ///
- /// Summary description for ByteBuffer.
- ///
- /// true
- public class ByteBuffer : MemoryStream {
- private ByteOrder order = ByteOrder.LITTLE_ENDIAN;
- private BinaryReader reader = null;
- private BinaryWriter writer = null;
-
- public int Remaining {
- get { return (int)( Length - Position ); }
- }
-
- ///////////////////////////////////////////////////////////////////////
- /// Constructor
- ///////////////////////////////////////////////////////////////////////
-
- //private ByteBuffer( byte[] buf ) : this( buf, ByteOrder.LITTLE_ENDIAN )
- //{
- //}
-
- public ByteBuffer ( byte[] buf, ByteOrder order )
- : base ( buf ) {
- SetOrder ( order );
- }
-
- public ByteBuffer ( int size, ByteOrder order )
- : base ( size ) {
- SetOrder ( order );
- }
-
- public ByteBuffer ( ) {
- }
-
- ///////////////////////////////////////////////////////////////////////
- /// Public Instance Methods
- ///////////////////////////////////////////////////////////////////////
-
- ///
- /// Return length as int, o/w, we can use Length (long) directly
- ///
- ///
- public int length ( ) {
- return (int)Length;
- }
-
- public ByteOrder GetOrder ( ) {
- return order;
- }
-
- public ByteBuffer SetOrder ( ByteOrder order ) {
- this.order = order;
-
- // Both reader and writer work on the same back store: MemoryStream
- if ( order == ByteOrder.LITTLE_ENDIAN ) {
- reader = new BinaryReader ( this );
- writer = new BinaryWriter ( this );
- } else {
- reader = new BEBinaryReader ( this );
- writer = new BEBinaryWriter ( this );
- }
- return this;
- }
-
- public ByteBuffer Rewind ( ) {
- Position = 0;
- return this;
- }
-
- public ByteBuffer Clear ( ) {
- Position = 0;
- SetLength ( 0 );
- return this;
- }
-
- ///
- /// Skip bytes
- ///
- /// How many bytes to skip
- /// Actual bytes skipped
- public int Skip ( int count ) {
- int old = (int)Position;
- Position += count;
- if ( Position > Length )
- return (int)Length - old;
- return count;
- }
-
- ///
- /// Skip one byte
- ///
- /// Actual bytes skipped
- public int Skip ( ) {
- return Skip ( 1 );
- }
-
-
- ///
- /// ByteBuffer
- ///
- ///
- ///
- public virtual ByteBuffer Write ( ByteBuffer data ) {
- writer.Write ( data.ToArray ( ) );
- return this;
- }
- public virtual ByteBuffer ReadBuffer ( int len ) {
- reader.ReadBytes ( len );
- return this;
- }
- public virtual ByteBuffer ReadBuffer ( int offset, int len ) {
- Position = offset;
- reader.ReadBytes ( len );
- return this;
- }
-
- ///
- /// Byte
- ///
- ///
- ///
- public virtual ByteBuffer Write ( byte value ) {
- writer.Write ( value );
- return this;
- }
- public virtual byte ReadByte ( ) {
- return reader.ReadByte ( );
- }
- public virtual ByteBuffer Write ( byte value, int off ) {
- Position = off;
- writer.Write ( value );
- return this;
- }
- public virtual byte ReadByte ( int off ) {
- Position = off;
- return reader.ReadByte ( );
- }
-
- ///
- /// Bytes
- ///
- ///
- ///
- public virtual ByteBuffer Write ( byte[] value ) {
- writer.Write ( value );
- return this;
- }
-
- ///
- /// Short
- ///
- ///
- ///
- public virtual ByteBuffer Write ( short value ) {
- writer.Write ( value );
- return this;
- }
- public virtual short ReadInt16 ( ) {
- return reader.ReadInt16 ( );
- }
- public virtual ByteBuffer Write ( int off, short value ) {
- Position = off;
- writer.Write ( value );
- return this;
- }
- public virtual short ReadInt16 ( int off ) {
- Position = off;
- return reader.ReadInt16 ( );
- }
-
- ///
- /// Int
- ///
- ///
- ///
- public virtual ByteBuffer Write ( int value ) {
- writer.Write ( value );
- return this;
- }
- public virtual int ReadInt32 ( ) {
- return reader.ReadInt32 ( );
- }
- public virtual ByteBuffer Write ( int off, int value ) {
- Position = off;
- writer.Write ( value );
- return this;
- }
- public virtual int ReadInt32 ( int off ) {
- Position = off;
- return reader.ReadInt32 ( );
- }
-
- ///
- /// Long
- ///
- ///
- ///
- public virtual ByteBuffer Write ( long value ) {
- writer.Write ( value );
- return this;
- }
- public virtual long ReadInt64 ( ) {
- return reader.ReadInt64 ( );
- }
- public virtual ByteBuffer Write ( int off, long value ) {
- Position = off;
- writer.Write ( value );
- return this;
- }
- public virtual long ReadInt64 ( int off ) {
- Position = off;
- return reader.ReadInt64 ( );
- }
-
- ///
- /// Float
- ///
- ///
- ///
- public virtual ByteBuffer Write ( float value ) {
- writer.Write ( value );
- return this;
- }
- public virtual float ReadSingle ( ) {
- return reader.ReadSingle ( );
- }
- public virtual ByteBuffer Write ( int off, float value ) {
- Position = off;
- writer.Write ( value );
- return this;
- }
- public virtual float ReadSingle ( int off ) {
- Position = off;
- return reader.ReadSingle ( );
- }
-
- ///
- /// Double
- ///
- ///
- ///
- public virtual ByteBuffer Write ( Double value ) {
- writer.Write ( value );
- return this;
- }
- public virtual Double ReadDouble ( ) {
- return reader.ReadDouble ( );
- }
- public virtual ByteBuffer Write ( int off, Double value ) {
- Position = off;
- writer.Write ( value );
- return this;
- }
- public virtual Double ReadDouble ( int off ) {
- Position = off;
- return reader.ReadDouble ( );
- }
-
- ///
- /// String
- ///
- ///
- ///
- public virtual ByteBuffer Write ( String value ) {
- writer.Write ( Encoding.ASCII.GetBytes ( value ) );
- return this;
- }
- public virtual String ReadString ( ) {
- Rewind ( );
- return ReadString ( length ( ) );
- }
- public virtual String ReadString ( int len ) {
- byte[] b = new byte[len];
- reader.Read ( b, 0, len );
- while ( len > 0 && b[len - 1] == 0 ) {
- --len;
- }
- return Encoding.ASCII.GetString ( b, 0, len ).Trim ( );
- }
-
- ///
- /// Boolean
- ///
- ///
- ///
- public virtual ByteBuffer Write ( bool value ) {
- writer.Write ( value );
- return this;
- }
- public virtual bool ReadBoolean ( ) {
- return reader.ReadBoolean ( );
- }
-
- public virtual String ToString ( ) {
- System.Text.StringBuilder buf = new System.Text.StringBuilder ( );
-
- byte[] arr = ToArray ( );
- foreach ( byte b in arr ) {
- buf.Append ( String.Format ( "{0:X2} ", b ) );
- }
-
- return buf.ToString ( );
- }
-
- ///////////////////////////////////////////////////////////////////////
- /// Public Class Methods
- ///////////////////////////////////////////////////////////////////////
-
- public static ByteBuffer Wrap ( byte[] buf ) {
- return Wrap ( buf, ByteOrder.LITTLE_ENDIAN );
- }
- public static ByteBuffer Wrap ( byte[] buf, ByteOrder order ) {
- return new ByteBuffer ( buf, order );
- }
-
- public static ByteBuffer Wrap ( byte[] buf, int offset, int len ) {
- return Wrap ( buf, offset, len, ByteOrder.LITTLE_ENDIAN );
- }
- public static ByteBuffer Wrap ( byte[] buf, int offset, int len, ByteOrder order ) {
- byte[] newBuf = new byte[len];
- Array.Copy ( buf, offset, newBuf, 0, len );
- return new ByteBuffer ( newBuf, order );
- }
- }
-}
diff --git a/Managed.AndroidDebugBridge/IO/ByteOrder.cs b/Managed.AndroidDebugBridge/IO/ByteOrder.cs
index 90cf075..5623f1d 100644
--- a/Managed.AndroidDebugBridge/IO/ByteOrder.cs
+++ b/Managed.AndroidDebugBridge/IO/ByteOrder.cs
@@ -10,7 +10,11 @@ namespace Managed.Adb.IO {
/// true
public class ByteOrder {
- private ByteOrder ( String name ) {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The name.
+ private ByteOrder ( string name ) {
this.Name = name;
}
@@ -29,14 +33,14 @@ private ByteOrder ( String name ) {
///
/// The name.
///
- public String Name { get; private set; }
+ public string Name { get; private set; }
///
/// Returns a that represents the current .
///
///
/// A that represents the current .
///
- public String ToString ( ) {
+ public override string ToString ( ) {
return Name;
}
}
diff --git a/Managed.AndroidDebugBridge/IO/LinuxPath.cs b/Managed.AndroidDebugBridge/IO/LinuxPath.cs
index e793f48..1b91299 100644
--- a/Managed.AndroidDebugBridge/IO/LinuxPath.cs
+++ b/Managed.AndroidDebugBridge/IO/LinuxPath.cs
@@ -15,7 +15,7 @@ public static class LinuxPath {
///
/// Pattern to escape filenames for shell command consumption.
///
- private const String ESCAPEPATTERN = "([\\\\()*+?\"'#/\\s])";
+ private const string ESCAPEPATTERN = @"([\\\(\)*+?""'\#/])";
///
/// The directory separator character
@@ -28,9 +28,9 @@ public static class LinuxPath {
///
/// Invalid characters for a file name
///
- private static readonly char[] InvalidFileNameChars = new char[] {
- '"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
- '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
+ private static readonly char[] InvalidFileNameChars = new char[] {
+ '"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
+ '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
'\x001c', '\x001d', '\x001e', '\x001f', '*', '?', '\\', '/'
};
///
@@ -52,22 +52,12 @@ public static class LinuxPath {
///
/// Invalid characters for a file/directory path
///
- private static readonly char[] RealInvalidPathChars = new char[] {
- '"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
- '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
+ private static readonly char[] RealInvalidPathChars = new char[] {
+ '"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v',
+ '\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b',
'\x001c', '\x001d', '\x001e', '\x001f'
};
- ///
- /// Determines whether this instance [can path circumvent security native] the specified part of path.
- ///
- /// The part of path.
- ///
- /// true if this instance [can path circumvent security native] the specified part of path; otherwise, false.
- ///
- [MethodImpl ( MethodImplOptions.InternalCall )]
- private static extern bool CanPathCircumventSecurityNative ( string partOfPath );
-
/// Changes the extension of a path string.
/// A string containing the modified path information.On Windows-based desktop platforms, if path is null or an empty string (""), the path information is returned unmodified. If extension is null, the returned string contains the specified path with its extension removed. If path has no extension, and extension is not null, the returned path string contains extension appended to the end of path.
/// The new extension (with a leading period). Specify null to remove an existing extension from path.
@@ -87,12 +77,12 @@ public static string ChangeExtension ( string path, string extension ) {
str = path.Substring ( 0, length );
break;
}
- if ( ( ( ch == DirectorySeparatorChar ) || ( ch == AltDirectorySeparatorChar ) ) ) {
+ if ( IsDirectorySeparator(ch) ) {
break;
}
}
- if ( String.IsNullOrEmpty ( extension ) || path.Length == 0 ) {
- return str;
+ if ( string.IsNullOrWhiteSpace ( extension ) || path.Length == 0 ) {
+ return path;
}
if ( extension.Length > 0 && extension[0] != '.' ) {
str = str + ".";
@@ -101,59 +91,11 @@ public static string ChangeExtension ( string path, string extension ) {
return ( str + extension );
}
- ///
- /// Checks if the char array starts with ordinal
- ///
- /// The array.
- /// The num chars.
- /// The compare to.
- /// if set to true [ignore case].
- ///
- private static unsafe bool CharArrayStartsWithOrdinal ( char* array, int numChars, string compareTo, bool ignoreCase ) {
- if ( numChars < compareTo.Length ) {
- return false;
- }
- if ( ignoreCase ) {
- string str = new string ( array, 0, compareTo.Length );
- return compareTo.Equals ( str, StringComparison.OrdinalIgnoreCase );
- }
- for ( int i = 0; i < compareTo.Length; i++ ) {
- if ( array[i] != compareTo[i] ) {
- return false;
- }
- }
- return true;
- }
-
- ///
- /// Checks if the char array starts with ordinal
- ///
- /// The array.
- /// The num chars.
- /// The compare to.
- /// if set to true [ignore case].
- ///
- private static bool CharArrayStartsWithOrdinal ( char[] array, int numChars, string compareTo, bool ignoreCase ) {
- if ( numChars < compareTo.Length ) {
- return false;
- }
- if ( ignoreCase ) {
- string str = new string ( array, 0, compareTo.Length );
- return compareTo.Equals ( str, StringComparison.OrdinalIgnoreCase );
- }
- for ( int i = 0; i < compareTo.Length; i++ ) {
- if ( array[i] != compareTo[i] ) {
- return false;
- }
- }
- return true;
- }
-
///
/// Checks the invalid path chars.
///
/// The path.
- internal static void CheckInvalidPathChars( string path ) {
+ internal static void CheckInvalidPathChars ( string path ) {
for ( int i = 0; i < path.Length; i++ ) {
int num2 = path[i];
if ( ( ( num2 == 0x22 ) || ( num2 == 60 ) ) || ( ( ( num2 == 0x3e ) || ( num2 == 0x7c ) ) || ( num2 < 0x20 ) ) ) {
@@ -162,63 +104,12 @@ internal static void CheckInvalidPathChars( string path ) {
}
}
- /// Combines two path strings.
- /// A string containing the combined paths. If one of the specified paths is a zero-length string, this method returns the other path. If path2 contains an absolute path, this method returns path2.
- /// The second path.
- /// The first path.
- /// path1 or path2 is null.
- /// path1 or path2 contain one or more of the invalid characters defined in , or contains a wildcard character.
- public static string Combine ( string path1, string path2 ) {
- if ( ( path1 == null ) || ( path2 == null ) ) {
- throw new ArgumentNullException ( ( path1 == null ) ? "path1" : "path2" );
- }
- CheckInvalidPathChars ( path1 );
- CheckInvalidPathChars ( path2 );
- return CombineNoChecks ( path1, path2 );
- }
-
- ///
- /// Combine the specified paths to form one path
- ///
- /// The path1.
- /// The path2.
- /// The path3.
- ///
- public static string Combine ( string path1, string path2, string path3 ) {
- if ( ( ( path1 == null ) || ( path2 == null ) ) || ( path3 == null ) ) {
- throw new ArgumentNullException ( ( path1 == null ) ? "path1" : ( ( path2 == null ) ? "path2" : "path3" ) );
- }
- CheckInvalidPathChars ( path1 );
- CheckInvalidPathChars ( path2 );
- CheckInvalidPathChars ( path3 );
- return CombineNoChecks ( CombineNoChecks ( path1, path2 ), path3 );
- }
-
- ///
- /// Combine the specified paths to form one path
- ///
- /// The path1.
- /// The path2.
- /// The path3.
- /// The path4.
- ///
- public static string Combine ( string path1, string path2, string path3, string path4 ) {
- if ( ( ( path1 == null ) || ( path2 == null ) ) || ( ( path3 == null ) || ( path4 == null ) ) ) {
- throw new ArgumentNullException ( ( path1 == null ) ? "path1" : ( ( path2 == null ) ? "path2" : ( ( path3 == null ) ? "path3" : "path4" ) ) );
- }
- CheckInvalidPathChars ( path1 );
- CheckInvalidPathChars ( path2 );
- CheckInvalidPathChars ( path3 );
- CheckInvalidPathChars ( path4 );
- return CombineNoChecks ( CombineNoChecks ( CombineNoChecks ( path1, path2 ), path3 ), path4 );
- }
-
///
/// Combine the specified paths to form one path
///
/// The paths.
///
- public static String Combine ( params String[] paths ) {
+ public static string Combine ( params string[] paths ) {
if ( paths == null ) {
throw new ArgumentNullException ( "paths" );
}
@@ -237,22 +128,22 @@ public static String Combine ( params String[] paths ) {
capacity += paths[i].Length;
}
char ch = paths[i][paths[i].Length - 1];
- if ( ( ( ch != DirectorySeparatorChar ) && ( ch != AltDirectorySeparatorChar ) ) ) {
+ if ( !IsDirectorySeparator(ch) ) {
capacity++;
}
}
}
- StringBuilder builder = new StringBuilder ( capacity );
+ var builder = new StringBuilder ( capacity );
for ( int j = num2; j < paths.Length; j++ ) {
if ( paths[j].Length != 0 ) {
if ( builder.Length == 0 ) {
builder.Append ( FixupPath ( paths[j] ) );
} else {
char ch2 = builder[builder.Length - 1];
- if ( ( ( ch2 != DirectorySeparatorChar ) && ( ch2 != AltDirectorySeparatorChar ) ) ) {
+ if ( !IsDirectorySeparator(ch2) ) {
builder.Append ( DirectorySeparatorChar );
}
- builder.Append ( paths[j] );
+ builder.Append ( paths[j] );
}
}
}
@@ -260,32 +151,6 @@ public static String Combine ( params String[] paths ) {
}
- ///
- /// Combines the path with no checks.
- ///
- /// The path1.
- /// The path2.
- ///
- private static string CombineNoChecks ( string path1, string path2 ) {
- if ( path2.Length == 0 ) {
- return FixupPath ( path1 );
- }
- if ( path1.Length == 0 ) {
- return FixupPath ( path2 );
- }
- if ( IsPathRooted ( path2 ) ) {
- return FixupPath ( path2 );
- }
- char ch = path1[path1.Length - 1];
- char ch2 = path2[0];
- if ( ch != DirectorySeparatorChar && ch != AltDirectorySeparatorChar &&
- ch2 != DirectorySeparatorChar && ch2 != AltDirectorySeparatorChar ) {
- return ( FixupPath ( path1 ) + path2 );
- }
- return ( FixupPath ( path1 ) + path2 );
- }
-
-
/// Returns the directory information for the specified path string.
/// A containing directory information for path, or null if path denotes a root directory, is the empty string (""), or is null. Returns if path does not contain directory information.
@@ -293,22 +158,16 @@ private static string CombineNoChecks ( string path1, string path2 ) {
/// The path parameter contains invalid characters, is empty, or contains only white spaces, or contains a wildcard character.
/// The path parameter is longer than the system-defined maximum length.
/// 1
- public static string GetDirectoryName ( String path ) {
+ public static string GetDirectoryName ( string path ) {
if ( path != null ) {
CheckInvalidPathChars ( path );
- //path = FixupPath ( path );
-
- String tpath = path;
- if ( tpath.Length > 1 ) {
- if ( tpath.EndsWith ( new String ( new char[] { DirectorySeparatorChar } ) ) ) {
- return tpath.Substring ( 0, tpath.Length );
- }
-
- tpath = tpath.Substring ( 0, tpath.LastIndexOf ( DirectorySeparatorChar ) + 1 );
-
+ var tpath = path;
+ if ( EndsWithDirectorySeparator(tpath) ) {
return FixupPath ( tpath );
- } else if ( tpath.Length == 1 ) {
- return new String ( new char[] { DirectorySeparatorChar } );
+ } else {
+ var end = tpath.LastIndexOfAny ( new char[] { DirectorySeparatorChar, AltDirectorySeparatorChar } );
+ end = end < 0 ? tpath.Length : end;
+ return FixupPath ( tpath.Substring ( 0, end ) );
}
}
return null;
@@ -325,7 +184,7 @@ public static string GetPathWithoutFile ( string path ) {
string tfilename = GetFileName ( path );
string tpath = path.Substring ( 0, path.Length - tfilename.Length );
tpath = FixupPath ( tpath );
- return tpath.Substring ( 0, tpath.LastIndexOf ( DirectorySeparatorChar ) + 1 );
+ return tpath.Substring ( 0, tpath.LastIndexOfAny ( new char[] { DirectorySeparatorChar, AltDirectorySeparatorChar } ) + 1 );
}
return null;
}
@@ -340,11 +199,11 @@ private static string FixupPath ( string path ) {
sb = sb.Replace ( System.IO.Path.DirectorySeparatorChar, DirectorySeparatorChar );
- if ( !sb.StartsWith ( new String ( new char[] { DirectorySeparatorChar } ) ) ) {
+ if ( !StartsWithDirectorySeparator(sb) ) {
sb = string.Format ( ".{0}{1}", DirectorySeparatorChar, sb );
}
- if ( !sb.EndsWith ( new String ( new char[] { DirectorySeparatorChar } ) ) ) {
+ if ( !EndsWithDirectorySeparator(sb) ) {
sb = string.Format ( "{0}{1}", sb, DirectorySeparatorChar );
}
@@ -373,7 +232,7 @@ public static string GetExtension ( string path ) {
}
return string.Empty;
}
- if ( ( ( ch == DirectorySeparatorChar ) || ( ch == AltDirectorySeparatorChar ) ) ) {
+ if ( IsDirectorySeparator ( ch ) ) {
break;
}
}
@@ -392,7 +251,7 @@ public static string GetFileName ( string path ) {
int num2 = length;
while ( --num2 >= 0 ) {
char ch = path[num2];
- if ( ( ( ch == DirectorySeparatorChar ) || ( ch == AltDirectorySeparatorChar ) ) ) {
+ if ( IsDirectorySeparator ( ch ) ) {
return path.Substring ( num2 + 1, ( length - num2 ) - 1 );
}
}
@@ -457,7 +316,7 @@ internal static int GetRootLength ( string path ) {
if ( ( length >= 2 ) && IsDirectorySeparator ( path[1] ) ) {
num = 2;
int num3 = 2;
- while ( ( num < length ) && ( ( ( path[num] != DirectorySeparatorChar ) && ( path[num] != AltDirectorySeparatorChar ) ) || ( --num3 > 0 ) ) ) {
+ while ( ( num < length ) && !IsDirectorySeparator(path[num] ) || ( --num3 > 0 ) ) {
num++;
}
}
@@ -480,7 +339,7 @@ internal static int GetRootLength ( string path ) {
public static bool HasExtension ( string path ) {
if ( path != null ) {
CheckInvalidPathChars ( path );
- if ( path.EndsWith ( new String ( new char[] { DirectorySeparatorChar } ) ) || path.EndsWith ( new String ( new char[] { AltDirectorySeparatorChar } ) ) ) {
+ if ( EndsWithDirectorySeparator ( path ) ) {
return false;
}
@@ -490,7 +349,7 @@ public static bool HasExtension ( string path ) {
if ( ch == '.' ) {
return ( length != ( path.Length - 1 ) );
}
- if ( ( ( ch == DirectorySeparatorChar ) || ( ch == AltDirectorySeparatorChar ) ) ) {
+ if ( IsDirectorySeparator ( ch ) ) {
break;
}
}
@@ -498,35 +357,6 @@ public static bool HasExtension ( string path ) {
return false;
}
- ///
- /// Combine the specified paths to form one path
- ///
- /// The path1.
- /// The path2.
- ///
- internal static string InternalCombine ( string path1, string path2 ) {
- if ( ( path1 == null ) || ( path2 == null ) ) {
- throw new ArgumentNullException ( ( path1 == null ) ? "path1" : "path2" );
- }
- CheckInvalidPathChars ( path1 );
- CheckInvalidPathChars ( path2 );
- if ( path2.Length == 0 ) {
- throw new ArgumentException ( "Path can not empty", "path2" );
- }
- if ( IsPathRooted ( path2 ) ) {
- throw new ArgumentException ( "Path is already rooted", "path2" );
- }
- int length = path1.Length;
- if ( length == 0 ) {
- return path2;
- }
- char ch = path1[length - 1];
- if ( ( ( ch != DirectorySeparatorChar ) && ( ch != AltDirectorySeparatorChar ) ) ) {
- return ( path1 + DirectorySeparatorChar + path2 );
- }
- return ( path1 + path2 );
- }
-
internal static bool IsDirectorySeparator ( char c ) {
if ( c != DirectorySeparatorChar ) {
return ( c == AltDirectorySeparatorChar );
@@ -534,6 +364,14 @@ internal static bool IsDirectorySeparator ( char c ) {
return true;
}
+ internal static bool EndsWithDirectorySeparator ( string path ) {
+ return path.EndsWith ( new string ( new char[] { DirectorySeparatorChar } ) ) || path.EndsWith ( new string ( new char[] { AltDirectorySeparatorChar } ) );
+ }
+
+ internal static bool StartsWithDirectorySeparator ( string path ) {
+ return path.StartsWith ( new string ( new char[] { DirectorySeparatorChar } ) ) || path.StartsWith ( new string ( new char[] { AltDirectorySeparatorChar } ) );
+ }
+
/// Gets a value indicating whether the specified path string contains absolute or relative path information.
/// true if path contains an absolute path; otherwise, false.
/// The path to test.
@@ -543,7 +381,7 @@ public static bool IsPathRooted ( string path ) {
if ( path != null ) {
CheckInvalidPathChars ( path );
int length = path.Length;
- if ( ( length >= 1 && ( path[0] == DirectorySeparatorChar || path[0] == AltDirectorySeparatorChar ) ) ||
+ if ( ( length >= 1 && IsDirectorySeparator ( path[0] ) ) ||
( length == 1 ) ) {
return true;
}
@@ -556,9 +394,10 @@ public static bool IsPathRooted ( string path ) {
///
/// The path.
///
- public static String Escape( String path ) {
- return new Regex ( ESCAPEPATTERN ).Replace ( path, new MatchEvaluator ( delegate ( Match m ) {
- return m.Result ( "\\\\$1" );
+ /// When path is null.
+ public static string Escape ( string path ) {
+ return path.Require ( ).REReplace(ESCAPEPATTERN, new MatchEvaluator ( delegate ( Match m) {
+ return m.Result ( "\\$1" );
} ) );
}
@@ -567,9 +406,13 @@ public static String Escape( String path ) {
///
/// The path.
///
- public static String Quote( String path ) {
- if ( path.Contains ( " " ) ) {
- return String.Format ( "\"{0}\"", path );
+ public static string Quote ( string path ) {
+ if ( string.IsNullOrEmpty(path) ) {
+ return path;
+ }
+
+ if(path.IsMatch(@"\s")) {
+ return "\"{0}\"".With ( path );
} else {
return path;
}
diff --git a/Managed.AndroidDebugBridge/IO/Rgb565.cs b/Managed.AndroidDebugBridge/IO/Rgb565.cs
index 8c23447..692014f 100644
--- a/Managed.AndroidDebugBridge/IO/Rgb565.cs
+++ b/Managed.AndroidDebugBridge/IO/Rgb565.cs
@@ -14,7 +14,7 @@ namespace Managed.Adb.IO {
public static class Rgb565 {
///
- /// To the image.
+ /// Reads the file and returns the RGB565 Image
///
/// The file.
///
@@ -25,7 +25,7 @@ public static Image ToImage ( string file ) {
}
///
- /// To the image.
+ /// Reads the file and returns the RGB565 Image
///
/// The stream.
///
@@ -44,7 +44,7 @@ public static Image ToImage ( Stream stream ) {
}
///
- /// To the image.
+ /// Reads the file and returns the RGB565 Image
///
/// The buffer.
///
@@ -53,7 +53,7 @@ public static Image ToImage ( byte[] buffer ) {
}
///
- /// To the image.
+ /// Reads the file and returns the RGB565 Image
///
/// The format.
/// The buffer.
diff --git a/Managed.AndroidDebugBridge/IO/ScreenResolution.cs b/Managed.AndroidDebugBridge/IO/ScreenResolution.cs
index df2e4b4..d782f46 100644
--- a/Managed.AndroidDebugBridge/IO/ScreenResolution.cs
+++ b/Managed.AndroidDebugBridge/IO/ScreenResolution.cs
@@ -113,6 +113,12 @@ private ScreenResolution ( ) {
}
private static ScreenResolution _instance = null;
+ ///
+ /// Gets the instance.
+ ///
+ ///
+ /// The instance.
+ ///
public static ScreenResolution Instance {
get {
if ( _instance == null ) {
@@ -122,9 +128,21 @@ public static ScreenResolution Instance {
}
}
+ ///
+ /// Gets the sizes.
+ ///
+ ///
+ /// The sizes.
+ ///
public Dictionary Sizes { get; private set; }
+ ///
+ /// Calculates the size.
+ ///
+ /// The pixels.
+ ///
+ ///
public Size CalculateSize ( long pixels ) {
// this doesnt work very well, unless the number of pixels is exact!
List ordered = new List ( Sizes.Keys );
@@ -143,6 +161,12 @@ public Size CalculateSize ( long pixels ) {
}
+ ///
+ /// Pixelses from size.
+ ///
+ /// The size.
+ ///
+ ///
public int PixelsFromSize ( Size size ) {
foreach ( var item in Sizes.Keys ) {
diff --git a/Managed.AndroidDebugBridge/IPacketConsumer.cs b/Managed.AndroidDebugBridge/IPacketConsumer.cs
index a9f7839..e2daa02 100644
--- a/Managed.AndroidDebugBridge/IPacketConsumer.cs
+++ b/Managed.AndroidDebugBridge/IPacketConsumer.cs
@@ -13,12 +13,17 @@ public interface IPacketConsumer {
///
void Read ( );
// TODO: JdwpPacket
- /*JdwpPacket*/ Object GetJdwpPacket ( );
+ ///
+ /// Gets the JDWP packet.
+ ///
+ ///
+ /*JdwpPacket*/
+ object GetJdwpPacket ( );
///
/// Forwards the packet to client.
///
/// The packet.
- void ForwardPacketToClient ( /*JdwpPacket*/ Object packet );
+ void ForwardPacketToClient ( /*JdwpPacket*/ object packet );
///
/// Sends the handshake.
///
@@ -27,6 +32,6 @@ public interface IPacketConsumer {
/// Sends the and consume.
///
/// The packet.
- void SendAndConsume ( /*JdwpPacket*/ Object packet );
+ void SendAndConsume ( /*JdwpPacket*/ object packet );
}
}
diff --git a/Managed.AndroidDebugBridge/ISyncProgressMonitor.cs b/Managed.AndroidDebugBridge/ISyncProgressMonitor.cs
index 4292217..708e0ce 100644
--- a/Managed.AndroidDebugBridge/ISyncProgressMonitor.cs
+++ b/Managed.AndroidDebugBridge/ISyncProgressMonitor.cs
@@ -28,8 +28,9 @@ public interface ISyncProgressMonitor {
///
/// Sent when a sub task is started.
///
+ /// The source.
/// the destination.
- void StartSubTask ( String source, String destination );
+ void StartSubTask ( string source, string destination );
///
/// Sent when some progress have been made.
diff --git a/Managed.AndroidDebugBridge/Log.cs b/Managed.AndroidDebugBridge/Log.cs
index 8f008d5..0a2a2c5 100644
--- a/Managed.AndroidDebugBridge/Log.cs
+++ b/Managed.AndroidDebugBridge/Log.cs
@@ -105,7 +105,7 @@ public static void d ( String tag, String format, params object[] args ) {
/// Outputs a Info level message.
///
/// The tag associated with the message.
- /// The message to output.
+ /// The message.
public static void i ( String tag, String message ) {
WriteLine ( LogLevel.Info, tag, message );
}
diff --git a/Managed.AndroidDebugBridge/LogLevel.cs b/Managed.AndroidDebugBridge/LogLevel.cs
index c627806..c3bac0f 100644
--- a/Managed.AndroidDebugBridge/LogLevel.cs
+++ b/Managed.AndroidDebugBridge/LogLevel.cs
@@ -67,6 +67,11 @@ static LogLevel ( ) {
/// The levels.
public static Dictionary Levels { get; private set; }
+ ///
+ /// Gets the by string.
+ ///
+ /// The value.
+ ///
public static LogLevelInfo GetByString ( String value ) {
foreach ( LogLevelInfo item in Values ) {
diff --git a/Managed.AndroidDebugBridge/Logs/ILogListener.cs b/Managed.AndroidDebugBridge/Logs/ILogListener.cs
index 0f57df4..3f36216 100644
--- a/Managed.AndroidDebugBridge/Logs/ILogListener.cs
+++ b/Managed.AndroidDebugBridge/Logs/ILogListener.cs
@@ -4,6 +4,9 @@
using System.Text;
namespace Managed.Adb.Logs {
+ ///
+ ///
+ ///
public interface ILogListener {
///
/// Sent when a new LogEntry has been parsed by the LogReceiver.
diff --git a/Managed.AndroidDebugBridge/Logs/LogEntry.cs b/Managed.AndroidDebugBridge/Logs/LogEntry.cs
index 8112b44..e89a35f 100644
--- a/Managed.AndroidDebugBridge/Logs/LogEntry.cs
+++ b/Managed.AndroidDebugBridge/Logs/LogEntry.cs
@@ -4,12 +4,51 @@
using System.Text;
namespace Managed.Adb.Logs {
+ ///
+ ///
+ ///
public sealed class LogEntry {
+ ///
+ /// Gets or sets the length.
+ ///
+ ///
+ /// The length.
+ ///
public int Length { get; set; }
+ ///
+ /// Gets or sets the process identifier.
+ ///
+ ///
+ /// The process identifier.
+ ///
public int ProcessId { get; set; }
+ ///
+ /// Gets or sets the thread identifier.
+ ///
+ ///
+ /// The thread identifier.
+ ///
public int ThreadId { get; set; }
+ ///
+ /// Gets or sets the time stamp.
+ ///
+ ///
+ /// The time stamp.
+ ///
public DateTime TimeStamp { get; set; }
+ ///
+ /// Gets or sets the nano seconds.
+ ///
+ ///
+ /// The nano seconds.
+ ///
public int NanoSeconds { get; set; }
+ ///
+ /// Gets or sets the data.
+ ///
+ ///
+ /// The data.
+ ///
public byte[] Data { get; set; }
}
}
diff --git a/Managed.AndroidDebugBridge/Logs/LogReceiver.cs b/Managed.AndroidDebugBridge/Logs/LogReceiver.cs
index 26d87d8..091185b 100644
--- a/Managed.AndroidDebugBridge/Logs/LogReceiver.cs
+++ b/Managed.AndroidDebugBridge/Logs/LogReceiver.cs
@@ -4,8 +4,18 @@
using System.Text;
namespace Managed.Adb.Logs {
+ ///
+ ///
+ ///
public class LogReceiver {
+ ///
+ /// The entr y_ heade r_ size
+ ///
private const int ENTRY_HEADER_SIZE = 20; // 2*2 + 4*4; see LogEntry.
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The listener.
public LogReceiver ( ILogListener listener ) {
EntryDataOffset = 0;
EntryHeaderBuffer = new byte[ENTRY_HEADER_SIZE];
@@ -13,18 +23,63 @@ public LogReceiver ( ILogListener listener ) {
Listener = listener;
}
+ ///
+ /// Gets or sets the entry data offset.
+ ///
+ ///
+ /// The entry data offset.
+ ///
private int EntryDataOffset { get; set; }
+ ///
+ /// Gets or sets the entry header offset.
+ ///
+ ///
+ /// The entry header offset.
+ ///
private int EntryHeaderOffset { get; set; }
+ ///
+ /// Gets or sets the entry header buffer.
+ ///
+ ///
+ /// The entry header buffer.
+ ///
private byte[] EntryHeaderBuffer { get; set; }
+ ///
+ /// Gets or sets the current entry.
+ ///
+ ///
+ /// The current entry.
+ ///
private LogEntry CurrentEntry { get; set; }
+ ///
+ /// Gets or sets the listener.
+ ///
+ ///
+ /// The listener.
+ ///
private ILogListener Listener { get; set; }
+ ///
+ /// Gets a value indicating whether this instance is cancelled.
+ ///
+ ///
+ /// true if this instance is cancelled; otherwise, false.
+ ///
public bool IsCancelled { get; private set; }
+ ///
+ /// Cancels this instance.
+ ///
public void Cancel ( ) {
this.IsCancelled = true;
}
+ ///
+ /// Parses the new data.
+ ///
+ /// The data.
+ /// The offset.
+ /// The length.
public void ParseNewData ( byte[] data, int offset, int length ) {
// notify the listener of new raw data
if ( Listener != null ) {
@@ -108,6 +163,13 @@ public void ParseNewData ( byte[] data, int offset, int length ) {
}
+ ///
+ /// Creates the entry.
+ ///
+ /// The data.
+ /// The offset.
+ ///
+ /// Buffer not big enough to hold full LoggerEntry header
private LogEntry CreateEntry ( byte[] data, int offset ) {
if ( data.Length < offset + ENTRY_HEADER_SIZE ) {
throw new ArgumentException ( "Buffer not big enough to hold full LoggerEntry header" );
diff --git a/Managed.AndroidDebugBridge/Managed.Adb.csproj b/Managed.AndroidDebugBridge/Managed.Adb.csproj
index 4d0072a..1b60198 100644
--- a/Managed.AndroidDebugBridge/Managed.Adb.csproj
+++ b/Managed.AndroidDebugBridge/Managed.Adb.csproj
@@ -57,6 +57,7 @@
true
AllRules.ruleset
x86
+ true
true
@@ -88,7 +89,6 @@
true
GlobalSuppressions.cs
prompt
- true
true
x86
AllRules.ruleset
@@ -124,8 +124,8 @@
..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll
-
- ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll
True
@@ -173,9 +173,6 @@
-
-
-
@@ -208,7 +205,6 @@
-
diff --git a/Managed.AndroidDebugBridge/MonitorThread.cs b/Managed.AndroidDebugBridge/MonitorThread.cs
index 7070390..39ad200 100644
--- a/Managed.AndroidDebugBridge/MonitorThread.cs
+++ b/Managed.AndroidDebugBridge/MonitorThread.cs
@@ -71,6 +71,11 @@ internal void SetDebugSelectedPort ( int value ) {
//throw new NotImplementedException ( );
}
+ ///
+ /// Drops the client.
+ ///
+ /// The client.
+ /// if set to true [notify].
public void DropClient ( IClient client, bool notify ) {
}
diff --git a/Managed.AndroidDebugBridge/RawImage.cs b/Managed.AndroidDebugBridge/RawImage.cs
index 531c84c..89a016d 100644
--- a/Managed.AndroidDebugBridge/RawImage.cs
+++ b/Managed.AndroidDebugBridge/RawImage.cs
@@ -102,6 +102,12 @@ public RawImage ( ) {
* @param buf the buffer to read from.
* @return true if success
*/
+ ///
+ /// Reads the header.
+ ///
+ /// The version.
+ /// The buf.
+ ///
public bool ReadHeader ( int version, BinaryReader buf ) {
this.Version = version;
// https://github.com/android/platform_system_core/blob/master/adb/framebuffer_service.c
@@ -146,11 +152,11 @@ public bool ReadHeader ( int version, BinaryReader buf ) {
return true;
}
- /**
- * Returns the size of the header for a specific version of the framebuffer adb protocol.
- * @param version the version of the protocol
- * @return the number of int that makes up the header.
- */
+ ///
+ /// Returns the size of the header for a specific version of the framebuffer adb protocol.
+ ///
+ /// the version of the protocol.
+ /// the number of int that makes up the header.
public static int GetHeaderSize ( int version ) {
switch ( version ) {
case 16: // compatibility mode
@@ -166,10 +172,11 @@ public static int GetHeaderSize ( int version ) {
return 0;
}
- /**
- * Returns a rotated version of the image
- * The image is rotated counter-clockwise.
- */
+ ///
+ /// Returns a rotated version of the image
+ /// The image is rotated counter-clockwise.
+ ///
+ ///
public RawImage GetRotated ( ) {
RawImage rotated = new RawImage ( );
rotated.Version = this.Version;
@@ -258,6 +265,11 @@ public Image ToImage ( ) {
return ToImage ( this.Bpp == 32 ? PixelFormat.Format32bppArgb : PixelFormat.Format16bppRgb565 );
}
+ ///
+ /// Swaps the specified b.
+ ///
+ /// The b.
+ ///
private byte[] Swap ( byte[] b ) {
var clone = new List ( );
b.IntReverseForRawImage ( bitem => {
diff --git a/Managed.AndroidDebugBridge/Receivers/BatteryReceiver.cs b/Managed.AndroidDebugBridge/Receivers/BatteryReceiver.cs
index 52ed48e..47c7372 100644
--- a/Managed.AndroidDebugBridge/Receivers/BatteryReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/BatteryReceiver.cs
@@ -11,17 +11,17 @@ namespace Managed.Adb {
///
///
public class BatteryReceiver : MultiLineReceiver {
- private const String TAG = "BatteryReceiver";
- private const String BATTERY_LEVEL = @"\s*level:\s?(\d+)";
- private const String AC_POWER = @"\s*AC\spowered:\s?(true|false)";
- private const String USB_POWER = @"\s*USB\spowered:\s?(true|false)";
- private const String PRESENT = @"\s*present:\s?(true|false)";
- private const String STATUS = @"\s*status:\s(\d+)";
- private const String HEALTH = @"\s*health:\s(\d+)";
- private const String SCALE = @"\s*scale:\s(\d+)";
- private const String VOLTAGE = @"\s*voltage:\s(\d+)";
- private const String TYPE = @"\s*technology:\s(.*?)$";
- private const String TEMP = @"\s*temperature:\s(\d+)";
+ private const string TAG = nameof ( BatteryReceiver );
+ private const string BATTERY_LEVEL = @"\s*level:\s?(\d+)";
+ private const string AC_POWER = @"\s*AC\spowered:\s?(true|false)";
+ private const string USB_POWER = @"\s*USB\spowered:\s?(true|false)";
+ private const string PRESENT = @"\s*present:\s?(true|false)";
+ private const string STATUS = @"\s*status:\s(\d+)";
+ private const string HEALTH = @"\s*health:\s(\d+)";
+ private const string SCALE = @"\s*scale:\s(\d+)";
+ private const string VOLTAGE = @"\s*voltage:\s(\d+)";
+ private const string TYPE = @"\s*technology:\s(.*?)$";
+ private const string TEMP = @"\s*temperature:\s(\d+)";
private const RegexOptions REOPTIONS = RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace;
@@ -33,7 +33,7 @@ public class BatteryReceiver : MultiLineReceiver {
/// The battery info.
///
public BatteryInfo BatteryInfo { get; private set; }
-
+
///
/// Processes the new lines.
///
@@ -41,12 +41,12 @@ public class BatteryReceiver : MultiLineReceiver {
protected override void ProcessNewLines ( string[] lines ) {
BatteryInfo = new BatteryInfo ( );
foreach ( var line in lines ) {
- var match = line.Match( BATTERY_LEVEL, REOPTIONS );
+ var match = line.Match ( BATTERY_LEVEL, REOPTIONS );
if ( match.Success ) {
try {
BatteryInfo.Level = Int32.Parse ( match.Groups[1].Value );
} catch ( FormatException ) {
- Log.w ( TAG, String.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
+ Log.w ( TAG, string.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
}
}
@@ -55,23 +55,23 @@ protected override void ProcessNewLines ( string[] lines ) {
try {
BatteryInfo.Scale = Int32.Parse ( match.Groups[1].Value );
} catch ( FormatException ) {
- Log.w ( TAG, String.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
+ Log.w ( TAG, string.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
}
}
match = line.Match ( AC_POWER, REOPTIONS );
if ( match.Success ) {
- BatteryInfo.ACPowered = String.Compare ( match.Groups[1].Value, bool.TrueString, true ) == 0;
+ BatteryInfo.ACPowered = string.Compare ( match.Groups[1].Value, bool.TrueString, true ) == 0;
}
match = line.Match ( USB_POWER, REOPTIONS );
if ( match.Success ) {
- BatteryInfo.UsbPowered = String.Compare ( match.Groups[1].Value, bool.TrueString, true ) == 0;
+ BatteryInfo.UsbPowered = string.Compare ( match.Groups[1].Value, bool.TrueString, true ) == 0;
}
match = line.Match ( PRESENT, REOPTIONS );
if ( match.Success ) {
- BatteryInfo.Present = String.Compare ( match.Groups[1].Value, bool.TrueString, true ) == 0;
+ BatteryInfo.Present = string.Compare ( match.Groups[1].Value, bool.TrueString, true ) == 0;
}
match = line.Match ( STATUS, REOPTIONS );
@@ -80,7 +80,7 @@ protected override void ProcessNewLines ( string[] lines ) {
var i = Int32.Parse ( match.Groups[1].Value );
BatteryInfo.Status = i.ToEnum ( );
} catch ( FormatException ) {
- Log.w ( TAG, String.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
+ Log.w ( TAG, string.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
}
}
@@ -90,7 +90,7 @@ protected override void ProcessNewLines ( string[] lines ) {
var i = Int32.Parse ( match.Groups[1].Value );
BatteryInfo.Health = i.ToEnum ( );
} catch ( FormatException ) {
- Log.w ( TAG, String.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
+ Log.w ( TAG, string.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
}
}
@@ -99,7 +99,7 @@ protected override void ProcessNewLines ( string[] lines ) {
try {
BatteryInfo.Voltage = Int32.Parse ( match.Groups[1].Value );
} catch ( FormatException ) {
- Log.w ( TAG, String.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
+ Log.w ( TAG, string.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
}
}
@@ -113,7 +113,7 @@ protected override void ProcessNewLines ( string[] lines ) {
try {
BatteryInfo.Temperature = Int32.Parse ( match.Groups[1].Value );
} catch ( FormatException ) {
- Log.w ( TAG, String.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
+ Log.w ( TAG, string.Format ( "Failed to parse {0} as an integer", match.Groups[1].Value ) );
}
}
}
diff --git a/Managed.AndroidDebugBridge/Receivers/CommandErrorReceiver.cs b/Managed.AndroidDebugBridge/Receivers/CommandErrorReceiver.cs
index db60db0..c6c5526 100644
--- a/Managed.AndroidDebugBridge/Receivers/CommandErrorReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/CommandErrorReceiver.cs
@@ -4,6 +4,10 @@
using System.Text;
namespace Managed.Adb {
+ ///
+ ///
+ ///
+ ///
internal class CommandErrorReceiver : MultiLineReceiver {
///
/// Initializes a new instance of the class.
diff --git a/Managed.AndroidDebugBridge/Receivers/CommandResultReceiver.cs b/Managed.AndroidDebugBridge/Receivers/CommandResultReceiver.cs
index ee3de35..12eb2e6 100644
--- a/Managed.AndroidDebugBridge/Receivers/CommandResultReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/CommandResultReceiver.cs
@@ -14,8 +14,8 @@ public class CommandResultReceiver : MultiLineReceiver{
/// The lines.
protected override void ProcessNewLines ( string[] lines ) {
var result = new StringBuilder ( );
- foreach ( String line in lines ) {
- if ( String.IsNullOrEmpty ( line ) || line.StartsWith ( "#" ) || line.StartsWith ( "$" ) ) {
+ foreach ( string line in lines ) {
+ if ( string.IsNullOrWhiteSpace ( line ) || line.StartsWith ( "#" ) || line.StartsWith ( "$" ) ) {
continue;
}
@@ -31,6 +31,6 @@ protected override void ProcessNewLines ( string[] lines ) {
///
/// The result.
///
- public String Result { get; private set; }
+ public string Result { get; private set; }
}
}
diff --git a/Managed.AndroidDebugBridge/Receivers/ConsoleOutputReceiver.cs b/Managed.AndroidDebugBridge/Receivers/ConsoleOutputReceiver.cs
index ac9ef9f..5828a3a 100644
--- a/Managed.AndroidDebugBridge/Receivers/ConsoleOutputReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/ConsoleOutputReceiver.cs
@@ -29,7 +29,7 @@ public static ConsoleOutputReceiver Instance {
/// The lines.
protected override void ProcessNewLines ( string[] lines ) {
foreach ( var line in lines ) {
- if (string.IsNullOrEmpty ( line ) || line.StartsWith ( "#" ) || line.StartsWith("$") ) {
+ if (string.IsNullOrWhiteSpace ( line ) || line.StartsWith ( "#" ) || line.StartsWith("$") ) {
continue;
}
Console.WriteLine ( line );
diff --git a/Managed.AndroidDebugBridge/Receivers/EnvironmentVariablesReceiver.cs b/Managed.AndroidDebugBridge/Receivers/EnvironmentVariablesReceiver.cs
index 02739a1..b9cd6fa 100644
--- a/Managed.AndroidDebugBridge/Receivers/EnvironmentVariablesReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/EnvironmentVariablesReceiver.cs
@@ -36,15 +36,15 @@ public EnvironmentVariablesReceiver ( Device device ) {
///
/// The lines.
protected override void ProcessNewLines ( string[] lines ) {
- foreach ( String line in lines ) {
- if ( String.IsNullOrEmpty ( line ) || line.StartsWith ( "#" ) ) {
+ foreach ( string line in lines ) {
+ if ( string.IsNullOrWhiteSpace ( line ) || line.StartsWith ( "#" ) || line.StartsWith ( "$" ) ) {
continue;
}
- Match m = Regex.Match ( line, ENV_PATTERN );
+ var m = Regex.Match ( line, ENV_PATTERN );
if ( m.Success ) {
- String label = m.Groups[1].Value.Trim ( );
- String value = m.Groups[2].Value.Trim ( );
+ var label = m.Groups[1].Value.Trim ( );
+ var value = m.Groups[2].Value.Trim ( );
if ( label.Length > 0 ) {
if ( Device.EnvironmentVariables.ContainsKey ( label ) ) {
diff --git a/Managed.AndroidDebugBridge/Receivers/GetPropReceiver.cs b/Managed.AndroidDebugBridge/Receivers/GetPropReceiver.cs
index b8be196..24ce720 100644
--- a/Managed.AndroidDebugBridge/Receivers/GetPropReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/GetPropReceiver.cs
@@ -41,14 +41,14 @@ protected override void ProcessNewLines ( string[] lines ) {
// date in the 2nd line. There seems to be an empty line
// after all that.
- foreach ( String line in lines ) {
- if ( String.IsNullOrEmpty ( line ) || line.StartsWith ( "#" ) || line.StartsWith("$") ) {
+ foreach ( string line in lines ) {
+ if ( string.IsNullOrEmpty ( line ) || line.StartsWith ( "#" ) || line.StartsWith("$") ) {
continue;
}
var m = line.Match ( GETPROP_PATTERN, RegexOptions.Compiled );
if ( m.Success ) {
- String label = m.Groups[1].Value.Trim ( );
- String value = m.Groups[2].Value.Trim ( );
+ var label = m.Groups[1].Value.Trim ( );
+ var value = m.Groups[2].Value.Trim ( );
if ( label.Length > 0 ) {
Device.Properties.Add ( label, value );
diff --git a/Managed.AndroidDebugBridge/Receivers/InstallReceiver.cs b/Managed.AndroidDebugBridge/Receivers/InstallReceiver.cs
index 2693685..a082919 100644
--- a/Managed.AndroidDebugBridge/Receivers/InstallReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/InstallReceiver.cs
@@ -13,20 +13,20 @@ public class InstallReceiver : MultiLineReceiver {
///
///
///
- private const String SUCCESS_OUTPUT = "Success";
+ private const string SUCCESS_OUTPUT = "Success";
///
///
///
- private const String FAILURE_PATTERN = @"Failure(?:\s+\[(.*)\])?";
+ private const string FAILURE_PATTERN = @"Failure(?:\s+\[(.*)\])?";
- private const String UNKNOWN_ERROR = "An unknown error occurred.";
+ private const string UNKNOWN_ERROR = "An unknown error occurred.";
///
/// Processes the new lines.
///
/// The lines.
protected override void ProcessNewLines ( string[] lines ) {
- foreach ( String line in lines ) {
+ foreach ( string line in lines ) {
if ( line.Length > 0 ) {
if ( line.StartsWith ( SUCCESS_OUTPUT ) ) {
ErrorMessage = null;
@@ -48,7 +48,7 @@ protected override void ProcessNewLines ( string[] lines ) {
/// Gets the error message if the install was unsuccessful.
///
/// The error message.
- public String ErrorMessage { get; private set; }
+ public string ErrorMessage { get; private set; }
///
/// Gets a value indicating whether the install was a success.
diff --git a/Managed.AndroidDebugBridge/Receivers/LinkResoverReceiver.cs b/Managed.AndroidDebugBridge/Receivers/LinkResoverReceiver.cs
index b348305..4b74cba 100644
--- a/Managed.AndroidDebugBridge/Receivers/LinkResoverReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/LinkResoverReceiver.cs
@@ -6,13 +6,30 @@
using MoreLinq;
namespace Managed.Adb {
+ ///
+ ///
+ ///
+ ///
internal sealed class LinkResoverReceiver : MultiLineReceiver {
+ ///
+ /// Initializes a new instance of the class.
+ ///
public LinkResoverReceiver ( ) {
}
- public String ResolvedPath { get; set; }
+ ///
+ /// Gets or sets the resolved path.
+ ///
+ ///
+ /// The resolved path.
+ ///
+ public string ResolvedPath { get; set; }
+ ///
+ /// Processes the new lines.
+ ///
+ /// The lines.
protected override void ProcessNewLines ( string[] lines ) {
// all we care about is a line with '->'
var regex = @"->\s+([^$]+)";
diff --git a/Managed.AndroidDebugBridge/Receivers/MountPointReceiver.cs b/Managed.AndroidDebugBridge/Receivers/MountPointReceiver.cs
index b5e0eef..3abe5ee 100644
--- a/Managed.AndroidDebugBridge/Receivers/MountPointReceiver.cs
+++ b/Managed.AndroidDebugBridge/Receivers/MountPointReceiver.cs
@@ -52,22 +52,6 @@ protected override void ProcessNewLines ( string[] lines ) {
}
}
} );
- /*
- foreach ( var line in lines ) {
- Match m = Regex.Match ( line, RE_MOUNTPOINT_PATTERN, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace );
- if ( m.Success ) {
- String block = m.Groups[1].Value.Trim ( ).Replace ( "//", "/" );
- String name = m.Groups[2].Value.Trim ( );
- String fs = m.Groups[3].Value.Trim ( );
- bool ro = String.Compare ( "ro", m.Groups[4].Value.Trim ( ), false ) == 0;
- MountPoint mnt = new MountPoint ( block, name, fs, ro );
- String key = name.Substring ( 1 );
- // currently does not support multiple mounts to the same location...
- if ( !Device.MountPoints.ContainsKey ( name ) ) {
- Device.MountPoints.Add ( name, mnt );
- }
- }
- }*/
}
///
diff --git a/Managed.AndroidDebugBridge/SyncService.cs b/Managed.AndroidDebugBridge/SyncService.cs
index 0866675..79e6826 100644
--- a/Managed.AndroidDebugBridge/SyncService.cs
+++ b/Managed.AndroidDebugBridge/SyncService.cs
@@ -9,6 +9,10 @@
using Camalot.Common.Extensions;
namespace Managed.Adb {
+ ///
+ ///
+ ///
+ ///
public class SyncService : IDisposable {
private const String OKAY = "OKAY";
private const String FAIL = "FAIL";
@@ -20,6 +24,9 @@ public class SyncService : IDisposable {
private const String LIST = "LIST";
private const String DENT = "DENT";
private const string TAG = "sync";
+ ///
+ ///
+ ///
[Flags]
public enum FileMode {
///
@@ -83,7 +90,9 @@ public enum FileMode {
private const int SYNC_DATA_MAX = 64 * 1024;
private const int REMOTE_PATH_MAX_LENGTH = 1024;
- #region static members
+ ///
+ /// Initializes the class.
+ ///
static SyncService ( ) {
NullProgressMonitor = new NullSyncProgressMonitor ( );
}
@@ -95,6 +104,12 @@ static SyncService ( ) {
/// The null progress monitor.
///
public static NullSyncProgressMonitor NullProgressMonitor { get; private set; }
+ ///
+ /// Gets or sets the data buffer.
+ ///
+ ///
+ /// The data buffer.
+ ///
private static byte[] DataBuffer { get; set; }
///
@@ -206,10 +221,24 @@ private static byte[] CreateFileRequest ( byte[] command, byte[] path ) {
return array;
}
+ ///
+ /// Creates the send file request.
+ ///
+ /// The command.
+ /// The path.
+ /// The mode.
+ ///
private static byte[] CreateSendFileRequest ( String command, String path, FileMode mode ) {
return CreateSendFileRequest ( Encoding.Default.GetBytes ( command ), Encoding.Default.GetBytes ( path ), mode );
}
+ ///
+ /// Creates the send file request.
+ ///
+ /// The command.
+ /// The path.
+ /// The mode.
+ ///
private static byte[] CreateSendFileRequest ( byte[] command, byte[] path, FileMode mode ) {
String modeString = String.Format ( ",{0}", ( (int)mode & 0777 ) );
byte[] modeContent = null;
@@ -227,7 +256,6 @@ private static byte[] CreateSendFileRequest ( byte[] command, byte[] path, FileM
return array;
}
- #endregion
///
/// Initializes a new instance of the class.
@@ -263,6 +291,12 @@ public SyncService ( IPEndPoint address, Device device ) {
/// The device.
///
public Device Device { get; private set; }
+ ///
+ /// Gets or sets the channel.
+ ///
+ ///
+ /// The channel.
+ ///
private Socket Channel { get; set; }
///
/// Gets a value indicating whether this instance is open.
@@ -644,6 +678,14 @@ private SyncResult DoPushFile ( string local, string remotePath, ISyncProgressMo
return new SyncResult ( ErrorCodeHelper.RESULT_OK );
}
+ ///
+ /// Does the push.
+ ///
+ /// The files.
+ /// The remote path.
+ /// The monitor.
+ ///
+ /// monitor;Monitor cannot be null
private SyncResult DoPush ( IEnumerable files, string remotePath, ISyncProgressMonitor monitor ) {
if ( monitor == null ) {
throw new ArgumentNullException ( "monitor", "Monitor cannot be null" );
@@ -802,15 +844,15 @@ private SyncResult DoPullFile ( string remotePath, string localPath, ISyncProgre
}
///
- ///
+ /// Does the pull.
///
- ///
- ///
- ///
- ///
+ /// The entries.
+ /// The local path.
+ /// The file listing service.
+ /// The monitor.
///
- /// Throws if unable to create a file or folder
/// Throws if the ISyncProgressMonitor is null
+ /// Throws if unable to create a file or folder
private SyncResult DoPull ( IEnumerable entries, string localPath, FileListingService fileListingService, ISyncProgressMonitor monitor ) {
if ( monitor == null ) {
throw new ArgumentNullException ( "monitor", "Monitor cannot be null" );
@@ -896,9 +938,13 @@ private long GetTotalRemoteFileSize ( IEnumerable entries, FileListin
///
/// compute the recursive file size of all the files in the list. Folders have a weight of 1.
///
- /// The local files / folders
- /// The total number of bytes
- /// This does not check for circular links.
+ /// The fsis.
+ ///
+ /// The total number of bytes
+ ///
+ ///
+ /// This does not check for circular links.
+ ///
private long GetTotalLocalFileSize ( IEnumerable fsis ) {
long count = 0;
diff --git a/Managed.AndroidDebugBridge/packages.config b/Managed.AndroidDebugBridge/packages.config
index 35ede0d..c3b3b75 100644
--- a/Managed.AndroidDebugBridge/packages.config
+++ b/Managed.AndroidDebugBridge/packages.config
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 9e69646..4a2ea47 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
[![MadBee](http://i.imgur.com/UxO8Lrj.png)](http://madb.bit13.com/)
[![Build status](https://ci.appveyor.com/api/projects/status/dn8mjauo4i5ghwlg?svg=true)](https://ci.appveyor.com/project/camalot/madb)
+[![Code Coverage by CodeCov](https://codecov.io/github/camalot/madb/coverage.svg)](https://codecov.io/github/camalot/madb)
This is a Managed port of the Android Debug Bridge to allow communication from .NET applications to Android devices.
This wraps the same methods that the ddms uses to directly communicate with ADB.
@@ -118,3 +119,13 @@ PM> Install-Package Managed.Adb.x64
* PullFile
* Push
* PushFile
+
+
+
+### Copyright
+Copyright (c) 2010-2016 Ryan Conrad
+
+Portions are:
+
+Copyright (c) 2004-2008 Jon Skeet and Marc Gravell
+Copyright (c) 2007 The Android Open Source Project
diff --git a/Shared/VersionAssemblyInfo.txt b/Shared/VersionAssemblyInfo.txt
deleted file mode 100644
index dfe846c..0000000
--- a/Shared/VersionAssemblyInfo.txt
+++ /dev/null
@@ -1 +0,0 @@
-2.0.27.22787
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
index 63ab527..1b13f0f 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -20,11 +20,15 @@ build:
verbosity: detailed
after_build:
- ps: .\.appveyor\appveyor.after-build.ps1
+test_script:
+- ps: ./.appveyor/appveyor.test.ps1
artifacts:
- path: '**\Managed.Adb.*.zip'
name: Zips
- path: '**\Managed.Adb.*.nupkg'
name: Nupkg
+- path: '*.coverage.xml'
+ name: Coverage
before_deploy:
- ps: .\.appveyor\appveyor.before-deployment.ps1
deploy:
@@ -34,6 +38,7 @@ deploy:
description: $(CI_RELEASE_DESCRIPTION)
auth_token:
secure: UEgy2H9zJKLi599QoO3qVf5BKFqloRQ246ez9cEgsfV3vooAUfVopMS9+IjRtArL
+ artifact: Zips
draft: true
force_update: true
on:
@@ -44,8 +49,21 @@ deploy:
secure: /M57OlSjcpugJFARA+j30alG5I+J1QxfRCDi5lWU3YhhzE1kxqLiAxtO+Bu7bQJt
artifact: Nupkg
on:
- branch: master
+ branch: /^(master|develop)$/
CI_DEPLOY_NUGET: True
+- provider: GitHub
+ tag: $(APPVEYOR_PROJECT_NAME)-v$(CI_BUILD_VERSION)-prerelease
+ release: $(APPVEYOR_PROJECT_NAME)-v$(CI_BUILD_VERSION)-prerelease
+ description: $(CI_RELEASE_DESCRIPTION)
+ auth_token:
+ secure: UEgy2H9zJKLi599QoO3qVf5BKFqloRQ246ez9cEgsfV3vooAUfVopMS9+IjRtArL
+ draft: true
+ artifact: Zips
+ prerelease: true
+ force_update: true
+ on:
+ branch: develop
+ CI_DEPLOY_GITHUB_PRE: True
after_deploy:
- ps: .\.appveyor\appveyor.after-deployment.ps1
notifications:
diff --git a/license.md b/license.md
index 9e49556..6989bd3 100644
--- a/license.md
+++ b/license.md
@@ -1,4 +1,5 @@
-Copyright 2015 Ryan Conrad
+Copyright 2010-2015 Ryan Conrad
+Copyright 2007 The Android Open Source Project (original Java project)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -10,4 +11,49 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
-limitations under the License.
\ No newline at end of file
+limitations under the License.
+
+Portions are:
+Copyright (c) 2004-2008 Jon Skeet and Marc Gravell
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. The end-user documentation included with the redistribution, if
+any, must include the following acknowledgment:
+
+"This product includes software developed by Jon Skeet
+and Marc Gravell. Contact skeet@pobox.com, or see
+http://www.pobox.com/~skeet/)."
+
+Alternately, this acknowledgment may appear in the software itself,
+if and wherever such third-party acknowledgments normally appear.
+
+4. The name "Miscellaneous Utility Library" must not be used to endorse
+or promote products derived from this software without prior written
+permission. For written permission, please contact skeet@pobox.com.
+
+5. Products derived from this software may not be called
+"Miscellaneous Utility Library", nor may "Miscellaneous Utility Library"
+appear in their name, without prior written permission of Jon Skeet.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL JON SKEET BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file