Convert System.Net.Http.Formatting WinRT assembly into portable library
This commit is contained in:
Родитель
7638b68b5b
Коммит
83169ad25a
|
@ -17,10 +17,6 @@
|
|||
<ReleaseRoot>.</ReleaseRoot>
|
||||
<BuildInParallel>$(BuildInParallel)</BuildInParallel>
|
||||
</SolutionsToBuild>
|
||||
<SolutionsToBuild Include="RuntimeRT.sln">
|
||||
<ReleaseRoot>.</ReleaseRoot>
|
||||
<BuildInParallel>$(BuildInParallel)</BuildInParallel>
|
||||
</SolutionsToBuild>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Integration" DependsOnTargets="Clean;Build;UnitTest" />
|
||||
|
@ -71,7 +67,7 @@
|
|||
|
||||
<Target Name = "RunTests">
|
||||
<ItemGroup>
|
||||
<TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.dll;bin\$(Configuration)\test\*.Test.*.dll" Exclude="**\SPA.Test.dll" />
|
||||
<TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.dll;bin\$(Configuration)\test\*.Test.*.dll;bin\$(Configuration)\Test\NetCore\*.Test.dll" Exclude="**\SPA.Test.dll" />
|
||||
<XunitProject Include="tools\WebStack.xunit.targets">
|
||||
<Properties>TestAssembly=%(TestDLLsXunit.FullPath);XmlPath=$(TestResultsDirectory)%(TestDLLsXunit.FileName)-XunitResults.xml</Properties>
|
||||
</XunitProject>
|
||||
|
|
18
Runtime.sln
18
Runtime.sln
|
@ -97,6 +97,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiHelpPage.VB.Test", "t
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Mvc.Facebook.Test", "test\Microsoft.AspNet.Mvc.Facebook.Test\Microsoft.AspNet.Mvc.Facebook.Test.csproj", "{C3BEF382-C7C4-454D-B017-1EAC03E9A82C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetCore", "src\System.Net.Http.Formatting.NetCore\System.Net.Http.Formatting.NetCore.csproj", "{C7060639-719B-4BD2-8A37-2F146B5A0668}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetCore.Test", "test\System.Net.Http.Formatting.NetCore.Test\System.Net.Http.Formatting.NetCore.Test.csproj", "{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeAnalysis|Any CPU = CodeAnalysis|Any CPU
|
||||
|
@ -380,6 +384,18 @@ Global
|
|||
{C3BEF382-C7C4-454D-B017-1EAC03E9A82C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3BEF382-C7C4-454D-B017-1EAC03E9A82C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3BEF382-C7C4-454D-B017-1EAC03E9A82C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -407,6 +423,7 @@ Global
|
|||
{8A607AC9-E7DD-4B74-A0B1-47FC95B9838B} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{821A136C-7C6F-44C6-A9E6-C39B5BFB1483} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{22075D5A-E9A1-4E2D-ABA7-8E7CBF2A049E} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{0BB62A1D-E6B5-49FA-9E3C-6AF679A66DFE} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{268DEE9D-F323-4A00-8ED8-3784388C3E3A} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{0F4870DB-A799-4DBA-99DF-0D74BB52FEC2} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
|
@ -431,5 +448,6 @@ Global
|
|||
{E22245AF-D5E1-46F6-B443-C886983EC50C} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{41D5691F-2720-44A0-9185-EEFE928D2679} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{C3BEF382-C7C4-454D-B017-1EAC03E9A82C} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetCore", "src\System.Net.Http.Formatting.NetCore\System.Net.Http.Formatting.NetCore.csproj", "{C7060639-719B-4BD2-8A37-2F146B5A0668}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeAnalysis|Any CPU = CodeAnalysis|Any CPU
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -2,6 +2,7 @@
|
|||
<repositories>
|
||||
<repository path="..\src\Microsoft.AspNet.Mvc.Facebook\packages.config" />
|
||||
<repository path="..\src\Microsoft.Web.WebPages.OAuth\packages.config" />
|
||||
<repository path="..\src\System.Net.Http.Formatting.NetCore\packages.config" />
|
||||
<repository path="..\src\System.Net.Http.Formatting\packages.config" />
|
||||
<repository path="..\src\System.Web.Http.OData\packages.config" />
|
||||
<repository path="..\src\System.Web.Http.SelfHost\packages.config" />
|
||||
|
@ -20,6 +21,7 @@
|
|||
<repository path="..\test\Microsoft.Web.Helpers.Test\packages.config" />
|
||||
<repository path="..\test\Microsoft.Web.Mvc.Test\packages.config" />
|
||||
<repository path="..\test\Microsoft.Web.WebPages.OAuth.Test\packages.config" />
|
||||
<repository path="..\test\System.Net.Http.Formatting.NetCore.Test\packages.config" />
|
||||
<repository path="..\test\System.Net.Http.Formatting.Test\packages.config" />
|
||||
<repository path="..\test\System.Web.Helpers.Test\packages.config" />
|
||||
<repository path="..\test\System.Web.Http.Integration.Test\packages.config" />
|
||||
|
|
|
@ -10,8 +10,9 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
#if !NOT_CLS_COMPLIANT
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
#endif
|
||||
[assembly: NeutralResourcesLanguage("en-US")]
|
||||
|
||||
// ===========================================================================
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Collections.Concurrent
|
||||
{
|
||||
// TODO: Remove this class after BCL makes their portable library version.
|
||||
internal sealed class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>
|
||||
{
|
||||
private Dictionary<TKey, TValue> _dictionary = new Dictionary<TKey, TValue>();
|
||||
private ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
|
||||
|
||||
public ICollection<TKey> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<TValue> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IDictionary)_dictionary).IsReadOnly;
|
||||
}
|
||||
}
|
||||
|
||||
public TValue this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
_lock.EnterReadLock();
|
||||
try
|
||||
{
|
||||
return _dictionary.ContainsKey(key);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// ConcurrentDictionary members
|
||||
public bool TryRemove(TKey key, out TValue removedValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public TValue GetOrAdd(TKey key, Func<TKey, TValue> addValueFactory)
|
||||
{
|
||||
_lock.EnterUpgradeableReadLock();
|
||||
try
|
||||
{
|
||||
TValue value;
|
||||
|
||||
if (_dictionary.ContainsKey(key))
|
||||
{
|
||||
return _dictionary[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
value = addValueFactory.Invoke(key);
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
_dictionary.Add(key, value);
|
||||
return value;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitUpgradeableReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryAdd(TKey key, TValue value)
|
||||
{
|
||||
_lock.EnterUpgradeableReadLock();
|
||||
try
|
||||
{
|
||||
if (_dictionary.ContainsKey(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
_dictionary.Add(key, value);
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitUpgradeableReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public TValue AddOrUpdate(TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
|
||||
{
|
||||
_lock.EnterUpgradeableReadLock();
|
||||
try
|
||||
{
|
||||
// update
|
||||
if (_dictionary.ContainsKey(key))
|
||||
{
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
_dictionary[key] = updateValueFactory.Invoke(key, _dictionary[key]);
|
||||
return _dictionary[key];
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
// add
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
_dictionary.Add(key, addValue);
|
||||
return addValue;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitUpgradeableReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,18 +9,19 @@
|
|||
<AssemblyName>System.Net.Http.Formatting</AssemblyName>
|
||||
<OutputPath>..\..\bin\$(Configuration)\NetCore\</OutputPath>
|
||||
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
|
||||
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC</DefineConstants>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<CodeAnalysisRuleSet>..\Strict.ruleset</CodeAnalysisRuleSet>
|
||||
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC;NOT_CLS_COMPLIANT</DefineConstants>
|
||||
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>Properties\CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Common\DictionaryExtensions.cs">
|
||||
<Link>Common\DictionaryExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Common\Error.cs">
|
||||
<Link>Common\Error.cs</Link>
|
||||
</Compile>
|
||||
|
@ -183,6 +184,7 @@
|
|||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Collections\Concurrent\ConcurrentDictionary.cs" />
|
||||
<Compile Include="MediaTypeHeaderValueExtensions.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -205,6 +207,7 @@
|
|||
<Link>Properties\Resources.resx</Link>
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -212,19 +215,23 @@
|
|||
<Link>CodeAnalysisDictionary.xml</Link>
|
||||
</CodeAnalysisDictionary>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.4.5.8\lib\winrt45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.4.5.11\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http">
|
||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.1.3-beta\lib\portable-net40+sl4+win8+wp71\System.Net.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Extensions">
|
||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.1.3-beta\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Primitives">
|
||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.1.3-beta\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
@ -233,4 +240,6 @@
|
|||
</Target>
|
||||
-->
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.0-rc\tools\Microsoft.Bcl.Build.targets" />
|
||||
</Project>
|
|
@ -1,4 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="4.5.8" targetFramework="winrt45" />
|
||||
<package id="Microsoft.Bcl" version="1.0.16-rc" targetFramework="portable-win+net45+wp80" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.0-rc" targetFramework="portable-win+net45+wp80" />
|
||||
<package id="Microsoft.Net.Http" version="2.1.3-beta" targetFramework="portable-win+net45+wp80" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="portable-win+net45+wp80" />
|
||||
</packages>
|
|
@ -25,7 +25,7 @@ namespace System.Net.Http.Formatting
|
|||
private JsonSerializerSettings _jsonSerializerSettings;
|
||||
private int _maxDepth = FormattingUtilities.DefaultMaxDepth;
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // DataContractJsonSerializer is not supported in portable library
|
||||
private ConcurrentDictionary<Type, DataContractJsonSerializer> _dataContractSerializerCache = new ConcurrentDictionary<Type, DataContractJsonSerializer>();
|
||||
private readonly IContractResolver _defaultContractResolver;
|
||||
private XmlDictionaryReaderQuotas _readerQuotas = FormattingUtilities.CreateDefaultReaderQuotas();
|
||||
|
@ -42,7 +42,7 @@ namespace System.Net.Http.Formatting
|
|||
SupportedMediaTypes.Add(MediaTypeConstants.TextJsonMediaType);
|
||||
|
||||
// Initialize serializer
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // DataContractJsonSerializer is not supported in portable library
|
||||
_defaultContractResolver = new JsonContractResolver(this);
|
||||
#endif
|
||||
_jsonSerializerSettings = CreateDefaultSerializerSettings();
|
||||
|
@ -51,7 +51,7 @@ namespace System.Net.Http.Formatting
|
|||
SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
|
||||
SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // MediaTypeMappings are not supported in portable library
|
||||
_requestHeaderMapping = new XmlHttpRequestHeaderMapping();
|
||||
MediaTypeMappings.Add(_requestHeaderMapping);
|
||||
#endif
|
||||
|
@ -91,7 +91,7 @@ namespace System.Net.Http.Formatting
|
|||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // DataContractJsonSerializer is not supported in portable library
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to use <see cref="DataContractJsonSerializer"/> by default.
|
||||
/// </summary>
|
||||
|
@ -106,7 +106,7 @@ namespace System.Net.Http.Formatting
|
|||
/// </summary>
|
||||
public bool Indent { get; set; }
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // MaxDepth not supported in portable library
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum depth allowed by this formatter.
|
||||
/// </summary>
|
||||
|
@ -137,7 +137,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
return new JsonSerializerSettings()
|
||||
{
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // no Contract resolver in portable libraries
|
||||
ContractResolver = _defaultContractResolver,
|
||||
#endif
|
||||
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||
|
@ -161,7 +161,7 @@ namespace System.Net.Http.Formatting
|
|||
throw Error.ArgumentNull("type");
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No DataContratJsonSerializer in portable library version
|
||||
if (UseDataContractJsonSerializer)
|
||||
{
|
||||
// If there is a registered non-null serializer, we can support this type.
|
||||
|
@ -191,7 +191,7 @@ namespace System.Net.Http.Formatting
|
|||
throw Error.ArgumentNull("type");
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No DataContratJsonSerializer in portable library version
|
||||
if (UseDataContractJsonSerializer)
|
||||
{
|
||||
MediaTypeFormatter.TryGetDelegatingTypeForIQueryableGenericOrSame(ref type);
|
||||
|
@ -246,7 +246,7 @@ namespace System.Net.Http.Formatting
|
|||
|
||||
try
|
||||
{
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No DataContratJsonSerializer in portable library version
|
||||
if (UseDataContractJsonSerializer)
|
||||
{
|
||||
DataContractJsonSerializer dataContractSerializer = GetDataContractSerializer(type);
|
||||
|
@ -310,7 +310,7 @@ namespace System.Net.Http.Formatting
|
|||
throw Error.ArgumentNull("writeStream");
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No DataContratJsonSerializer in portable library version
|
||||
if (UseDataContractJsonSerializer && Indent)
|
||||
{
|
||||
throw Error.NotSupported(Properties.Resources.UnsupportedIndent, typeof(DataContractJsonSerializer));
|
||||
|
@ -321,7 +321,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
Encoding effectiveEncoding = SelectCharacterEncoding(content == null ? null : content.Headers);
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No DataContratJsonSerializer in portable library version
|
||||
if (UseDataContractJsonSerializer)
|
||||
{
|
||||
if (MediaTypeFormatter.TryGetDelegatingTypeForIQueryableGenericOrSame(ref type))
|
||||
|
@ -355,7 +355,7 @@ namespace System.Net.Http.Formatting
|
|||
});
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No DataContratJsonSerializer in portable library version
|
||||
private static DataContractJsonSerializer CreateDataContractSerializer(Type type, bool throwOnError)
|
||||
{
|
||||
if (type == null)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
SupportedMediaTypes = new MediaTypeHeaderValueCollection();
|
||||
SupportedEncodings = new Collection<Encoding>();
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No MediaTypeMappings in portable library
|
||||
MediaTypeMappings = new Collection<MediaTypeMapping>();
|
||||
#endif
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ namespace System.Net.Http.Formatting
|
|||
/// </summary>
|
||||
public Collection<Encoding> SupportedEncodings { get; private set; }
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No MediaTypeMappings in portable library
|
||||
/// <summary>
|
||||
/// Gets the mutable collection of <see cref="MediaTypeMapping"/> elements used
|
||||
/// by this <see cref="MediaTypeFormatter"/> instance to determine the
|
||||
|
@ -160,29 +160,7 @@ namespace System.Net.Http.Formatting
|
|||
|
||||
private static int InitializeDefaultCollectionKeySize()
|
||||
{
|
||||
#if NETFX_CORE
|
||||
return Int32.MaxValue;
|
||||
#else
|
||||
// we first detect if we are running on 4.5, return Max value if we are.
|
||||
Type comparerType = Type.GetType(IWellKnownComparerTypeName, throwOnError: false);
|
||||
|
||||
if (comparerType != null)
|
||||
{
|
||||
return Int32.MaxValue;
|
||||
}
|
||||
|
||||
// we should try to read it from the AppSettings
|
||||
// if we found the aspnet settings configured, we will use that. Otherwise, we used the default
|
||||
NameValueCollection settings = ConfigurationManager.AppSettings;
|
||||
int result;
|
||||
|
||||
if (settings == null || !Int32.TryParse(settings["aspnet:MaxHttpCollectionKeys"], out result) || result < 0)
|
||||
{
|
||||
result = DefaultMaxHttpCollectionKeys;
|
||||
}
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace System.Net.Http.Formatting
|
|||
get { return Items.OfType<JsonMediaTypeFormatter>().FirstOrDefault(); }
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // FormUrlEncodedMediaTypeFormatter is not supported in portable library.
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MediaTypeFormatter"/> to use for <c>application/x-www-form-urlencoded</c> data.
|
||||
/// </summary>
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
return value == StringComparison.CurrentCulture ||
|
||||
value == StringComparison.CurrentCultureIgnoreCase ||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE
|
||||
value == StringComparison.InvariantCulture ||
|
||||
value == StringComparison.InvariantCultureIgnoreCase ||
|
||||
#endif
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace System.Net.Http.Formatting
|
|||
/// </summary>
|
||||
public bool Indent { get; set; }
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // MaxDepth is not supported in portable libraries
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum depth allowed by this formatter.
|
||||
/// </summary>
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace System.Net.Http
|
|||
/// </summary>
|
||||
public static readonly Type QueryableInterfaceGenericType = typeof(IQueryable<>);
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // XsdDataContractExporter is not supported in portable libraries
|
||||
/// <summary>
|
||||
/// An instance of <see cref="XsdDataContractExporter"/>.
|
||||
/// </summary>
|
||||
|
@ -164,7 +164,7 @@ namespace System.Net.Http
|
|||
/// <returns></returns>
|
||||
public static XmlDictionaryReaderQuotas CreateDefaultReaderQuotas()
|
||||
{
|
||||
#if NETFX_CORE
|
||||
#if NETFX_CORE // On core we set the max Quota
|
||||
return XmlDictionaryReaderQuotas.Max;
|
||||
#else
|
||||
return new XmlDictionaryReaderQuotas()
|
||||
|
|
|
@ -60,14 +60,13 @@ namespace System.Net.Http.Handlers
|
|||
return byteRead;
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
int readCount = await InnerStream.ReadAsync(buffer, offset, count, cancellationToken);
|
||||
ReportBytesReceived(readCount, userState: null);
|
||||
return readCount;
|
||||
}
|
||||
#else
|
||||
#if !NETFX_CORE // BeginX and EndX are not supported on streams in portable libraries
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return InnerStream.BeginRead(buffer, offset, count, callback, state);
|
||||
|
@ -93,13 +92,13 @@ namespace System.Net.Http.Handlers
|
|||
ReportBytesSent(1, userState: null);
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
await InnerStream.WriteAsync(buffer, offset, count, cancellationToken);
|
||||
ReportBytesSent(count, userState: null);
|
||||
}
|
||||
#else
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX are not supported on streams in portable libraries
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return new ProgressWriteAsyncResult(InnerStream, this, buffer, offset, count, callback, state);
|
||||
|
|
|
@ -21,11 +21,6 @@ namespace System.Net.Http
|
|||
private const int MinBufferSize = 256;
|
||||
private const int DefaultBufferSize = 32 * 1024;
|
||||
|
||||
#if !NETFX_CORE
|
||||
private static readonly AsyncCallback _onMultipartReadAsyncComplete = new AsyncCallback(OnMultipartReadAsyncComplete);
|
||||
private static readonly AsyncCallback _onMultipartWriteSegmentAsyncComplete = new AsyncCallback(OnMultipartWriteSegmentAsyncComplete);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified content is MIME multipart content.
|
||||
/// </summary>
|
||||
|
@ -103,7 +98,6 @@ namespace System.Net.Http
|
|||
/// <param name="streamProvider">A stream provider providing output streams for where to write body parts as they are parsed.</param>
|
||||
/// <param name="bufferSize">Size of the buffer used to read the contents.</param>
|
||||
/// <returns>A <see cref="Task{T}"/> representing the tasks of getting the result of reading the MIME content.</returns>
|
||||
#if NETFX_CORE
|
||||
public static async Task<T> ReadAsMultipartAsync<T>(this HttpContent content, T streamProvider, int bufferSize) where T : MultipartStreamProvider
|
||||
{
|
||||
if (content == null)
|
||||
|
@ -121,275 +115,100 @@ namespace System.Net.Http
|
|||
throw Error.ArgumentMustBeGreaterThanOrEqualTo("bufferSize", bufferSize, MinBufferSize);
|
||||
}
|
||||
|
||||
Stream stream = null;
|
||||
try
|
||||
{
|
||||
Stream stream = await content.ReadAsStreamAsync();
|
||||
List<HttpContent> childContents = new List<HttpContent>();
|
||||
try
|
||||
{
|
||||
stream = await content.ReadAsStreamAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IOException(Properties.Resources.ReadAsMimeMultipartErrorReading, e);
|
||||
}
|
||||
|
||||
using (var parser = new MimeMultipartBodyPartParser(content, streamProvider))
|
||||
{
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
bool finalPart = false;
|
||||
byte[] data = new byte[bufferSize];
|
||||
MultipartAsyncContext context = new MultipartAsyncContext(content, stream, parser, data, streamProvider.Contents);
|
||||
|
||||
while (!finalPart)
|
||||
{
|
||||
int readCount = await stream.ReadAsync(buffer, 0, buffer.Length);
|
||||
|
||||
// The parser returns one or more parsed parts, depending on how much data was returned
|
||||
// from the network read. The last part may be incomplete (partial), so we only dispose
|
||||
// of the parts once we know they're finished. Regardless of whether the part is complete
|
||||
// or not, we send the bytes to the desired output stream. We loop back for more data
|
||||
// until we've completely read the complete, final part.
|
||||
foreach (MimeBodyPart part in parser.ParseBuffer(buffer, readCount))
|
||||
{
|
||||
try
|
||||
{
|
||||
Stream output = part.GetOutputStream(content);
|
||||
|
||||
foreach (ArraySegment<byte> segment in part.Segments)
|
||||
{
|
||||
await output.WriteAsync(segment.Array, segment.Offset, segment.Count);
|
||||
}
|
||||
|
||||
if (part.IsComplete)
|
||||
{
|
||||
if (part.HttpContent != null)
|
||||
{
|
||||
childContents.Add(part.HttpContent);
|
||||
}
|
||||
|
||||
finalPart = part.IsFinal;
|
||||
part.Dispose();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Clean up the part if we got an error in the middle of parsing, because we normally
|
||||
// won't dispose a part until it's complete.
|
||||
part.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Start async read/write loop
|
||||
await MultipartReadAsync(context);
|
||||
|
||||
// Let the stream provider post-process when everything is complete
|
||||
await streamProvider.ExecutePostProcessingAsync();
|
||||
return streamProvider;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
stream.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task MultipartReadAsync(MultipartAsyncContext context)
|
||||
{
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
int bytesRead = 0;
|
||||
try
|
||||
{
|
||||
bytesRead = await context.ContentStream.ReadAsync(context.Data, 0, context.Data.Length);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IOException(Properties.Resources.ReadAsMimeMultipartErrorReading, e);
|
||||
}
|
||||
}
|
||||
#else
|
||||
public static Task<T> ReadAsMultipartAsync<T>(this HttpContent content, T streamProvider, int bufferSize) where T : MultipartStreamProvider
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
throw Error.ArgumentNull("content");
|
||||
}
|
||||
|
||||
if (streamProvider == null)
|
||||
{
|
||||
throw Error.ArgumentNull("streamProvider");
|
||||
}
|
||||
|
||||
if (bufferSize < MinBufferSize)
|
||||
{
|
||||
throw Error.ArgumentMustBeGreaterThanOrEqualTo("bufferSize", bufferSize, MinBufferSize);
|
||||
}
|
||||
|
||||
MimeMultipartBodyPartParser parser = null;
|
||||
return content.ReadAsStreamAsync().Then(stream =>
|
||||
{
|
||||
TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
parser = new MimeMultipartBodyPartParser(content, streamProvider);
|
||||
byte[] data = new byte[bufferSize];
|
||||
MultipartAsyncContext context = new MultipartAsyncContext(content, stream, taskCompletionSource, parser, data, streamProvider.Contents);
|
||||
|
||||
// Start async read/write loop
|
||||
MultipartReadAsync(context);
|
||||
|
||||
// Return task and complete when we have run the post processing step.
|
||||
return taskCompletionSource.Task.Then(() => streamProvider.ExecutePostProcessingAsync().ToTask<T>(result: streamProvider));
|
||||
}).Finally(() =>
|
||||
{
|
||||
if (parser != null)
|
||||
{
|
||||
parser.Dispose();
|
||||
}
|
||||
}, runSynchronously: true);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void MultipartReadAsync(MultipartAsyncContext context)
|
||||
{
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
IAsyncResult result = null;
|
||||
try
|
||||
{
|
||||
result = context.ContentStream.BeginRead(context.Data, 0, context.Data.Length, _onMultipartReadAsyncComplete, context);
|
||||
if (result.CompletedSynchronously)
|
||||
{
|
||||
MultipartReadAsyncComplete(result);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Exception exception = (result != null && result.CompletedSynchronously) ? e : new IOException(Properties.Resources.ReadAsMimeMultipartErrorReading, e);
|
||||
context.TaskCompletionSource.TrySetException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void OnMultipartReadAsyncComplete(IAsyncResult result)
|
||||
{
|
||||
if (result.CompletedSynchronously)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MultipartAsyncContext context = (MultipartAsyncContext)result.AsyncState;
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
try
|
||||
{
|
||||
MultipartReadAsyncComplete(result);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.TaskCompletionSource.TrySetException(e);
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void MultipartReadAsyncComplete(IAsyncResult result)
|
||||
{
|
||||
Contract.Assert(result != null, "result cannot be null");
|
||||
MultipartAsyncContext context = (MultipartAsyncContext)result.AsyncState;
|
||||
int bytesRead = 0;
|
||||
|
||||
try
|
||||
{
|
||||
bytesRead = context.ContentStream.EndRead(result);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.TaskCompletionSource.TrySetException(new IOException(Properties.Resources.ReadAsMimeMultipartErrorReading, e));
|
||||
}
|
||||
|
||||
IEnumerable<MimeBodyPart> parts = context.MimeParser.ParseBuffer(context.Data, bytesRead);
|
||||
context.PartsEnumerator = parts.GetEnumerator();
|
||||
MoveNextPart(context);
|
||||
await MoveToNextPartAsync(context);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void MultipartWriteSegmentAsync(MultipartAsyncContext context)
|
||||
private static async Task MoveToNextPartAsync(MultipartAsyncContext context)
|
||||
{
|
||||
Contract.Assert(context != null, "context cannot be null.");
|
||||
Stream output = context.PartsEnumerator.Current.GetOutputStream(context.Parent);
|
||||
ArraySegment<byte> segment = (ArraySegment<byte>)context.SegmentsEnumerator.Current;
|
||||
try
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
while (context.PartsEnumerator.MoveNext())
|
||||
{
|
||||
IAsyncResult result = output.BeginWrite(segment.Array, segment.Offset, segment.Count, _onMultipartWriteSegmentAsyncComplete, context);
|
||||
if (result.CompletedSynchronously)
|
||||
context.SegmentsEnumerator = context.PartsEnumerator.Current.Segments.GetEnumerator();
|
||||
if (await MoveToNextSegmentAsync(context))
|
||||
{
|
||||
MultipartWriteSegmentAsyncComplete(result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.PartsEnumerator.Current.Dispose();
|
||||
context.TaskCompletionSource.TrySetException(new IOException(Properties.Resources.ReadAsMimeMultipartErrorWriting, e));
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnMultipartWriteSegmentAsyncComplete(IAsyncResult result)
|
||||
{
|
||||
if (result.CompletedSynchronously)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MultipartWriteSegmentAsyncComplete(result);
|
||||
await MultipartReadAsync(context);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void MultipartWriteSegmentAsyncComplete(IAsyncResult result)
|
||||
private static async Task<bool> MoveToNextSegmentAsync(MultipartAsyncContext context)
|
||||
{
|
||||
Contract.Assert(result != null, "result cannot be null.");
|
||||
MultipartAsyncContext context = (MultipartAsyncContext)result.AsyncState;
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
|
||||
MimeBodyPart part = context.PartsEnumerator.Current;
|
||||
try
|
||||
if (context.SegmentsEnumerator.MoveNext())
|
||||
{
|
||||
Stream output = context.PartsEnumerator.Current.GetOutputStream(context.Parent);
|
||||
output.EndWrite(result);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
part.Dispose();
|
||||
context.TaskCompletionSource.TrySetException(new IOException(Properties.Resources.ReadAsMimeMultipartErrorWriting, e));
|
||||
}
|
||||
|
||||
if (!MoveNextSegment(context))
|
||||
{
|
||||
MoveNextPart(context);
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void MoveNextPart(MultipartAsyncContext context)
|
||||
{
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
try
|
||||
{
|
||||
while (context.PartsEnumerator.MoveNext())
|
||||
try
|
||||
{
|
||||
context.SegmentsEnumerator = context.PartsEnumerator.Current.Segments.GetEnumerator();
|
||||
if (MoveNextSegment(context))
|
||||
ArraySegment<byte> segment = (ArraySegment<byte>)context.SegmentsEnumerator.Current;
|
||||
await output.WriteAsync(segment.Array, segment.Offset, segment.Count);
|
||||
|
||||
if (!await MoveToNextSegmentAsync(context))
|
||||
{
|
||||
return;
|
||||
await MoveToNextPartAsync(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.TaskCompletionSource.TrySetException(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Read some more
|
||||
MultipartReadAsync(context);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static bool MoveNextSegment(MultipartAsyncContext context)
|
||||
{
|
||||
Contract.Assert(context != null, "context cannot be null");
|
||||
try
|
||||
{
|
||||
if (context.SegmentsEnumerator.MoveNext())
|
||||
{
|
||||
MultipartWriteSegmentAsync(context);
|
||||
return true;
|
||||
}
|
||||
else if (CheckPartCompletion(context.PartsEnumerator.Current, context.Result))
|
||||
catch (Exception e)
|
||||
{
|
||||
// We are done parsing
|
||||
context.TaskCompletionSource.TrySetResult(true);
|
||||
return true;
|
||||
context.PartsEnumerator.Current.Dispose();
|
||||
throw new IOException(Properties.Resources.ReadAsMimeMultipartErrorWriting, e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.TaskCompletionSource.TrySetException(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return CheckPartCompletion(context.PartsEnumerator.Current, context.Result);
|
||||
}
|
||||
|
||||
private static bool CheckPartCompletion(MimeBodyPart part, ICollection<HttpContent> result)
|
||||
|
@ -416,18 +235,16 @@ namespace System.Net.Http
|
|||
/// </summary>
|
||||
private class MultipartAsyncContext
|
||||
{
|
||||
public MultipartAsyncContext(HttpContent parent, Stream contentStream, TaskCompletionSource<bool> taskCompletionSource, MimeMultipartBodyPartParser mimeParser, byte[] data, ICollection<HttpContent> result)
|
||||
public MultipartAsyncContext(HttpContent parent, Stream contentStream, MimeMultipartBodyPartParser mimeParser, byte[] data, ICollection<HttpContent> result)
|
||||
{
|
||||
Contract.Assert(parent != null);
|
||||
Contract.Assert(contentStream != null);
|
||||
Contract.Assert(taskCompletionSource != null);
|
||||
Contract.Assert(mimeParser != null);
|
||||
Contract.Assert(data != null);
|
||||
|
||||
Parent = parent;
|
||||
ContentStream = contentStream;
|
||||
Result = result;
|
||||
TaskCompletionSource = taskCompletionSource;
|
||||
MimeParser = mimeParser;
|
||||
Data = data;
|
||||
}
|
||||
|
@ -447,11 +264,6 @@ namespace System.Net.Http
|
|||
/// </summary>
|
||||
public ICollection<HttpContent> Result { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the task completion source managing when we are done parsing the MIME multipart message
|
||||
/// </summary>
|
||||
public TaskCompletionSource<bool> TaskCompletionSource { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The data buffer that we use for reading data from the input stream into before processing.
|
||||
/// </summary>
|
||||
|
@ -472,6 +284,5 @@ namespace System.Net.Http
|
|||
/// </summary>
|
||||
public IEnumerator SegmentsEnumerator { get; set; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ namespace System.Net.Http
|
|||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // No Begin/EndX in portable libraries
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is propagated.")]
|
||||
private static void OnWriteComplete(IAsyncResult result)
|
||||
{
|
||||
|
@ -421,7 +421,7 @@ namespace System.Net.Http
|
|||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
#if !NETFX_CORE // not used due to no Begin/End Support
|
||||
private Task<HttpContent> PrepareContentAsync()
|
||||
{
|
||||
if (Content == null)
|
||||
|
|
|
@ -91,12 +91,12 @@ namespace System.Net.Http.Internal
|
|||
return _innerStream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return _innerStream.ReadAsync(buffer, offset, count, cancellationToken);
|
||||
}
|
||||
#else
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return _innerStream.BeginRead(buffer, offset, count, callback, state);
|
||||
|
@ -118,7 +118,6 @@ namespace System.Net.Http.Internal
|
|||
_innerStream.Flush();
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
|
||||
{
|
||||
return _innerStream.CopyToAsync(destination, bufferSize, cancellationToken);
|
||||
|
@ -128,7 +127,6 @@ namespace System.Net.Http.Internal
|
|||
{
|
||||
return _innerStream.FlushAsync(cancellationToken);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
|
@ -140,12 +138,12 @@ namespace System.Net.Http.Internal
|
|||
_innerStream.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return _innerStream.WriteAsync(buffer, offset, count, cancellationToken);
|
||||
}
|
||||
#else
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
return _innerStream.BeginWrite(buffer, offset, count, callback, state);
|
||||
|
|
|
@ -14,9 +14,7 @@ namespace System.Net.Http.Internal
|
|||
/// </summary>
|
||||
internal class ReadOnlyStreamWithEncodingPreamble : Stream
|
||||
{
|
||||
#if NETFX_CORE
|
||||
private static Task<int> _cancelledTask = GetCancelledTask();
|
||||
#endif
|
||||
private Stream _innerStream;
|
||||
private ArraySegment<byte> _remainingBytes;
|
||||
|
||||
|
@ -108,14 +106,12 @@ namespace System.Net.Http.Internal
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
private static Task<int> GetCancelledTask()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<int>();
|
||||
tcs.SetCanceled();
|
||||
return tcs.Task;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
|
@ -146,7 +142,6 @@ namespace System.Net.Http.Internal
|
|||
return result;
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_remainingBytes.Array == null)
|
||||
|
@ -160,7 +155,6 @@ namespace System.Net.Http.Internal
|
|||
|
||||
return Task.FromResult(Read(buffer, offset, count));
|
||||
}
|
||||
#endif
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
|
|
|
@ -10,6 +10,10 @@ using System.Runtime.InteropServices;
|
|||
|
||||
[assembly: AssemblyTitle("System.Net.Http.Formatting")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
#if !NETFX_CORE // GuidAttibute is not supported in portable libraries
|
||||
[assembly: Guid("7fa1ae84-36e2-46b6-812c-c985a8e65e9a")]
|
||||
[assembly: InternalsVisibleTo("System.Net.Http.Formatting.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
|
||||
[assembly: InternalsVisibleTo("System.Net.Http.Formatting.Test.Integration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
|
||||
#else
|
||||
[assembly: InternalsVisibleTo("System.Net.Http.Formatting.NetCore.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
|
||||
#endif
|
||||
|
|
|
@ -109,8 +109,9 @@ namespace System.Net.Http
|
|||
#if NETFX_CORE
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
// Note we don't call dipose on the inner stream as the stream will get disposed when this
|
||||
// HttpContent instance is disposed.
|
||||
_serializeToStreamTask.TrySetResult(true);
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#else
|
||||
public override void Close()
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>Properties\CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Common\DictionaryExtensions.cs">
|
||||
<Link>Common\DictionaryExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Common\Error.cs">
|
||||
<Link>Common\Error.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -29,7 +29,14 @@ namespace Microsoft.TestCommon
|
|||
Array values = Enum.GetValues(typeof(TEnum));
|
||||
foreach (object value in values)
|
||||
{
|
||||
Assert.True(_isDefined((TEnum)value));
|
||||
if (ValueExistsForFramework((TEnum)value))
|
||||
{
|
||||
Assert.True(_isDefined((TEnum)value));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.False(_isDefined((TEnum)value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,19 +52,37 @@ namespace Microsoft.TestCommon
|
|||
Array values = Enum.GetValues(typeof(TEnum));
|
||||
foreach (object value in values)
|
||||
{
|
||||
_validate((TEnum)value, "parameter");
|
||||
if (ValueExistsForFramework((TEnum)value))
|
||||
{
|
||||
_validate((TEnum)value, "parameter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_ThrowsForUndefinedValues()
|
||||
{
|
||||
Assert.ThrowsInvalidEnumArgument(
|
||||
AssertForUndefinedValue(
|
||||
() => _validate(_undefined, "parameter"),
|
||||
"parameter",
|
||||
(int)Convert.ChangeType(_undefined, typeof(int)),
|
||||
typeof(TEnum),
|
||||
allowDerivedExceptions: false);
|
||||
}
|
||||
|
||||
protected virtual void AssertForUndefinedValue(Action testCode, string parameterName, int invalidValue, Type enumType, bool allowDerivedExceptions = false)
|
||||
{
|
||||
Assert.ThrowsInvalidEnumArgument(
|
||||
testCode,
|
||||
parameterName,
|
||||
invalidValue,
|
||||
enumType,
|
||||
allowDerivedExceptions);
|
||||
}
|
||||
|
||||
protected virtual bool ValueExistsForFramework(TEnum value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,276 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>System.Net.Http</RootNamespace>
|
||||
<AssemblyName>System.Net.Http.Formatting.NetCore.Test</AssemblyName>
|
||||
<OutputPath>..\..\bin\$(Configuration)\Test\NetCore\</OutputPath>
|
||||
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Extensions">
|
||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.1.3-beta\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Primitives">
|
||||
<HintPath>..\..\packages\Microsoft.Net.Http.2.1.3-beta\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.XML" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
|
||||
<Aliases>unused</Aliases>
|
||||
</Reference>
|
||||
<Reference Include="xunit.extensions, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll</HintPath>
|
||||
<Aliases>unused</Aliases>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||
<Visible>False</Visible>
|
||||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\JsonNetSerializationTest.cs">
|
||||
<Link>Formatting\JsonNetSerializationTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\JsonNetValidationTest.cs">
|
||||
<Link>Formatting\JsonNetValidationTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\JTokenCreatorSurrogate.cs">
|
||||
<Link>Formatting\JTokenCreatorSurrogate.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\JTokenRoundTripComparer.cs">
|
||||
<Link>Formatting\JTokenRoundTripComparer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Internal\ReadOnlyStreamWithEncodingPreambleTest.cs">
|
||||
<Link>Internal\ReadOnlyStreamWithEncodingPreambleTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\MimeBodyPartTest.cs">
|
||||
<Link>MimeBodyPartTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpHeaderExtensionsTest.cs">
|
||||
<Link>HttpHeaderExtensionsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpUnsortedResponseTest.cs">
|
||||
<Link>HttpUnsortedResponseTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpUnsortedRequestTest.cs">
|
||||
<Link>HttpUnsortedRequestTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\StringComparisonHelperTest.cs">
|
||||
<Link>SFormatting\tringComparisonHelperTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockAsyncCallback.cs">
|
||||
<Link>Mocks\MockAsyncCallback.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockCompletedAsyncResult.cs">
|
||||
<Link>Mocks\MockCompletedAsyncResult.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpClientFactoryTest.cs">
|
||||
<Link>HttpClientFactoryTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Handlers\ProgressContentTest.cs">
|
||||
<Link>Handlers\ProgressContentTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Handlers\ProgressStreamTest.cs">
|
||||
<Link>Handlers\ProgressStreamTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Handlers\HttpProgressEventArgsTest.cs">
|
||||
<Link>Handlers\HttpProgressEventArgsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\MultipartRelatedStreamProviderTests.cs">
|
||||
<Link>MultipartRelatedStreamProviderTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\MultipartStreamProviderTestBase.cs">
|
||||
<Link>MultipartStreamProviderTestBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\MultipartFileDataTest.cs">
|
||||
<Link>MultipartFileDataTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DataContractEnum.cs">
|
||||
<Link>DataSets\Types\DataContractEnum.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DataContractType.cs">
|
||||
<Link>DataSets\Types\DataContractType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DerivedDataContractType.cs">
|
||||
<Link>DataSets\Types\DerivedDataContractType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DerivedJsonMediaTypeFormatter.cs">
|
||||
<Link>DataSets\Types\DerivedJsonMediaTypeFormatter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DerivedWcfPocoType.cs">
|
||||
<Link>DataSets\Types\DerivedWcfPocoType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DerivedXmlMediaTypeFormatter.cs">
|
||||
<Link>DataSets\Types\DerivedXmlMediaTypeFormatter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\DerivedXmlSerializableType.cs">
|
||||
<Link>DataSets\Types\DerivedXmlSerializableType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\HttpTestData.cs">
|
||||
<Link>DataSets\HttpTestData.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\INotJsonSerializable.cs">
|
||||
<Link>DataSets\Types\INotJsonSerializable.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\WcfPocoType.cs">
|
||||
<Link>DataSets\Types\WcfPocoType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\DataSets\Types\XmlSerializableType.cs">
|
||||
<Link>DataSets\Types\XmlSerializableType.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\DataContractJsonMediaTypeFormatterTests.cs">
|
||||
<Link>Formatting\DataContractJsonMediaTypeFormatterTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\SerializerConsistencyTests.cs">
|
||||
<Link>Formatting\SerializerConsistencyTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\XmlSerializerMediaTypeFormatterTests.cs">
|
||||
<Link>Formatting\XmlSerializerMediaTypeFormatterTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\MediaTypeFormatterTestBase.cs">
|
||||
<Link>Formatting\MediaTypeFormatterTestBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpClientExtensionsTest.cs">
|
||||
<Link>HttpClientExtensionsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Internal\AsyncResultTest.cs">
|
||||
<Link>Internal\AsyncResultTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Internal\DelegatingStreamTest.cs">
|
||||
<Link>Internal\DelegatingStreamTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockDelegatingHandler.cs">
|
||||
<Link>Mocks\MockDelegatingHandler.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockDelegatingStream.cs">
|
||||
<Link>Mocks\MockDelegatingStream.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockProgressEventHandler.cs">
|
||||
<Link>Mocks\MockProgressEventHandler.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\TestableHttpMessageHandler.cs">
|
||||
<Link>Mocks\TestableHttpMessageHandler.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\UriQueryDataSet.cs">
|
||||
<Link>UriQueryDataSet.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\FormattingUtilitiesTests.cs">
|
||||
<Link>FormattingUtilitiesTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\JsonMediaTypeFormatterTests.cs">
|
||||
<Link>Formatting\JsonMediaTypeFormatterTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\MediaTypeConstantsTests.cs">
|
||||
<Link>Formatting\MediaTypeConstantsTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\MediaTypeFormatterCollectionTests.cs">
|
||||
<Link>Formatting\MediaTypeFormatterCollectionTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\MediaTypeFormatterTests.cs">
|
||||
<Link>Formatting\MediaTypeFormatterTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\MediaTypeHeaderValueExtensionsTests.cs">
|
||||
<Link>Formatting\MediaTypeHeaderValueExtensionsTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\ParsedMediaTypeHeaderValueTests.cs">
|
||||
<Link>Formatting\ParsedMediaTypeHeaderValueTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\XmlMediaTypeFormatterTests.cs">
|
||||
<Link>Formatting\XmlMediaTypeFormatterTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpContentMessageExtensionsTests.cs">
|
||||
<Link>HttpContentMessageExtensionsTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpContentMultipartExtensionsTests.cs">
|
||||
<Link>HttpContentMultipartExtensionsTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpMessageContentTests.cs">
|
||||
<Link>HttpMessageContentTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\Parsers\HttpRequestHeaderParserTests.cs">
|
||||
<Link>Formatting\Parsers\HttpRequestHeaderParserTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\Parsers\HttpRequestLineParserTests.cs">
|
||||
<Link>Formatting\Parsers\HttpRequestLineParserTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\Parsers\HttpResponseHeaderParserTests.cs">
|
||||
<Link>Formatting\Parsers\HttpResponseHeaderParserTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\Parsers\HttpStatusLineParserTests.cs">
|
||||
<Link>Formatting\Parsers\HttpStatusLineParserTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\Parsers\InternetMessageFormatHeaderParserTests.cs">
|
||||
<Link>Formatting\Parsers\InternetMessageFormatHeaderParserTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Formatting\Parsers\MimeMultipartParserTests.cs">
|
||||
<Link>Formatting\Parsers\MimeMultipartParserTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\MultipartMemoryStreamProviderTests.cs">
|
||||
<Link>MultipartMemoryStreamProviderTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\ObjectContentOfTTests.cs">
|
||||
<Link>ObjectContentOfTTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\ObjectContentTests.cs">
|
||||
<Link>ObjectContentTests.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\ParserData.cs">
|
||||
<Link>ParserData.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockHttpContent.cs">
|
||||
<Link>Mocks\MockHttpContent.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Mocks\MockMediaTypeFormatter.cs">
|
||||
<Link>Mocks\MockMediaTypeFormatter.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\HttpContentExtensionsTest.cs">
|
||||
<Link>HttpContentExtensionsTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\PushStreamContentTest.cs">
|
||||
<Link>PushStreamContentTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\System.Net.Http.Formatting.Test\Handlers\ProgressMessageHandlerTest.cs">
|
||||
<Link>PushStreamContentTest.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\System.Net.Http.Formatting.NetCore\System.Net.Http.Formatting.NetCore.csproj">
|
||||
<Project>{C7060639-719B-4BD2-8A37-2F146B5A0668}</Project>
|
||||
<Name>System.Net.Http.Formatting</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.TestCommon\Microsoft.TestCommon.csproj">
|
||||
<Project>{FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0}</Project>
|
||||
<Name>Microsoft.TestCommon</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Net.Http" version="2.1.3-beta" targetFramework="net45" />
|
||||
<package id="Moq" version="4.0.10827" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
|
||||
<package id="xunit" version="1.9.1" targetFramework="net45" />
|
||||
<package id="xunit.extensions" version="1.9.1" targetFramework="net45" />
|
||||
</packages>
|
|
@ -340,6 +340,7 @@ namespace System.Net.Http.Formatting.DataSets
|
|||
|
||||
//// TODO: make this list compose from other data?
|
||||
// Collection of legal instances of all standard MediaTypeMapping types
|
||||
#if !NETFX_CORE // not present in portable library version
|
||||
public static TestData<MediaTypeMapping> StandardMediaTypeMappings
|
||||
{
|
||||
get
|
||||
|
@ -358,6 +359,7 @@ namespace System.Net.Http.Formatting.DataSets
|
|||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static TestData<string> LegalUriPathExtensions
|
||||
{
|
||||
|
@ -484,7 +486,9 @@ namespace System.Net.Http.Formatting.DataSets
|
|||
{
|
||||
new XmlMediaTypeFormatter(),
|
||||
new JsonMediaTypeFormatter(),
|
||||
#if !NETFX_CORE // not present in portable library version
|
||||
new FormUrlEncodedMediaTypeFormatter()
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +509,9 @@ namespace System.Net.Http.Formatting.DataSets
|
|||
{
|
||||
new DerivedXmlMediaTypeFormatter(),
|
||||
new DerivedJsonMediaTypeFormatter(),
|
||||
#if !NETFX_CORE // not present in portable library version
|
||||
new DerivedFormUrlEncodedMediaTypeFormatter(),
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
public DataContractJsonMediaTypeFormatter()
|
||||
{
|
||||
#if !NETFX_CORE // DataContractJsonSerializer is not supported in portable library
|
||||
UseDataContractJsonSerializer = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,6 +65,7 @@ namespace System.Net.Http.Formatting
|
|||
expectedDefaultValue: false);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // We don't support MaxDepth in the portable library
|
||||
[Fact]
|
||||
public void MaxDepth_RoundTrips()
|
||||
{
|
||||
|
@ -76,6 +79,7 @@ namespace System.Net.Http.Formatting
|
|||
illegalUpperValue: null,
|
||||
roundTripTestValue: 256);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Theory]
|
||||
[TestDataSet(typeof(CommonUnitTestDataSets), "RepresentativeValueAndRefTypeTestDataCollection")]
|
||||
|
@ -94,12 +98,18 @@ namespace System.Net.Http.Formatting
|
|||
Assert.False(isSerializable != canSupport && isSerializable, String.Format("2nd CanReadType returned wrong value for '{0}'.", variationType));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void CanReadType_ReturnsFalse_ForInvalidDataContracts()
|
||||
{
|
||||
JsonMediaTypeFormatter formatter = new DataContractJsonMediaTypeFormatter();
|
||||
|
||||
#if !NETFX_CORE
|
||||
Assert.False(formatter.CanReadType(typeof(InvalidDataContract)));
|
||||
#else
|
||||
// The formatter is unable to positively identify non readable types, so true is always returned
|
||||
Assert.True(formatter.CanReadType(typeof(InvalidDataContract)));
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -107,9 +117,15 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
JsonMediaTypeFormatter formatter = new DataContractJsonMediaTypeFormatter();
|
||||
|
||||
#if !NETFX_CORE
|
||||
Assert.False(formatter.CanWriteType(typeof(InvalidDataContract)));
|
||||
#else
|
||||
// The formatter is unable to positively identify non readable types, so true is always returned
|
||||
Assert.True(formatter.CanWriteType(typeof(InvalidDataContract)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public class InvalidDataContract
|
||||
{
|
||||
// removing the default ctor makes this invalid
|
||||
|
@ -157,7 +173,7 @@ namespace System.Net.Http.Formatting
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void UseDataContractJsonSerializer_True()
|
||||
public void UseDataContractJsonSerializer_Default()
|
||||
{
|
||||
DataContractJsonMediaTypeFormatter jsonFormatter = new DataContractJsonMediaTypeFormatter();
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
|
@ -168,6 +184,7 @@ namespace System.Net.Http.Formatting
|
|||
Assert.False(serializedString.Contains("\r\n"), "Using DCJS should emit data without indentation by default.");
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // Indent won't throw on portable libraries because UDCJS is not available, so this test is not needed
|
||||
[Fact]
|
||||
public void UseDataContractJsonSerializer_True_Indent_Throws()
|
||||
{
|
||||
|
@ -179,6 +196,7 @@ namespace System.Net.Http.Formatting
|
|||
new SampleType(),
|
||||
memoryStream, content, transportContext: null));
|
||||
}
|
||||
#endif
|
||||
|
||||
[Theory]
|
||||
[TestDataSet(typeof(HttpTestData), "ReadAndWriteCorrectCharacterEncoding")]
|
||||
|
|
|
@ -71,6 +71,7 @@ namespace System.Net.Http.Formatting
|
|||
expectedDefaultValue: false);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // MaxDepth is not supported in portable libraries
|
||||
[Fact]
|
||||
public void MaxDepth_RoundTrips()
|
||||
{
|
||||
|
@ -84,6 +85,7 @@ namespace System.Net.Http.Formatting
|
|||
illegalUpperValue: null,
|
||||
roundTripTestValue: 256);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Theory]
|
||||
[TestDataSet(typeof(CommonUnitTestDataSets), "RepresentativeValueAndRefTypeTestDataCollection")]
|
||||
|
@ -168,7 +170,12 @@ namespace System.Net.Http.Formatting
|
|||
[Fact]
|
||||
public void UseDataContractJsonSerializer_False()
|
||||
{
|
||||
JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter { UseDataContractJsonSerializer = false };
|
||||
JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter
|
||||
{
|
||||
#if !NETFX_CORE // No JsonSerializer in portable libraries
|
||||
UseDataContractJsonSerializer = false
|
||||
#endif
|
||||
};
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
HttpContent content = new StringContent(String.Empty);
|
||||
Assert.Task.Succeeds(formatter.WriteToStreamAsync(typeof(SampleType), new SampleType(), memoryStream, content, transportContext: null));
|
||||
|
@ -182,7 +189,13 @@ namespace System.Net.Http.Formatting
|
|||
[Fact]
|
||||
public void UseDataContractJsonSerializer_False_Indent()
|
||||
{
|
||||
JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter { UseDataContractJsonSerializer = false, Indent = true };
|
||||
JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter
|
||||
{
|
||||
#if !NETFX_CORE // No JsonSerializer in portable libraries
|
||||
UseDataContractJsonSerializer = false,
|
||||
#endif
|
||||
Indent = true
|
||||
};
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
HttpContent content = new StringContent(String.Empty);
|
||||
Assert.Task.Succeeds(formatter.WriteToStreamAsync(typeof(SampleType), new SampleType(), memoryStream, content, transportContext: null));
|
||||
|
@ -196,7 +209,12 @@ namespace System.Net.Http.Formatting
|
|||
[InlineData(typeof(IEnumerable<string>))]
|
||||
public void UseJsonFormatterWithNull(Type type)
|
||||
{
|
||||
JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter { UseDataContractJsonSerializer = false };
|
||||
JsonMediaTypeFormatter formatter = new JsonMediaTypeFormatter
|
||||
{
|
||||
#if !NETFX_CORE // No JsonSerializer in portable libraries
|
||||
UseDataContractJsonSerializer = false
|
||||
#endif
|
||||
};
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
HttpContent content = new StringContent(String.Empty);
|
||||
Assert.Task.Succeeds(formatter.WriteToStreamAsync(type, null, memoryStream, content, transportContext: null));
|
||||
|
|
|
@ -65,7 +65,11 @@ namespace System.Net.Http.Formatting
|
|||
// Classes
|
||||
{ new DataContractType() { s = "foo", i = 49, NotAMember = "Error" }, "{\"s\":\"foo\",\"i\":49}" },
|
||||
{ new POCOType() { s = "foo", t = "Error"}, "{\"s\":\"foo\"}" },
|
||||
#if !NETFX_CORE // Only publics are serialized in portable library
|
||||
{ new SerializableType("protected") { publicField = "public", protectedInternalField = "protected internal", internalField = "internal", PublicProperty = "private", nonSerializedField = "Error" }, "{\"publicField\":\"public\",\"internalField\":\"internal\",\"protectedInternalField\":\"protected internal\",\"protectedField\":\"protected\",\"privateField\":\"private\"}" },
|
||||
#else
|
||||
{ new SerializableType("protected") { publicField = "public", protectedInternalField = "protected internal", internalField = "internal", PublicProperty = "private", nonSerializedField = "Error" }, "{\"publicField\":\"public\",\"PublicProperty\":\"private\"}" },
|
||||
#endif
|
||||
{ new { field1 = "x", field2 = (string)null, field3 = "y" }, "{\"field1\":\"x\",\"field2\":null,\"field3\":\"y\"}" },
|
||||
|
||||
// Generics
|
||||
|
@ -137,7 +141,8 @@ namespace System.Net.Http.Formatting
|
|||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal(expectedObject, Deserialize(json, type), new ObjectComparer());
|
||||
object o = Deserialize(json, type);
|
||||
Assert.Equal(expectedObject, o, new ObjectComparer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,11 +459,16 @@ namespace System.Net.Http.Formatting
|
|||
|
||||
public bool Equals(SerializableType other)
|
||||
{
|
||||
#if !NETFX_CORE // Only publics are serialized in portable library
|
||||
return this.publicField == other.publicField &&
|
||||
this.internalField == other.internalField &&
|
||||
this.protectedInternalField == other.protectedInternalField &&
|
||||
this.protectedField == other.protectedField &&
|
||||
this.privateField == other.privateField;
|
||||
#else
|
||||
return this.publicField == other.publicField &&
|
||||
this.privateField == other.privateField;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace System.Net.Http.Formatting
|
|||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // SimpleRequiredMemberSelector uses MemberInfo which is not avaiable on portable libraries
|
||||
[Theory]
|
||||
[PropertyData("Theories")]
|
||||
public void ModelErrorsPopulatedWithValidationErrors(string json, Type type, int expectedErrors)
|
||||
|
@ -54,6 +55,7 @@ namespace System.Net.Http.Formatting
|
|||
|
||||
mockLogger.Verify(mock => mock.LogError(It.IsAny<string>(), It.IsAny<Exception>()), Times.Exactly(expectedErrors));
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void HittingMaxDepthRaisesOnlyOneValidationError()
|
||||
|
@ -78,6 +80,7 @@ namespace System.Net.Http.Formatting
|
|||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // IRequiredMemeberSelector uses MemberInfo which is not avaiable on portable libraries
|
||||
// this IRMS treats all member names that start with "Required" as required
|
||||
public class SimpleRequiredMemberSelector : IRequiredMemberSelector
|
||||
{
|
||||
|
@ -86,6 +89,7 @@ namespace System.Net.Http.Formatting
|
|||
return member.Name.StartsWith("Required");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public class DataContractWithRequiredMembers
|
||||
{
|
||||
|
|
|
@ -23,10 +23,16 @@ namespace System.Net.Http.Formatting
|
|||
public void Constructor()
|
||||
{
|
||||
MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection();
|
||||
#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
|
||||
Assert.Equal(3, collection.Count);
|
||||
#else
|
||||
Assert.Equal(2, collection.Count);
|
||||
#endif
|
||||
Assert.NotNull(collection.XmlFormatter);
|
||||
Assert.NotNull(collection.JsonFormatter);
|
||||
#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
|
||||
Assert.NotNull(collection.FormUrlEncodedFormatter);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -91,10 +97,14 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
new XmlMediaTypeFormatter(),
|
||||
new JsonMediaTypeFormatter(),
|
||||
#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
|
||||
new FormUrlEncodedMediaTypeFormatter(),
|
||||
#endif
|
||||
new XmlMediaTypeFormatter(),
|
||||
new JsonMediaTypeFormatter(),
|
||||
#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
|
||||
new FormUrlEncodedMediaTypeFormatter(),
|
||||
#endif
|
||||
};
|
||||
|
||||
MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(formatters);
|
||||
|
@ -131,6 +141,7 @@ namespace System.Net.Http.Formatting
|
|||
Assert.Null(collection.JsonFormatter);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // No FormUrlEncodedMediaTypeFormatter in portable library version
|
||||
[Fact]
|
||||
public void FormUrlEncodedFormatter_SetByCtor()
|
||||
{
|
||||
|
@ -145,6 +156,7 @@ namespace System.Net.Http.Formatting
|
|||
MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(new MediaTypeFormatter[0]);
|
||||
Assert.Null(collection.FormUrlEncodedFormatter);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void Remove_SetsXmlFormatter()
|
||||
|
|
|
@ -45,10 +45,12 @@ namespace System.Net.Http.Formatting
|
|||
Collection<MediaTypeHeaderValue> supportedMediaTypes = formatter.SupportedMediaTypes;
|
||||
Assert.NotNull(supportedMediaTypes);
|
||||
Assert.Equal(0, supportedMediaTypes.Count);
|
||||
|
||||
#if !NETFX_CORE // No MediaTypeMapping support in portable libraries
|
||||
Collection<MediaTypeMapping> mappings = formatter.MediaTypeMappings;
|
||||
|
||||
Assert.NotNull(mappings);
|
||||
Assert.Equal(0, mappings.Count);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -116,6 +118,7 @@ namespace System.Net.Http.Formatting
|
|||
Assert.ThrowsArgument(() => supportedMediaTypes.Insert(0, mediaType), "item", Error.Format(Properties.Resources.CannotUseMediaRangeForSupportedMediaType, typeof(MediaTypeHeaderValue).Name, mediaType.MediaType));
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // No MediaTypeMapping support in portable libraries
|
||||
[Fact]
|
||||
public void MediaTypeMappings_IsMutable()
|
||||
{
|
||||
|
@ -129,6 +132,7 @@ namespace System.Net.Http.Formatting
|
|||
|
||||
Assert.True(standardMappings.SequenceEqual(formatter.MediaTypeMappings));
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void SelectCharacterEncoding_ThrowsIfNoSupportedEncodings()
|
||||
|
|
|
@ -10,5 +10,20 @@ namespace System.Net.Http.Formatting
|
|||
: base(StringComparisonHelper.IsDefined, StringComparisonHelper.Validate, (StringComparison)999)
|
||||
{
|
||||
}
|
||||
|
||||
#if NETFX_CORE // InvariantCulture and InvarianteCultureIgnore case are not supported in portable library projects
|
||||
protected override void AssertForUndefinedValue(Action testCode, string parameterName, int invalidValue, Type enumType, bool allowDerivedExceptions = false)
|
||||
{
|
||||
Assert.ThrowsArgument(
|
||||
testCode,
|
||||
parameterName,
|
||||
allowDerivedExceptions);
|
||||
}
|
||||
|
||||
protected override bool ValueExistsForFramework(StringComparison value)
|
||||
{
|
||||
return !(value == StringComparison.InvariantCulture || value == StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace System.Net.Http.Formatting
|
|||
Assert.Equal("application/xml", mediaType.MediaType);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // We don't support MaxDepth in the portable library
|
||||
[Fact]
|
||||
public void MaxDepthReturnsCorrectValue()
|
||||
{
|
||||
|
@ -63,6 +64,7 @@ namespace System.Net.Http.Formatting
|
|||
Task task = formatter.ReadFromStreamAsync(typeof(SampleType), stream, null, null);
|
||||
Assert.Throws<SerializationException>(() => task.Wait());
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void Indent_RoundTrips()
|
||||
|
@ -241,7 +243,15 @@ namespace System.Net.Http.Formatting
|
|||
|
||||
// Arrange
|
||||
XmlMediaTypeFormatter formatter = new XmlMediaTypeFormatter();
|
||||
|
||||
string formattedContent = "<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + content + "</string>";
|
||||
#if NETFX_CORE
|
||||
// We need to supply the xml declaration when compiled in portable library for non utf-8 content
|
||||
if (String.Equals("utf-16", encoding, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
formattedContent = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + formattedContent;
|
||||
}
|
||||
#endif
|
||||
string mediaType = string.Format("application/xml; charset={0}", encoding);
|
||||
|
||||
// Act & assert
|
||||
|
@ -273,7 +283,12 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
XmlMediaTypeFormatter formatter = new XmlMediaTypeFormatter();
|
||||
|
||||
#if !NETFX_CORE
|
||||
Assert.False(formatter.CanReadType(typeof(InvalidDataContract)));
|
||||
#else
|
||||
// The formatter is unable to positively identify non readable types, so true is always returned
|
||||
Assert.True(formatter.CanReadType(typeof(InvalidDataContract)));
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -281,7 +296,12 @@ namespace System.Net.Http.Formatting
|
|||
{
|
||||
XmlMediaTypeFormatter formatter = new XmlMediaTypeFormatter();
|
||||
|
||||
#if !NETFX_CORE
|
||||
Assert.False(formatter.CanWriteType(typeof(InvalidDataContract)));
|
||||
#else
|
||||
// The formatter is unable to positively identify non readable types, so true is always returned
|
||||
Assert.True(formatter.CanWriteType(typeof(InvalidDataContract)));
|
||||
#endif
|
||||
}
|
||||
|
||||
public class InvalidDataContract
|
||||
|
|
|
@ -58,7 +58,12 @@ namespace System.Net.Http.Formatting
|
|||
[Fact]
|
||||
public void ReadDeeplyNestedObjectWorks()
|
||||
{
|
||||
XmlSerializerMediaTypeFormatter formatter = new XmlSerializerMediaTypeFormatter() { MaxDepth = 5001 };
|
||||
XmlSerializerMediaTypeFormatter formatter = new XmlSerializerMediaTypeFormatter()
|
||||
{
|
||||
#if !NETFX_CORE // We don't support MaxDepth in the portable library
|
||||
MaxDepth = 5001
|
||||
#endif
|
||||
};
|
||||
|
||||
StringContent content = new StringContent(GetDeeplyNestedObject(5000));
|
||||
|
||||
|
@ -229,6 +234,13 @@ namespace System.Net.Http.Formatting
|
|||
// Arrange
|
||||
XmlSerializerMediaTypeFormatter formatter = new XmlSerializerMediaTypeFormatter();
|
||||
string formattedContent = "<string>" + content + "</string>";
|
||||
#if NETFX_CORE
|
||||
if (String.Equals("utf-16", encoding, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// We need to supply the xml declaration when compiled in portable library for non utf-8 content
|
||||
formattedContent = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + formattedContent;
|
||||
}
|
||||
#endif
|
||||
string mediaType = string.Format("application/xml; charset={0}", encoding);
|
||||
|
||||
// Act & assert
|
||||
|
|
|
@ -133,7 +133,11 @@ namespace System.Net.Http.Handlers
|
|||
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
#if NETFX_CORE
|
||||
HttpResponseMessage response = new HttpResponseMessage() { RequestMessage = request };
|
||||
#else
|
||||
HttpResponseMessage response = request.CreateResponse();
|
||||
#endif
|
||||
if (_includeResponseEntity)
|
||||
{
|
||||
response.Content = new StringContent("Response Entity");
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace System.Net.Http.Handlers
|
|||
Assert.Equal(100, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
[Fact]
|
||||
public void BeginEndRead_ReportsBytesRead()
|
||||
{
|
||||
|
@ -95,6 +96,37 @@ namespace System.Net.Http.Handlers
|
|||
Assert.Equal(expectedLength, mockProgressEventHandler.EventArgs.TotalBytes);
|
||||
Assert.Equal(100, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
#else
|
||||
[Fact]
|
||||
public void ReadAsync_ReportsBytesRead()
|
||||
{
|
||||
// Arrange
|
||||
HttpResponseMessage response = CreateResponse();
|
||||
Stream innerStream = response.Content.ReadAsStreamAsync().Result;
|
||||
long? expectedLength = response.Content.Headers.ContentLength;
|
||||
MockProgressEventHandler mockProgressEventHandler;
|
||||
ProgressMessageHandler progressMessageHandler = MockProgressEventHandler.CreateProgressMessageHandler(out mockProgressEventHandler, sendProgress: false);
|
||||
ProgressStream progressStream = CreateProgressStream(innerStream: innerStream, progressMessageHandler: progressMessageHandler, response: response);
|
||||
object userState = new object();
|
||||
|
||||
// Act/Assert
|
||||
int totalBytesRead = 0;
|
||||
int bytesRead = 0;
|
||||
do
|
||||
{
|
||||
byte[] buffer = new byte[8];
|
||||
bytesRead = progressStream.ReadAsync(buffer, 0, buffer.Length).Result;
|
||||
totalBytesRead += bytesRead;
|
||||
|
||||
Assert.Equal(totalBytesRead, mockProgressEventHandler.EventArgs.BytesTransferred);
|
||||
Assert.Equal((100L * totalBytesRead) / expectedLength, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
while (bytesRead > 0);
|
||||
|
||||
Assert.Equal(expectedLength, mockProgressEventHandler.EventArgs.TotalBytes);
|
||||
Assert.Equal(100, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Fact]
|
||||
public void Write_ReportsBytesWritten()
|
||||
|
@ -152,6 +184,7 @@ namespace System.Net.Http.Handlers
|
|||
Assert.Equal(100, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
[Fact]
|
||||
public void BeginEndWrite_ReportsBytesWritten()
|
||||
{
|
||||
|
@ -192,6 +225,39 @@ namespace System.Net.Http.Handlers
|
|||
Assert.Equal(expectedLength, mockProgressEventHandler.EventArgs.TotalBytes);
|
||||
Assert.Equal(100, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
#else
|
||||
[Fact]
|
||||
public void WriteAsync_ReportsBytesWritten()
|
||||
{
|
||||
// Arrange
|
||||
ManualResetEvent writeComplete = new ManualResetEvent(false);
|
||||
HttpRequestMessage request = CreateRequest();
|
||||
Stream innerStream = new MemoryStream();
|
||||
byte[] buffer = CreateBufferContent();
|
||||
long? expectedLength = request.Content.Headers.ContentLength;
|
||||
MockProgressEventHandler mockProgressEventHandler;
|
||||
ProgressMessageHandler progressMessageHandler = MockProgressEventHandler.CreateProgressMessageHandler(out mockProgressEventHandler, sendProgress: true);
|
||||
ProgressStream progressStream = CreateProgressStream(innerStream: innerStream, progressMessageHandler: progressMessageHandler, request: request);
|
||||
object userState = new object();
|
||||
|
||||
// Act/Assert
|
||||
int totalBytesWritten = 0;
|
||||
int bytesWritten = 0;
|
||||
while (totalBytesWritten < expectedLength)
|
||||
{
|
||||
bytesWritten = Math.Min(8, (int)expectedLength - totalBytesWritten);
|
||||
progressStream.WriteAsync(buffer, totalBytesWritten, bytesWritten).Wait();
|
||||
|
||||
totalBytesWritten += bytesWritten;
|
||||
|
||||
Assert.Equal(totalBytesWritten, mockProgressEventHandler.EventArgs.BytesTransferred);
|
||||
Assert.Equal((100L * totalBytesWritten) / expectedLength, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
|
||||
Assert.Equal(expectedLength, mockProgressEventHandler.EventArgs.TotalBytes);
|
||||
Assert.Equal(100, mockProgressEventHandler.EventArgs.ProgressPercentage);
|
||||
}
|
||||
#endif
|
||||
|
||||
internal static ProgressStream CreateProgressStream(
|
||||
Stream innerStream = null,
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Linq;
|
|||
using System.Net.Http.Formatting.Parsers;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.TestCommon;
|
||||
|
||||
namespace System.Net.Http
|
||||
|
@ -109,7 +111,7 @@ namespace System.Net.Http
|
|||
public void ReadAsMultipartAsync_ThrowsOnNullStreamProvider()
|
||||
{
|
||||
HttpContent content = CreateContent(ValidBoundary);
|
||||
Assert.ThrowsArgumentNull(() => content.ReadAsMultipartAsync((MultipartMemoryStreamProvider)null), "streamProvider");
|
||||
Assert.ThrowsArgumentNull(() => content.ReadAsMultipartAsync((MultipartStreamProvider)null).Wait(), "streamProvider");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -117,7 +119,7 @@ namespace System.Net.Http
|
|||
{
|
||||
HttpContent content = CreateContent(ValidBoundary);
|
||||
Assert.ThrowsArgumentGreaterThanOrEqualTo(
|
||||
() => content.ReadAsMultipartAsync(new MultipartMemoryStreamProvider(), ParserData.MinBufferSize - 1),
|
||||
() => content.ReadAsMultipartAsync(new MultipartMemoryStreamProvider(), ParserData.MinBufferSize - 1).Wait(),
|
||||
"bufferSize", ParserData.MinBufferSize.ToString(), ParserData.MinBufferSize - 1);
|
||||
}
|
||||
|
||||
|
@ -342,26 +344,39 @@ namespace System.Net.Http
|
|||
{
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new Exception(ExceptionSyncStreamMessage);
|
||||
throw new IOException(ExceptionSyncStreamMessage);
|
||||
}
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new IOException(ExceptionAsyncStreamMessage);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new Exception(ExceptionAsyncStreamMessage);
|
||||
throw new IOException(ExceptionAsyncStreamMessage);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public class WriteErrorStream : MemoryStream
|
||||
{
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new Exception(ExceptionSyncStreamMessage);
|
||||
throw new IOException(ExceptionSyncStreamMessage);
|
||||
}
|
||||
|
||||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new IOException(ExceptionAsyncStreamMessage);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
throw new Exception(ExceptionAsyncStreamMessage);
|
||||
throw new IOException(ExceptionAsyncStreamMessage);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public class BadStreamProvider : MultipartStreamProvider
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using System.IO;
|
||||
using System.Net.Http.Mocks;
|
||||
using System.Threading;
|
||||
using Microsoft.TestCommon;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
|
@ -191,6 +192,7 @@ namespace System.Net.Http.Internal
|
|||
mockInnerStream.Verify(s => s.Read(buffer, offset, count), Times.Once());
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
[Fact]
|
||||
public void DelegatingStream_BeginRead()
|
||||
{
|
||||
|
@ -224,6 +226,23 @@ namespace System.Net.Http.Internal
|
|||
// Assert
|
||||
mockInnerStream.Verify(s => s.EndRead(mockIAsyncResult.Object), Times.Once());
|
||||
}
|
||||
#endif
|
||||
[Fact]
|
||||
public void DelegatingStream_ReadAsyc()
|
||||
{
|
||||
// Arrange
|
||||
Mock<Stream> mockInnerStream = new Mock<Stream>();
|
||||
MockDelegatingStream mockStream = new MockDelegatingStream(mockInnerStream.Object);
|
||||
byte[] buffer = new byte[2];
|
||||
int offset = 1;
|
||||
int count = 1;
|
||||
|
||||
// Act
|
||||
mockStream.ReadAsync(buffer, offset, count, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
mockInnerStream.Verify(s => s.ReadAsync(buffer, offset, count, CancellationToken.None), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DelegatingStream_ReadByte()
|
||||
|
@ -284,6 +303,7 @@ namespace System.Net.Http.Internal
|
|||
mockInnerStream.Verify(s => s.Write(buffer, offset, count), Times.Once());
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // BeginX and EndX not supported on Streams in portable libraries
|
||||
[Fact]
|
||||
public void DelegatingStream_BeginWrite()
|
||||
{
|
||||
|
@ -317,6 +337,23 @@ namespace System.Net.Http.Internal
|
|||
// Assert
|
||||
mockInnerStream.Verify(s => s.EndWrite(mockIAsyncResult.Object), Times.Once());
|
||||
}
|
||||
#endif
|
||||
[Fact]
|
||||
public void DelegatingStream_WriteAsync()
|
||||
{
|
||||
// Arrange
|
||||
Mock<Stream> mockInnerStream = new Mock<Stream>();
|
||||
MockDelegatingStream mockStream = new MockDelegatingStream(mockInnerStream.Object);
|
||||
byte[] buffer = new byte[2];
|
||||
int offset = 1;
|
||||
int count = 1;
|
||||
|
||||
// Act
|
||||
mockStream.WriteAsync(buffer, offset, count, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
mockInnerStream.Verify(s => s.WriteAsync(buffer, offset, count, CancellationToken.None), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DelegatingStream_WriteByte()
|
||||
|
|
|
@ -39,8 +39,11 @@ namespace System.Net.Http.Mocks
|
|||
SendAsyncException = new Exception("SendAsync exception");
|
||||
throw SendAsyncException;
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // Extension method only available on non portable library
|
||||
return TaskHelpers.FromResult(request.CreateResponse());
|
||||
#else
|
||||
return TaskHelpers.FromResult(new HttpResponseMessage { RequestMessage = request });
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,10 +190,12 @@ namespace System.Net.Http
|
|||
return true;
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // No override available in portable library projects
|
||||
public override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContent content, TransportContext transportContext)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ namespace System.Net.Http
|
|||
Assert.True(serializeToStreamTask.Task.Result);
|
||||
}
|
||||
|
||||
#if !NETFX_CORE // No Stream.Close on portable libraries
|
||||
[Fact]
|
||||
public void NonClosingDelegatingStream_Close_CompletesTaskButDoNotCloseInnerStream()
|
||||
{
|
||||
|
@ -118,7 +119,8 @@ namespace System.Net.Http
|
|||
Assert.Equal(TaskStatus.RanToCompletion, serializeToStreamTask.Task.Status);
|
||||
Assert.True(serializeToStreamTask.Task.Result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private class MockStreamAction
|
||||
{
|
||||
bool _close;
|
||||
|
|
Загрузка…
Ссылка в новой задаче