diff --git a/Mindscape.Raygun4Net.WebApi/RaygunWebApiDelegatingHandler.cs b/Mindscape.Raygun4Net.WebApi/RaygunWebApiDelegatingHandler.cs index cfd38bd6..8bb95446 100644 --- a/Mindscape.Raygun4Net.WebApi/RaygunWebApiDelegatingHandler.cs +++ b/Mindscape.Raygun4Net.WebApi/RaygunWebApiDelegatingHandler.cs @@ -7,15 +7,16 @@ namespace Mindscape.Raygun4Net.WebApi public class RaygunWebApiDelegatingHandler : DelegatingHandler { public const string RequestBodyKey = "Raygun.RequestBody"; + private const int MaxBytesToCapture = 4096; protected override async System.Threading.Tasks.Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { // ReadAsByteArrayAsync is always readable as it calls LoadIntoBufferAsync internally. var bytes = await request.Content.ReadAsByteArrayAsync(); - if (bytes.Length > 0) + if (bytes != null && bytes.Length > 0) { // Only take first 4096 bytes - var bytesToSend = bytes.Take(4096).ToArray(); + var bytesToSend = bytes.Take(MaxBytesToCapture).ToArray(); request.Properties[RequestBodyKey] = Encoding.UTF8.GetString(bytesToSend); } diff --git a/build.ps1 b/build.ps1 index 31cc12d9..590aed87 100644 --- a/build.ps1 +++ b/build.ps1 @@ -9,7 +9,6 @@ properties { $solution_file_webjob = "$root/Mindscape.Raygun4Net.Azure.WebJob.sln" $solution_file_webapi = "$root/Mindscape.Raygun4Net.WebApi.sln" $solution_file_winrt = "$root/Mindscape.Raygun4Net.WinRT.sln" - $solution_file_windows_phone = "$root/Mindscape.Raygun4Net.WindowsPhone.sln" $configuration = "Release" $build_dir = "$root\build\" $build_dir_client_profile = "$build_dir\Net3.ClientProfile" @@ -25,7 +24,7 @@ properties { $env:Path += ";$nunit_dir;$tools_dir;$nuget_dir" } -task default -depends Compile, CompileWinRT, CompileWindowsPhone +task default -depends Compile, CompileWinRT task Clean { remove-item -force -recurse $build_dir -ErrorAction SilentlyContinue | Out-Null @@ -57,11 +56,7 @@ task CompileWinRT -depends Init { remove-item -force -recurse $build_dir/Mindscape.Raygun4Net.WinRT.Tests -ErrorAction SilentlyContinue | Out-Null } -task CompileWindowsPhone -depends Init { - exec { msbuild "$solution_file_windows_phone" /m /p:OutDir=$build_dir /p:Configuration=$Configuration } -} - -task Test -depends Compile, CompileWinRT, CompileWindowsPhone, CompileWindowsStore { +task Test -depends Compile, CompileWinRT { $test_assemblies = Get-ChildItem $build_dir -Include *Tests.dll -Name Push-Location -Path $build_dir diff --git a/buildWindowsPhone.bat b/buildWindowsPhone.bat new file mode 100644 index 00000000..15262a1c --- /dev/null +++ b/buildWindowsPhone.bat @@ -0,0 +1,4 @@ +set EnableNuGetPackageRestore=true +call .\packages\psake.4.3.2\tools\psake.cmd buildWindowsPhone.ps1 %* + +pause \ No newline at end of file diff --git a/buildWindowsPhone.ps1 b/buildWindowsPhone.ps1 new file mode 100644 index 00000000..ca926086 --- /dev/null +++ b/buildWindowsPhone.ps1 @@ -0,0 +1,34 @@ +properties { + $root = $psake.build_script_dir + $solution_file = "$root/Mindscape.Raygun4Net.WindowsPhone.sln" + $configuration = "Release" + $build_dir = "$root\build\WindowsPhone\" + $nunit_dir = "$root\packages\NUnit.Runners.2.6.2\tools\" + $tools_dir = "$root\tools" + $nuget_dir = "$root\.nuget" + $env:Path += ";$nunit_dir;$tools_dir;$nuget_dir" +} + +task default -depends Compile + +task Clean { + remove-item -force -recurse $build_dir -ErrorAction SilentlyContinue | Out-Null +} + +task Init -depends Clean { + new-item $build_dir -itemType directory | Out-Null +} + +task Compile -depends Init { + exec { msbuild "$solution_file" /m /p:OutDir=$build_dir /p:Configuration=$Configuration } +} + +task Test -depends Compile { + $test_assemblies = Get-ChildItem $build_dir -Include *Tests.dll -Name + + Push-Location -Path $build_dir + + exec { nunit-console.exe $test_assemblies } + + Pop-Location +}