Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -126,40 +126,55 @@ namespace System.Net
public enum HttpStatusCode
{
Accepted = 202,
AlreadyReported = 208,
Ambiguous = 300,
BadGateway = 502,
BadRequest = 400,
Conflict = 409,
Continue = 100,
Created = 201,
EarlyHints = 103,
ExpectationFailed = 417,
FailedDependency = 424,
Forbidden = 403,
Found = 302,
GatewayTimeout = 504,
Gone = 410,
HttpVersionNotSupported = 505,
IMUsed = 226,
InsufficientStorage = 507,
InternalServerError = 500,
LengthRequired = 411,
Locked = 423,
LoopDetected = 508,
MethodNotAllowed = 405,
MisdirectedRequest = 421,
Moved = 301,
MovedPermanently = 301,
MultipleChoices = 300,
MultiStatus = 207,
NetworkAuthenticationRequired = 511,
NoContent = 204,
NonAuthoritativeInformation = 203,
NotAcceptable = 406,
NotExtended = 510,
NotFound = 404,
NotImplemented = 501,
NotModified = 304,
OK = 200,
PartialContent = 206,
PaymentRequired = 402,
PermanentRedirect = 308,
PreconditionFailed = 412,
PreconditionRequired = 428,
Processing = 102,
ProxyAuthenticationRequired = 407,
Redirect = 302,
RedirectKeepVerb = 307,
RedirectMethod = 303,
RequestedRangeNotSatisfiable = 416,
RequestEntityTooLarge = 413,
RequestHeaderFieldsTooLarge = 431,
RequestTimeout = 408,
RequestUriTooLong = 414,
ResetContent = 205,
@@ -167,11 +182,15 @@ namespace System.Net
ServiceUnavailable = 503,
SwitchingProtocols = 101,
TemporaryRedirect = 307,
TooManyRequests = 429,
Unauthorized = 401,
UnavailableForLegalReasons = 451,
UnprocessableEntity = 422,
UnsupportedMediaType = 415,
Unused = 306,
UpgradeRequired = 426,
UseProxy = 305,
VariantAlsoNegotiates = 506
}
public partial interface ICredentials
{

View File

@@ -0,0 +1,4 @@
Compat issues with assembly System.Net.Primitives:
TypesMustExist : Type 'System.Net.CookieVariant' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Net.PathList' does not exist in the implementation but it does exist in the contract.
Total Issues: 2

View File

@@ -0,0 +1,12 @@
Compat issues with assembly System.Net.Primitives:
MembersMustExist : Member 'System.Boolean System.Net.Cookie.IsQuotedDomain' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Boolean System.Net.Cookie.IsQuotedVersion' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Net.Cookie.Clone()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Net.Cookie.InternalSetName(System.String)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Net.Cookie.ToServerString()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Net.Cookie.Variant.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Net.Cookie.Variant.set(System.Net.CookieVariant)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Net.CookieCollection.InternalAdd(System.Net.Cookie, System.Boolean)' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Net.CookieVariant' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Net.PathList' does not exist in the implementation but it does exist in the contract.
Total Issues: 10

View File

@@ -6,6 +6,7 @@
<OutputType>Library</OutputType>
<ProjectGuid>{8772BC91-7B55-49B9-94FA-4B1BE5BEAB55}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap-Windows_NT-Release|AnyCPU'" />
@@ -92,8 +93,8 @@
<Compile Include="$(CommonPath)\System\Marvin.cs">
<Link>Common\System\Marvin.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\StringBuilderCache.cs">
<Link>Common\System\IO\StringBuilderCache.cs</Link>
<Compile Include="$(CommonPath)\CoreLib\System\Text\StringBuilderCache.cs">
<Link>Common\System\Text\StringBuilderCache.cs</Link>
</Compile>
<!-- Logging -->
<Compile Include="$(CommonPath)\System\Net\Logging\NetEventSource.Common.cs">

View File

@@ -97,6 +97,7 @@ namespace System.Net
public const int DefaultPerDomainCookieLimit = 20;
public const int DefaultCookieLengthLimit = 4096;
private static readonly string s_fqdnMyDomain = CreateFqdnMyDomain();
private static readonly HeaderVariantInfo[] s_headerInfo = {
new HeaderVariantInfo(HttpKnownHeaderNames.SetCookie, CookieVariant.Rfc2109),
new HeaderVariantInfo(HttpKnownHeaderNames.SetCookie2, CookieVariant.Rfc2965)
@@ -107,19 +108,13 @@ namespace System.Net
private int m_maxCookies = DefaultCookieLimit; // Do not rename (binary serialization)
private int m_maxCookiesPerDomain = DefaultPerDomainCookieLimit; // Do not rename (binary serialization)
private int m_count = 0; // Do not rename (binary serialization)
private string m_fqdnMyDomain = string.Empty; // Do not rename (binary serialization)
private string m_fqdnMyDomain = s_fqdnMyDomain; // Do not rename (binary serialization)
public CookieContainer()
{
string domain = HostInformation.DomainName;
if (domain != null && domain.Length > 1)
{
m_fqdnMyDomain = '.' + domain;
}
// Otherwise it will remain string.Empty.
}
public CookieContainer(int capacity) : this()
public CookieContainer(int capacity)
{
if (capacity <= 0)
{
@@ -142,6 +137,14 @@ namespace System.Net
m_maxCookieSize = maxCookieSize;
}
private static string CreateFqdnMyDomain()
{
string domain = HostInformation.DomainName;
return domain != null && domain.Length > 1 ?
'.' + domain :
string.Empty;
}
// NOTE: after shrinking the capacity, Count can become greater than Capacity.
public int Capacity
{

View File

@@ -10,6 +10,8 @@ namespace System.Net
// Informational 1xx
Continue = 100,
SwitchingProtocols = 101,
Processing = 102,
EarlyHints = 103,
// Successful 2xx
OK = 200,
@@ -19,6 +21,10 @@ namespace System.Net
NoContent = 204,
ResetContent = 205,
PartialContent = 206,
MultiStatus = 207,
AlreadyReported = 208,
IMUsed = 226,
// Redirection 3xx
MultipleChoices = 300,
@@ -34,6 +40,7 @@ namespace System.Net
Unused = 306,
TemporaryRedirect = 307,
RedirectKeepVerb = 307,
PermanentRedirect = 308,
// Client Error 4xx
BadRequest = 400,
@@ -54,9 +61,25 @@ namespace System.Net
UnsupportedMediaType = 415,
RequestedRangeNotSatisfiable = 416,
ExpectationFailed = 417,
// From the discussion thread on #4382:
// "It would be a mistake to add it to .NET now. See golang/go#21326,
// nodejs/node#14644, requests/requests#4238 and aspnet/HttpAbstractions#915".
// ImATeapot = 418
MisdirectedRequest = 421,
UnprocessableEntity = 422,
Locked = 423,
FailedDependency = 424,
UpgradeRequired = 426,
PreconditionRequired = 428,
TooManyRequests = 429,
RequestHeaderFieldsTooLarge = 431,
UnavailableForLegalReasons = 451,
// Server Error 5xx
InternalServerError = 500,
NotImplemented = 501,
@@ -64,5 +87,11 @@ namespace System.Net
ServiceUnavailable = 503,
GatewayTimeout = 504,
HttpVersionNotSupported = 505,
VariantAlsoNegotiates = 506,
InsufficientStorage = 507,
LoopDetected = 508,
NotExtended = 510,
NetworkAuthenticationRequired = 511
}
}

View File

@@ -6,6 +6,7 @@ using System.Buffers.Binary;
using System.Diagnostics;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Net
{
@@ -232,7 +233,7 @@ namespace System.Net
return false;
}
address = IPAddressParser.Parse(ipString.AsReadOnlySpan(), tryParse: true);
address = IPAddressParser.Parse(ipString.AsSpan(), tryParse: true);
return (address != null);
}
@@ -249,7 +250,7 @@ namespace System.Net
throw new ArgumentNullException(nameof(ipString));
}
return IPAddressParser.Parse(ipString.AsReadOnlySpan(), tryParse: false);
return IPAddressParser.Parse(ipString.AsSpan(), tryParse: false);
}
public static IPAddress Parse(ReadOnlySpan<char> ipSpan)
@@ -611,7 +612,7 @@ namespace System.Net
const int addressAndScopeIdLength = IPAddressParserStatics.IPv6AddressBytes + sizeof(uint);
Span<byte> addressAndScopeIdSpan = stackalloc byte[addressAndScopeIdLength];
new ReadOnlySpan<ushort>(_numbers).AsBytes().CopyTo(addressAndScopeIdSpan);
MemoryMarshal.AsBytes(new ReadOnlySpan<ushort>(_numbers)).CopyTo(addressAndScopeIdSpan);
Span<byte> scopeIdSpan = addressAndScopeIdSpan.Slice(IPAddressParserStatics.IPv6AddressBytes);
bool scopeWritten = BitConverter.TryWriteBytes(scopeIdSpan, _addressOrScopeId);
Debug.Assert(scopeWritten);
@@ -627,7 +628,7 @@ namespace System.Net
// For IPv4 addresses, we use Marvin on the integer representation of the Address.
hashCode = Marvin.ComputeHash32(
addressOrScopeIdSpan.AsBytes(),
MemoryMarshal.AsBytes(addressOrScopeIdSpan),
Marvin.DefaultSeed);
}

View File

@@ -21,6 +21,7 @@ namespace System.Net
// The address is parsed as IPv6 if and only if it contains a colon. This is valid because
// we don't support/parse a port specification at the end of an IPv4 address.
ushort* numbers = stackalloc ushort[IPAddressParserStatics.IPv6AddressShorts];
new Span<ushort>(numbers, IPAddressParserStatics.IPv6AddressShorts).Clear();
if (Ipv6StringToAddress(ipSpan, numbers, IPAddressParserStatics.IPv6AddressShorts, out uint scope))
{
return new IPAddress(numbers, IPAddressParserStatics.IPv6AddressShorts, scope);

View File

@@ -9,8 +9,8 @@ namespace System.Net.Primitives.Functional.Tests
{
public sealed class IPAddressParsing_Span : IPAddressParsing
{
public override IPAddress Parse(string ipString) => IPAddress.Parse(ipString.AsReadOnlySpan());
public override bool TryParse(string ipString, out IPAddress address) => IPAddress.TryParse(ipString.AsReadOnlySpan(), out address);
public override IPAddress Parse(string ipString) => IPAddress.Parse(ipString.AsSpan());
public override bool TryParse(string ipString, out IPAddress address) => IPAddress.TryParse(ipString.AsSpan(), out address);
[Theory]

View File

@@ -37,7 +37,7 @@ namespace System.Net.Primitives.Functional.Tests
IPAddress ip = new IPAddress(address);
Assert.True(ip.TryWriteBytes(new Span<byte>(result), out int bytesWritten));
Assert.Equal<byte>(address, result.AsSpan().Slice(0, bytesWritten).ToArray());
Assert.Equal<byte>(address, result.AsSpan(0, bytesWritten).ToArray());
Assert.Equal(address.Length, bytesWritten);
}

View File

@@ -54,8 +54,8 @@
<Compile Include="$(CommonPath)\System\Marvin.cs">
<Link>ProductionCode\Common\System\Marvin.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\StringBuilderCache.cs">
<Link>ProductionCode\Common\System\IO\StringBuilderCache.cs</Link>
<Compile Include="$(CommonPath)\CoreLib\System\Text\StringBuilderCache.cs">
<Link>ProductionCode\Common\System\Text\StringBuilderCache.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
@@ -168,4 +168,4 @@
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -80,33 +80,5 @@ namespace NetPrimitivesUnitTests
int expectedCookieCount = expectedStrings.Length >> 1;
Assert.Equal(expectedCookieCount, cookieCount);
}
[ActiveIssue(22925)]
[Theory]
[InlineData("cookie_name=cookie_value", new[] { "cookie_name", "cookie_value" })]
[InlineData("cookie_name=cookie_value;", new[] { "cookie_name", "cookie_value" })]
[InlineData("cookie_name1=cookie_value1;cookie_name2=cookie_value2", new[] { "cookie_name1", "cookie_value1", "cookie_name2", "cookie_value2" })]
[InlineData("cookie_name1=cookie_value1;cookie_name2=cookie_value2;", new[] { "cookie_name1", "cookie_value1", "cookie_name2", "cookie_value2" })]
public void CookieParserGet_SetCookieHeaderValue_Success(string cookieString, string[] expectedStrings)
{
int index = 0;
int cookieCount = 0;
var parser = new CookieParser(cookieString);
while (true)
{
Cookie cookie = parser.Get();
if (cookie == null)
{
break;
}
cookieCount++;
Assert.Equal(expectedStrings[index++], cookie.Name);
Assert.Equal(expectedStrings[index++], cookie.Value);
}
int expectedCookieCount = expectedStrings.Length >> 1;
Assert.Equal(expectedCookieCount, cookieCount);
}
}
}

View File

@@ -98,8 +98,8 @@
<Compile Include="$(CommonPath)\System\Marvin.cs">
<Link>Common\System\Marvin.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\StringBuilderCache.cs">
<Link>Common\System\IO\StringBuilderCache.cs</Link>
<Compile Include="$(CommonPath)\CoreLib\System\Text\StringBuilderCache.cs">
<Link>Common\System\Text\StringBuilderCache.cs</Link>
</Compile>
<!-- Logging -->
<Compile Include="$(CommonPath)\System\Net\Logging\NetEventSource.Common.cs">
@@ -144,4 +144,4 @@
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>