Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -1,76 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding.Tests", "tests\System.Text.Encoding.Tests.csproj", "{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding", "src\System.Text.Encoding.csproj", "{ECD16D77-404B-4992-A476-C0C8A34BBB15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding.Performance.Tests", "tests\Performance\System.Text.Encoding.Performance.Tests.csproj", "{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
net46_Debug|Any CPU = net46_Debug|Any CPU
net46_Release|Any CPU = net46_Release|Any CPU
netcore50_Debug|Any CPU = netcore50_Debug|Any CPU
netcore50_Release|Any CPU = netcore50_Release|Any CPU
netcore50aot_Debug|Any CPU = netcore50aot_Debug|Any CPU
netcore50aot_Release|Any CPU = netcore50aot_Release|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.net46_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.net46_Debug|Any CPU.Build.0 = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.net46_Release|Any CPU.ActiveCfg = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.net46_Release|Any CPU.Build.0 = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50_Debug|Any CPU.Build.0 = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50_Release|Any CPU.ActiveCfg = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50_Release|Any CPU.Build.0 = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50aot_Debug|Any CPU.Build.0 = Debug|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50aot_Release|Any CPU.ActiveCfg = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.netcore50aot_Release|Any CPU.Build.0 = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}.Release|Any CPU.Build.0 = Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.net46_Debug|Any CPU.ActiveCfg = net46_Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.net46_Debug|Any CPU.Build.0 = net46_Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.net46_Release|Any CPU.ActiveCfg = net46_Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.net46_Release|Any CPU.Build.0 = net46_Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50_Debug|Any CPU.ActiveCfg = netcore50_Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50_Debug|Any CPU.Build.0 = netcore50_Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50_Release|Any CPU.ActiveCfg = netcore50_Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50_Release|Any CPU.Build.0 = netcore50_Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50aot_Debug|Any CPU.ActiveCfg = netcore50aot_Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50aot_Debug|Any CPU.Build.0 = netcore50aot_Debug|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50aot_Release|Any CPU.ActiveCfg = netcore50aot_Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.netcore50aot_Release|Any CPU.Build.0 = netcore50aot_Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECD16D77-404B-4992-A476-C0C8A34BBB15}.Release|Any CPU.Build.0 = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.net46_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.net46_Debug|Any CPU.Build.0 = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.net46_Release|Any CPU.ActiveCfg = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.net46_Release|Any CPU.Build.0 = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50_Debug|Any CPU.Build.0 = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50_Release|Any CPU.ActiveCfg = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50_Release|Any CPU.Build.0 = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50aot_Debug|Any CPU.Build.0 = Debug|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50aot_Release|Any CPU.ActiveCfg = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.netcore50aot_Release|Any CPU.Build.0 = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F6AD626-B78D-4231-BD0F-A0C462FDBF2E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,60 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding.Tests", "tests\System.Text.Encoding.Tests.csproj", "{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}"
ProjectSection(ProjectDependencies) = postProject
{635F30B9-5566-4096-B772-68FAA9B00DF4} = {635F30B9-5566-4096-B772-68FAA9B00DF4}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding.Performance.Tests", "tests\Performance\System.Text.Encoding.Performance.Tests.csproj", "{859C92CB-72FB-453C-A363-7CD025E29B1D}"
ProjectSection(ProjectDependencies) = postProject
{635F30B9-5566-4096-B772-68FAA9B00DF4} = {635F30B9-5566-4096-B772-68FAA9B00DF4}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding", "src\System.Text.Encoding.csproj", "{635F30B9-5566-4096-B772-68FAA9B00DF4}"
ProjectSection(ProjectDependencies) = postProject
{D5E689FD-4848-4E06-B6ED-35EA09AF9E20} = {D5E689FD-4848-4E06-B6ED-35EA09AF9E20}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Text.Encoding", "ref\System.Text.Encoding.csproj", "{D5E689FD-4848-4E06-B6ED-35EA09AF9E20}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
{859C92CB-72FB-453C-A363-7CD025E29B1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{859C92CB-72FB-453C-A363-7CD025E29B1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{859C92CB-72FB-453C-A363-7CD025E29B1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{859C92CB-72FB-453C-A363-7CD025E29B1D}.Release|Any CPU.Build.0 = Release|Any CPU
{635F30B9-5566-4096-B772-68FAA9B00DF4}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{635F30B9-5566-4096-B772-68FAA9B00DF4}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{635F30B9-5566-4096-B772-68FAA9B00DF4}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{635F30B9-5566-4096-B772-68FAA9B00DF4}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{D5E689FD-4848-4E06-B6ED-35EA09AF9E20}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{D5E689FD-4848-4E06-B6ED-35EA09AF9E20}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{D5E689FD-4848-4E06-B6ED-35EA09AF9E20}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{D5E689FD-4848-4E06-B6ED-35EA09AF9E20}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{859C92CB-72FB-453C-A363-7CD025E29B1D} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{635F30B9-5566-4096-B772-68FAA9B00DF4} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{D5E689FD-4848-4E06-B6ED-35EA09AF9E20} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
EndGlobal

View File

@@ -4,5 +4,6 @@
<PropertyGroup>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<IsNETCoreApp>true</IsNETCoreApp>
<IsUAP>true</IsUAP>
</PropertyGroup>
</Project>

View File

@@ -3,6 +3,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProjectGuid>{D5E689FD-4848-4E06-B6ED-35EA09AF9E20}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />

View File

@@ -1,10 +1,9 @@
Compat issues with assembly System.Text.Encoding:
MembersMustExist : Member 'System.Text.Decoder.Convert(System.Byte*, System.Int32, System.Char*, System.Int32, System.Boolean, System.Int32, System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Decoder.GetCharCount(System.Byte*, System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Decoder.GetChars(System.Byte*, System.Int32, System.Char*, System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Text.DecoderFallbackException' does not inherit from base type 'System.SystemException' in the implementation but it does in the contract.
MembersMustExist : Member 'System.Text.Encoder.Convert(System.Char*, System.Int32, System.Byte*, System.Int32, System.Boolean, System.Int32, System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Encoder.GetBytes(System.Char*, System.Int32, System.Byte*, System.Int32, System.Boolean)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Text.EncoderFallbackException' does not inherit from base type 'System.SystemException' in the implementation but it does in the contract.
MembersMustExist : Member 'System.Text.Encoding.BodyName.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Encoding.Default.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Encoding.GetEncodings()' does not exist in the implementation but it does exist in the contract.
@@ -16,4 +15,4 @@ MembersMustExist : Member 'System.Text.Encoding.IsBrowserSave.get()' does not ex
MembersMustExist : Member 'System.Text.Encoding.IsMailNewsDisplay.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Encoding.IsMailNewsSave.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Text.Encoding.WindowsCodePage.get()' does not exist in the implementation but it does exist in the contract.
Total Issues: 16

View File

@@ -2,9 +2,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
uap101aot-Windows_NT;
net463-Windows_NT;
netcoreapp;
uapaot-Windows_NT;
uap-Windows_NT;
netcoreapp-Windows_NT;
netcoreapp-Unix;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -4,21 +4,19 @@
<PropertyGroup>
<AssemblyName>System.Text.Encoding</AssemblyName>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<!-- copy to uap10.1 until nuget makes the change to map that to ns1.7 -->
<ProjectGuid>{635F30B9-5566-4096-B772-68FAA9B00DF4}</ProjectGuid>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap101aot-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap101aot-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='net463-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Release|AnyCPU'" />
<ItemGroup>
<TargetingPackReference Include="mscorlib" Condition="'$(TargetGroup)' == 'net463'" />
<TargetingPackReference Include="System.Private.CoreLib" Condition="'$(TargetGroup)' != 'net463'" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uapaot-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uapaot-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<ReferenceFromRuntime Include="System.Private.CoreLib" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard1.3;
netcoreapp;
netstandard;
</BuildConfigurations>
</PropertyGroup>

View File

@@ -6,12 +6,15 @@ using Xunit;
namespace System.Text.Tests
{
public static class EncodingHelpers
public static partial class EncodingHelpers
{
public static void Encode(Encoding encoding, string chars, int index, int count, byte[] expected)
{
GetByteCount(encoding, chars, index, count, expected.Length);
GetBytes(encoding, chars, index, count, expected);
GetByteCount_NetCoreApp(encoding, chars, index, count, expected.Length);
GetBytes_NetCoreApp(encoding, chars, index, count, expected);
}
private static unsafe void GetByteCount(Encoding encoding, string chars, int index, int count, int expected)
@@ -23,6 +26,7 @@ namespace System.Text.Tests
Assert.Equal(expected, encoding.GetByteCount(chars));
Assert.Equal(expected, encoding.GetByteCount(charArray));
}
// Use GetByteCount(char[], int, int)
Assert.Equal(expected, encoding.GetByteCount(charArray, index, count));
@@ -65,6 +69,7 @@ namespace System.Text.Tests
byte[] charArrayResultBasic = encoding.GetBytes(source.ToCharArray());
VerifyGetBytes(charArrayResultBasic, 0, charArrayResultBasic.Length, originalBytes, expectedBytes);
}
// Use GetBytes(char[], int, int)
byte[] charArrayResultAdvanced = encoding.GetBytes(source.ToCharArray(), index, count);
VerifyGetBytes(charArrayResultAdvanced, 0, charArrayResultAdvanced.Length, originalBytes, expectedBytes);
@@ -222,5 +227,13 @@ namespace System.Text.Tests
// Use GetString(byte[], int, int)
Assert.Equal(expected, encoding.GetString(bytes, index, count));
}
#if !netcoreapp
// Netcoreapp adds GetByteCount(string, int, int) and GetBytes(string, int, int) APIs.
// To use the common data from the Encode(...) entry point to these tests, we can define stubs that
// do nothing with netfx or netstandard. However, these are defined (they test the new APIs) with netcoreapp.
private static void GetByteCount_NetCoreApp(Encoding encoding, string chars, int index, int count, int expected) {}
private static void GetBytes_NetCoreApp(Encoding encoding, string chars, int index, int count, byte[] expected) {}
#endif
}
}

View File

@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;
namespace System.Text.Tests
{
public static partial class EncodingHelpers
{
private static void GetByteCount_NetCoreApp(Encoding encoding, string chars, int index, int count, int expected)
{
// Use GetByteCount(string, int, int)
Assert.Equal(expected, encoding.GetByteCount(chars, index, count));
}
private static void GetBytes_NetCoreApp(Encoding encoding, string chars, int index, int count, byte[] expected)
{
// Use GetBytes(string, int, int)
byte[] stringResultAdvanced = encoding.GetBytes(chars, index, count);
VerifyGetBytes(stringResultAdvanced, 0, stringResultAdvanced.Length, new byte[expected.Length], expected);
}
}
}

View File

@@ -7,7 +7,7 @@ using Xunit;
namespace System.Text.Tests
{
public static class NegativeEncodingTests
public static partial class NegativeEncodingTests
{
public static IEnumerable<object[]> Encodings_TestData()
{
@@ -40,10 +40,12 @@ namespace System.Text.Tests
// Chars is null
Assert.Throws<ArgumentNullException>(encoding is ASCIIEncoding ? "chars" : "s", () => encoding.GetByteCount((string)null));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount((char[])null));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount(null, 0, 0));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetByteCount((char[])null, 0, 0));
// Index or count < 0
// Index < 0
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount(new char[3], -1, 0));
// Count < 0
Assert.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount(new char[3], 0, -1));
// Index + count > chars.Length
@@ -71,7 +73,7 @@ namespace System.Text.Tests
// Source is null
Assert.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetBytes(null, 0, 0));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null, 0, 0));
Assert.Throws<ArgumentNullException>(expectedStringParamName, () => encoding.GetBytes((string)null, 0, 0, new byte[1], 0));
Assert.Throws<ArgumentNullException>("chars", () => encoding.GetBytes((char[])null, 0, 0, new byte[1], 0));
@@ -308,6 +310,9 @@ namespace System.Text.Tests
Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(chars));
Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray));
}
Assert.Throws<EncoderFallbackException>(() => encoding.GetByteCount(charsArray, index, count));
Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(charsArray, index, count));
Assert.Throws<EncoderFallbackException>(() => encoding.GetBytes(chars, index, count, bytes, 0));

View File

@@ -0,0 +1,52 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using Xunit;
namespace System.Text.Tests
{
public static partial class NegativeEncodingTests
{
[Theory]
[MemberData(nameof(Encodings_TestData))]
public static unsafe void GetByteCount_Invalid_NetCoreApp(Encoding encoding)
{
// Chars is null
Assert.Throws<ArgumentNullException>("s", () => encoding.GetByteCount((string)null, 0, 0));
// Index < 0
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", -1, 0));
// Count < 0
Assert.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount("abc", 0, -1));
// Index + count > chars.Length
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 0, 4));
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 1, 3));
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 2, 2));
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 3, 1));
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 4, 0));
}
[Theory]
[MemberData(nameof(Encodings_TestData))]
public static unsafe void GetBytes_Invalid_NetCoreApp(Encoding encoding)
{
// Source is null
Assert.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null, 0, 0));
// CharIndex < 0
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", -1, 0));
// CharCount < 0
Assert.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes("a", 0, -1));
// CharIndex + charCount > source.Length
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 2, 0));
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 1, 1));
Assert.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 0, 2));
}
}
}

View File

@@ -4,6 +4,7 @@
<PropertyGroup>
<IncludePerformanceTests>true</IncludePerformanceTests>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProjectGuid>{859C92CB-72FB-453C-A363-7CD025E29B1D}</ProjectGuid>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
@@ -14,5 +15,11 @@
<Link>Common\System\PerfUtils.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(CommonPath)\..\perf\PerfRunner\PerfRunner.csproj">
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
<Name>PerfRunner</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Text.Encoding.Tests.csproj" />
<Project Include="System.Text.Encoding.Tests.csproj">
<TargetGroup>netstandard1.3</TargetGroup>
<TestTFMs>netcoreapp1.0</TestTFMs>
</Project>
<Project Include="System.Text.Encoding.Tests.csproj">
<TargetGroup>netstandard1.3</TargetGroup>
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>netcore50;net46</TestTFMs>
</Project>
<Project Include="Performance\System.Text.Encoding.Performance.Tests.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{9574CEEC-5554-411B-B44C-6CA9EC1CEB08}</ProjectGuid>
<ProjectGuid>{3BB28F2F-51DF-49A3-A0BF-E1C5C0D7E3E0}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants Condition="'$(TargetGroup)'=='netcoreapp'">$(DefineConstants);netcoreapp</DefineConstants>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.3-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="ASCIIEncoding\ASCIIEncodingEncode.cs" />
<Compile Include="ASCIIEncoding\ASCIIEncodingDecode.cs" />
@@ -39,7 +40,9 @@
<Compile Include="Fallback\EncoderExceptionFallbackTests.cs" />
<Compile Include="Fallback\DecoderExceptionFallbackTests.cs" />
<Compile Include="NegativeEncodingTests.cs" />
<Compile Include="NegativeEncodingTests.netcoreapp.cs" Condition="'$(TargetGroup)'=='netcoreapp'" />
<Compile Include="EncodingTestHelpers.cs" />
<Compile Include="EncodingTestHelpers.netcoreapp.cs" Condition="'$(TargetGroup)'=='netcoreapp'" />
<Compile Include="Latin1Encoding\Latin1EncodingEncode.cs" />
<Compile Include="Latin1Encoding\Latin1EncodingDecode.cs" />
<Compile Include="Latin1Encoding\Latin1EncodingGetMaxByteCount.cs" />
@@ -72,12 +75,10 @@
<Compile Include="UTF8Encoding\UTF8EncodingGetMaxCharCount.cs" />
<Compile Include="UTF8Encoding\UTF8EncodingTests.cs" />
<Compile Include="$(CommonTestPath)\System\RandomDataGenerator.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<Compile Include="Encoding\Encoding.netstandard.cs" />
<Compile Include="UnicodeEncoding\UnicodeEncoding.netstandard.cs" />
<Compile Include="Decoder\Decoder.netstandard.cs" />
<Compile Include="Encoder\Encoder.netstandard.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>