Consolidate .netcoreapp.cs files because System.Text.Encoding project is no longer...
authorRoman Marusyk <Marusyk@users.noreply.github.com>
Fri, 1 Nov 2019 13:58:20 +0000 (14:58 +0100)
committerJan Kotas <jkotas@microsoft.com>
Fri, 1 Nov 2019 13:58:20 +0000 (06:58 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/1394f2df79628c9f18f8de0dd4bbd6ce4984d807

src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingDecode.cs
src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingDecode.netcoreapp.cs [deleted file]
src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingEncode.cs
src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingEncode.netcoreapp.cs [deleted file]
src/libraries/System.Text.Encoding/tests/Decoder/DecoderSpanTests.cs [moved from src/libraries/System.Text.Encoding/tests/Decoder/DecoderSpanTests.netcoreapp.cs with 98% similarity]
src/libraries/System.Text.Encoding/tests/Encoder/EncoderSpanTests.cs [moved from src/libraries/System.Text.Encoding/tests/Encoder/EncoderSpanTests.netcoreapp.cs with 98% similarity]
src/libraries/System.Text.Encoding/tests/EncodingTestHelpers.cs
src/libraries/System.Text.Encoding/tests/EncodingTestHelpers.netcoreapp.cs [deleted file]
src/libraries/System.Text.Encoding/tests/NegativeEncodingTests.cs
src/libraries/System.Text.Encoding/tests/NegativeEncodingTests.netcoreapp.cs [deleted file]
src/libraries/System.Text.Encoding/tests/System.Text.Encoding.Tests.csproj

index 5f61f82..04ad268 100644 (file)
@@ -3,11 +3,12 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Collections.Generic;
+using System.Linq;
 using Xunit;
 
 namespace System.Text.Tests
 {
-    public partial class ASCIIEncodingDecode
+    public class ASCIIEncodingDecode
     {
         public static IEnumerable<object[]> Decode_TestData()
         {
@@ -75,5 +76,50 @@ namespace System.Text.Tests
             }
             return new string(chars);
         }
+
+        [Theory]
+        [InlineData("hello!", 6)]
+        [InlineData("hello\u1234there!", 16)]
+        [InlineData("\ud800\udc00", 10)]
+        public void GetByteCount_WithReplacementFallback(string input, int expectedByteCount)
+        {
+            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("abcde"), DecoderFallback.ExceptionFallback);
+            Assert.Equal(expectedByteCount, encoding.GetByteCount(input));
+        }
+
+        [Fact]
+        public void GetByteCount_WithSingleCharNonAsciiReplacementFallback_ValidatesAscii()
+        {
+            // Tests trying to replace one non-ASCII character with another, which should cause
+            // fallback logic to identify the invalid data and abort the operation.
+
+            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("\u1234"), DecoderFallback.ExceptionFallback);
+            Assert.Throws<ArgumentException>("chars", () => encoding.GetByteCount("\u0080"));
+        }
+
+        [Theory]
+        [InlineData("hello!", "hello!")]
+        [InlineData("hello\u1234there!", "helloabcdethere!")]
+        [InlineData("\ud800\udc00", "abcdeabcde")]
+        public void GetBytes_WithReplacementFallback(string input, string expectedResult)
+        {
+            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("abcde"), DecoderFallback.ExceptionFallback);
+            Assert.Equal(WideToAsciiStr(expectedResult), encoding.GetBytes(input));
+        }
+
+        [Fact]
+        public void GetBytes_WithNonAsciiInput_AndSingleCharNonAsciiReplacementFallback_Throws()
+        {
+            // Tests trying to replace one non-ASCII character with another, which should cause
+            // fallback logic to identify the invalid data and abort the operation.
+
+            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("\u1234"), DecoderFallback.ExceptionFallback);
+            Assert.Throws<ArgumentException>("chars", () => encoding.GetBytes("\u0080"));
+        }
+
+        private static byte[] WideToAsciiStr(string input)
+        {
+            return input.Select(ch => (byte)checked((sbyte)ch)).ToArray(); // makes sure each char is 00..7F
+        }
     }
 }
diff --git a/src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingDecode.netcoreapp.cs b/src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingDecode.netcoreapp.cs
deleted file mode 100644 (file)
index 2c2983a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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.Linq;
-using Xunit;
-
-namespace System.Text.Tests
-{
-    public partial class ASCIIEncodingDecode
-    {
-        [Theory]
-        [InlineData("hello!", 6)]
-        [InlineData("hello\u1234there!", 16)]
-        [InlineData("\ud800\udc00", 10)]
-        public void GetByteCount_WithReplacementFallback(string input, int expectedByteCount)
-        {
-            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("abcde"), DecoderFallback.ExceptionFallback);
-            Assert.Equal(expectedByteCount, encoding.GetByteCount(input));
-        }
-
-        [Fact]
-        public void GetByteCount_WithSingleCharNonAsciiReplacementFallback_ValidatesAscii()
-        {
-            // Tests trying to replace one non-ASCII character with another, which should cause
-            // fallback logic to identify the invalid data and abort the operation.
-
-            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("\u1234"), DecoderFallback.ExceptionFallback);
-            Assert.Throws<ArgumentException>("chars", () => encoding.GetByteCount("\u0080"));
-        }
-
-        [Theory]
-        [InlineData("hello!", "hello!")]
-        [InlineData("hello\u1234there!", "helloabcdethere!")]
-        [InlineData("\ud800\udc00", "abcdeabcde")]
-        public void GetBytes_WithReplacementFallback(string input, string expectedResult)
-        {
-            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("abcde"), DecoderFallback.ExceptionFallback);
-            Assert.Equal(WideToAsciiStr(expectedResult), encoding.GetBytes(input));
-        }
-
-        [Fact]
-        public void GetBytes_WithNonAsciiInput_AndSingleCharNonAsciiReplacementFallback_Throws()
-        {
-            // Tests trying to replace one non-ASCII character with another, which should cause
-            // fallback logic to identify the invalid data and abort the operation.
-
-            Encoding encoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("\u1234"), DecoderFallback.ExceptionFallback);
-            Assert.Throws<ArgumentException>("chars", () => encoding.GetBytes("\u0080"));
-        }
-
-        private static byte[] WideToAsciiStr(string input)
-        {
-            return input.Select(ch => (byte)checked((sbyte)ch)).ToArray(); // makes sure each char is 00..7F
-        }
-    }
-}
index 6d09cd6..ad95697 100644 (file)
@@ -3,11 +3,12 @@
 // See the LICENSE file in the project root for more information.
 
 using System.Collections.Generic;
+using System.Linq;
 using Xunit;
 
 namespace System.Text.Tests
 {
-    public partial class ASCIIEncodingEncode
+    public class ASCIIEncodingEncode
     {
         public static IEnumerable<object[]> Encode_TestData()
         {
@@ -110,5 +111,84 @@ namespace System.Text.Tests
             }
             return bytes;
         }
+
+        [Theory]
+        [InlineData("hello!", 6)]
+        [InlineData("hello\u0080there!", 16)]
+        [InlineData("\u00ff\u00ff", 10)]
+        public void GetCharCount_WithReplacementFallback(string input, int expectedCharCount)
+        {
+            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new DecoderReplacementFallback("abcde"));
+            Assert.Equal(expectedCharCount, encoding.GetCharCount(WideToNarrowStr(input)));
+        }
+
+        [Fact]
+        public void GetCharCount_WithInvalidFallbackBuffer_ValidatesAscii()
+        {
+            // Internal fallback logic should notice that we're about to write out a standalone
+            // surrogate character and should abort the operation.
+
+            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new StandaloneLowSurrogateDecoderFallback());
+            Assert.Throws<ArgumentException>(() => encoding.GetCharCount(new byte[] { 0x80 }));
+        }
+
+        [Theory]
+        [InlineData("hello!", "hello!")]
+        [InlineData("hello\u0080there!", "helloabcdethere!")]
+        [InlineData("\u00ff\u00ff", "abcdeabcde")]
+        public void GetChars_WithReplacementFallback(string input, string expectedResult)
+        {
+            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new DecoderReplacementFallback("abcde"));
+            Assert.Equal(expectedResult, encoding.GetChars(WideToNarrowStr(input)));
+        }
+
+        [Fact]
+        public void GetChars_WithNonAsciiInput_AndSingleCharNonAsciiReplacementFallback_Throws()
+        {
+            // Internal fallback logic should notice that we're about to write out a standalone
+            // surrogate character and should abort the operation.
+
+            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new StandaloneLowSurrogateDecoderFallback());
+            Assert.Throws<ArgumentException>(() => encoding.GetChars(new byte[] { 0x80 }));
+        }
+
+        private static byte[] WideToNarrowStr(string input)
+        {
+            return input.Select(ch => checked((byte)ch)).ToArray(); // makes sure each char is 00..FF
+        }
+
+        private class StandaloneLowSurrogateDecoderFallback : DecoderFallback
+        {
+            public override int MaxCharCount => 1;
+
+            public override DecoderFallbackBuffer CreateFallbackBuffer()
+            {
+                return new InnerFallbackBuffer();
+            }
+
+            private class InnerFallbackBuffer : DecoderFallbackBuffer
+            {
+                private int _remaining;
+
+                public override int Remaining => _remaining;
+
+                public override bool Fallback(byte[] bytesUnknown, int index)
+                {
+                    _remaining = 1;
+                    return true;
+                }
+
+                public override char GetNextChar()
+                {
+                    // Return a standalone low surrogate
+                    return (--_remaining >= 0) ? '\udc00' : default;
+                }
+
+                public override bool MovePrevious()
+                {
+                    throw new NotImplementedException();
+                }
+            }
+        }
     }
 }
diff --git a/src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingEncode.netcoreapp.cs b/src/libraries/System.Text.Encoding/tests/ASCIIEncoding/ASCIIEncodingEncode.netcoreapp.cs
deleted file mode 100644 (file)
index 922d9e0..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// 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.Linq;
-using Xunit;
-
-namespace System.Text.Tests
-{
-    public partial class ASCIIEncodingEncode
-    {
-        [Theory]
-        [InlineData("hello!", 6)]
-        [InlineData("hello\u0080there!", 16)]
-        [InlineData("\u00ff\u00ff", 10)]
-        public void GetCharCount_WithReplacementFallback(string input, int expectedCharCount)
-        {
-            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new DecoderReplacementFallback("abcde"));
-            Assert.Equal(expectedCharCount, encoding.GetCharCount(WideToNarrowStr(input)));
-        }
-
-        [Fact]
-        public void GetCharCount_WithInvalidFallbackBuffer_ValidatesAscii()
-        {
-            // Internal fallback logic should notice that we're about to write out a standalone
-            // surrogate character and should abort the operation.
-
-            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new StandaloneLowSurrogateDecoderFallback());
-            Assert.Throws<ArgumentException>(() => encoding.GetCharCount(new byte[] { 0x80 }));
-        }
-
-        [Theory]
-        [InlineData("hello!", "hello!")]
-        [InlineData("hello\u0080there!", "helloabcdethere!")]
-        [InlineData("\u00ff\u00ff", "abcdeabcde")]
-        public void GetChars_WithReplacementFallback(string input, string expectedResult)
-        {
-            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new DecoderReplacementFallback("abcde"));
-            Assert.Equal(expectedResult, encoding.GetChars(WideToNarrowStr(input)));
-        }
-
-        [Fact]
-        public void GetChars_WithNonAsciiInput_AndSingleCharNonAsciiReplacementFallback_Throws()
-        {
-            // Internal fallback logic should notice that we're about to write out a standalone
-            // surrogate character and should abort the operation.
-
-            Encoding encoding = Encoding.GetEncoding("ascii", EncoderFallback.ExceptionFallback, new StandaloneLowSurrogateDecoderFallback());
-            Assert.Throws<ArgumentException>(() => encoding.GetChars(new byte[] { 0x80 }));
-        }
-
-        private static byte[] WideToNarrowStr(string input)
-        {
-            return input.Select(ch => checked((byte)ch)).ToArray(); // makes sure each char is 00..FF
-        }
-
-        private class StandaloneLowSurrogateDecoderFallback : DecoderFallback
-        {
-            public override int MaxCharCount => 1;
-
-            public override DecoderFallbackBuffer CreateFallbackBuffer()
-            {
-                return new InnerFallbackBuffer();
-            }
-
-            private class InnerFallbackBuffer : DecoderFallbackBuffer
-            {
-                private int _remaining;
-
-                public override int Remaining => _remaining;
-
-                public override bool Fallback(byte[] bytesUnknown, int index)
-                {
-                    _remaining = 1;
-                    return true;
-                }
-
-                public override char GetNextChar()
-                {
-                    // Return a standalone low surrogate
-                    return (--_remaining >= 0) ? '\udc00' : default;
-                }
-
-                public override bool MovePrevious()
-                {
-                    throw new NotImplementedException();
-                }
-            }
-        }
-    }
-}
@@ -6,7 +6,7 @@ using Xunit;
 
 namespace System.Text.Encodings.Tests
 {
-    public partial class DecoderTests
+    public class DecoderTests
     {
         [Fact]
         public static void GetCharCount_Span_MatchesEncodingCharCount()
@@ -6,7 +6,7 @@ using Xunit;
 
 namespace System.Text.Encodings.Tests
 {
-    public partial class EncoderTests
+    public class EncoderTests
     {
         [Fact]
         public static void GetByteCount_Span_MatchesEncodingByteCount()
index d860c8a..5a53a66 100644 (file)
@@ -6,7 +6,7 @@ using Xunit;
 
 namespace System.Text.Tests
 {
-    public static partial class EncodingHelpers
+    public static class EncodingHelpers
     {
         public static void Encode(Encoding encoding, string chars, int index, int count, byte[] expected)
         {
@@ -232,11 +232,64 @@ namespace System.Text.Tests
             Assert.Equal(expected, encoding.GetString(bytes, index, count));
         }
 
-        // Netcoreapp adds several Encoding members.
-        static partial void GetByteCount_NetCoreApp(Encoding encoding, string chars, int index, int count, int expected);
-        static partial void GetBytes_NetCoreApp(Encoding encoding, string chars, int index, int count, byte[] expected);
-        static partial void GetCharCount_NetCoreApp(Encoding encoding, byte[] bytes, int index, int count, int expected);
-        static partial void VerifyGetChars_NetCoreApp(Encoding encoding, byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, char[] expectedChars);
-        static partial void GetString_NetCoreApp(Encoding encoding, byte[] bytes, int index, int count, string expected);
+        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));
+
+            // Use GetByteCount(ReadOnlySpan<char> chars)
+            Assert.Equal(expected, encoding.GetByteCount(chars.AsSpan(index, count)));
+
+            if (count == 0)
+                Assert.Equal(expected, encoding.GetByteCount(ReadOnlySpan<char>.Empty));
+        }
+
+        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);
+
+            // Use GetBytes(ReadOnlySpan<char>, Span<byte>)
+            Array.Clear(stringResultAdvanced, 0, stringResultAdvanced.Length);
+            Assert.Equal(expected.Length, encoding.GetBytes(chars.AsSpan(index, count), (Span<byte>)stringResultAdvanced));
+            VerifyGetBytes(stringResultAdvanced, 0, stringResultAdvanced.Length, new byte[expected.Length], expected);
+
+            if (count == 0)
+                Assert.Equal(expected.Length, encoding.GetBytes(ReadOnlySpan<char>.Empty, (Span<byte>)stringResultAdvanced));
+        }
+
+        static void GetCharCount_NetCoreApp(Encoding encoding, byte[] bytes, int index, int count, int expected)
+        {
+            // Use GetCharCount(ReadOnlySpan<byte>)
+            Assert.Equal(expected, encoding.GetCharCount(new ReadOnlySpan<byte>(bytes, index, count)));
+
+            if (count == 0)
+                Assert.Equal(expected, encoding.GetCharCount(ReadOnlySpan<byte>.Empty));
+        }
+
+        static void VerifyGetChars_NetCoreApp(Encoding encoding, byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, char[] expectedChars)
+        {
+            // Use GetChars(ReadOnlySpan<byte>, Span<char>)
+            char[] byteChars = (char[])chars.Clone();
+            int charCount = encoding.GetChars(new ReadOnlySpan<byte>(bytes, byteIndex, byteCount), new Span<char>(byteChars).Slice(charIndex));
+            VerifyGetChars(byteChars, charIndex, charCount, (char[])chars.Clone(), expectedChars);
+            Assert.Equal(expectedChars.Length, charCount);
+
+            if (byteCount == 0)
+            {
+                charCount = encoding.GetChars(ReadOnlySpan<byte>.Empty, new Span<char>(byteChars).Slice(charIndex));
+                Assert.Equal(expectedChars.Length, charCount);
+            }
+        }
+
+        static void GetString_NetCoreApp(Encoding encoding, byte[] bytes, int index, int count, string expected)
+        {
+            // Use GetString(ReadOnlySpan<byte>)
+            Assert.Equal(expected, encoding.GetString(new ReadOnlySpan<byte>(bytes, index, count)));
+
+            if (count == 0)
+                Assert.Equal(expected, encoding.GetString(ReadOnlySpan<byte>.Empty));
+        }
     }
 }
diff --git a/src/libraries/System.Text.Encoding/tests/EncodingTestHelpers.netcoreapp.cs b/src/libraries/System.Text.Encoding/tests/EncodingTestHelpers.netcoreapp.cs
deleted file mode 100644 (file)
index 470baac..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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
-    {
-        static partial 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));
-
-            // Use GetByteCount(ReadOnlySpan<char> chars)
-            Assert.Equal(expected, encoding.GetByteCount(chars.AsSpan(index, count)));
-
-            if (count == 0)
-                Assert.Equal(expected, encoding.GetByteCount(ReadOnlySpan<char>.Empty));
-        }
-
-        static partial 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);
-
-            // Use GetBytes(ReadOnlySpan<char>, Span<byte>)
-            Array.Clear(stringResultAdvanced, 0, stringResultAdvanced.Length);
-            Assert.Equal(expected.Length, encoding.GetBytes(chars.AsSpan(index, count), (Span<byte>)stringResultAdvanced));
-            VerifyGetBytes(stringResultAdvanced, 0, stringResultAdvanced.Length, new byte[expected.Length], expected);
-
-            if (count == 0)
-                Assert.Equal(expected.Length, encoding.GetBytes(ReadOnlySpan<char>.Empty, (Span<byte>)stringResultAdvanced));
-        }
-
-        static partial void GetCharCount_NetCoreApp(Encoding encoding, byte[] bytes, int index, int count, int expected)
-        {
-            // Use GetCharCount(ReadOnlySpan<byte>)
-            Assert.Equal(expected, encoding.GetCharCount(new ReadOnlySpan<byte>(bytes, index, count)));
-
-            if (count == 0)
-                Assert.Equal(expected, encoding.GetCharCount(ReadOnlySpan<byte>.Empty));
-        }
-
-        static partial void VerifyGetChars_NetCoreApp(Encoding encoding, byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, char[] expectedChars)
-        {
-            // Use GetChars(ReadOnlySpan<byte>, Span<char>)
-            char[] byteChars = (char[])chars.Clone();
-            int charCount = encoding.GetChars(new ReadOnlySpan<byte>(bytes, byteIndex, byteCount), new Span<char>(byteChars).Slice(charIndex));
-            VerifyGetChars(byteChars, charIndex, charCount, (char[])chars.Clone(), expectedChars);
-            Assert.Equal(expectedChars.Length, charCount);
-
-            if (byteCount == 0)
-            {
-                charCount = encoding.GetChars(ReadOnlySpan<byte>.Empty, new Span<char>(byteChars).Slice(charIndex));
-                Assert.Equal(expectedChars.Length, charCount);
-            }
-        }
-
-        static partial void GetString_NetCoreApp(Encoding encoding, byte[] bytes, int index, int count, string expected)
-        {
-            // Use GetString(ReadOnlySpan<byte>)
-            Assert.Equal(expected, encoding.GetString(new ReadOnlySpan<byte>(bytes, index, count)));
-
-            if (count == 0)
-                Assert.Equal(expected, encoding.GetString(ReadOnlySpan<byte>.Empty));
-        }
-    }
-}
index c6ad2f3..0477769 100644 (file)
@@ -2,13 +2,12 @@
 // 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;
 using System.Collections.Generic;
 using Xunit;
 
 namespace System.Text.Tests
 {
-    public static partial class NegativeEncodingTests
+    public static class NegativeEncodingTests
     {
         public static IEnumerable<object[]> Encodings_TestData()
         {
@@ -618,6 +617,46 @@ namespace System.Text.Tests
             AssertExtensions.Throws<ArgumentException>("chars", () => decoder.Convert(new byte[4], 0, 4, new char[0], 0, 0, flush, out charsUsed, out bytesUsed, out completed));
             VerifyOutParams();
         }
+
+        [Theory]
+        [MemberData(nameof(Encodings_TestData))]
+        public static unsafe void GetByteCount_Invalid_NetCoreApp(Encoding encoding)
+        {
+            // Chars is null
+            AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetByteCount((string)null, 0, 0));
+
+            // Index < 0
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", -1, 0));
+
+            // Count < 0
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount("abc", 0, -1));
+
+            // Index + count > chars.Length
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 0, 4));
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 1, 3));
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 2, 2));
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 3, 1));
+            AssertExtensions.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
+            AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null, 0, 0));
+
+            // CharIndex < 0
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", -1, 0));
+
+            // CharCount < 0
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes("a", 0, -1));
+
+            // CharIndex + charCount > source.Length
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 2, 0));
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 1, 1));
+            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 0, 2));
+        }
     }
 
     public class HighMaxCharCountEncoderFallback : EncoderFallback
diff --git a/src/libraries/System.Text.Encoding/tests/NegativeEncodingTests.netcoreapp.cs b/src/libraries/System.Text.Encoding/tests/NegativeEncodingTests.netcoreapp.cs
deleted file mode 100644 (file)
index 3728611..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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;
-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
-            AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetByteCount((string)null, 0, 0));
-
-            // Index < 0
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", -1, 0));
-
-            // Count < 0
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount("abc", 0, -1));
-
-            // Index + count > chars.Length
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 0, 4));
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 1, 3));
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 2, 2));
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetByteCount("abc", 3, 1));
-            AssertExtensions.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
-            AssertExtensions.Throws<ArgumentNullException>("s", () => encoding.GetBytes((string)null, 0, 0));
-
-            // CharIndex < 0
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", -1, 0));
-
-            // CharCount < 0
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetBytes("a", 0, -1));
-
-            // CharIndex + charCount > source.Length
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 2, 0));
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 1, 1));
-            AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => encoding.GetBytes("a", 0, 2));
-        }
-    }
-}
index bf0322f..60332f8 100644 (file)
@@ -8,14 +8,12 @@
   <ItemGroup>
     <Compile Include="ASCIIEncoding\ASCIIEncodingEncode.cs" />
     <Compile Include="ASCIIEncoding\ASCIIEncodingDecode.cs" />
-    <Compile Include="ASCIIEncoding\ASCIIEncodingEncode.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
-    <Compile Include="ASCIIEncoding\ASCIIEncodingDecode.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
     <Compile Include="ASCIIEncoding\ASCIIEncodingGetDecoder.cs" />
     <Compile Include="ASCIIEncoding\ASCIIEncodingGetEncoder.cs" />
     <Compile Include="ASCIIEncoding\ASCIIEncodingGetMaxByteCount.cs" />
     <Compile Include="ASCIIEncoding\ASCIIEncodingGetMaxCharCount.cs" />
     <Compile Include="ASCIIEncoding\ASCIIEncodingTests.cs" />
-    <Compile Include="Decoder\DecoderSpanTests.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
+    <Compile Include="Decoder\DecoderSpanTests.cs" />
     <Compile Include="Decoder\DecoderConvert2.cs" />
     <Compile Include="Decoder\DecoderCtor.cs" />
     <Compile Include="Decoder\DecoderGetCharCount2.cs" />
@@ -26,7 +24,7 @@
     <Compile Include="DecoderFallback\DecoderFallbackTests.cs" />
     <Compile Include="DecoderFallbackException\DecoderFallbackExceptionTests.cs" />
     <Compile Include="EncoderFallbackException\EncoderFallbackExceptionTests.cs" />
-    <Compile Include="Encoder\EncoderSpanTests.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
+    <Compile Include="Encoder\EncoderSpanTests.cs" />
     <Compile Include="Encoder\EncoderConvert2.cs" />
     <Compile Include="Encoder\EncoderCtor.cs" />
     <Compile Include="Encoder\EncoderGetByteCount2.cs" />
@@ -40,9 +38,7 @@
     <Compile Include="Fallback\EncoderExceptionFallbackTests.cs" />
     <Compile Include="Fallback\DecoderExceptionFallbackTests.cs" />
     <Compile Include="NegativeEncodingTests.cs" />
-    <Compile Include="NegativeEncodingTests.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
     <Compile Include="EncodingTestHelpers.cs" />
-    <Compile Include="EncodingTestHelpers.netcoreapp.cs" Condition="'$(TargetsNetCoreApp)' == 'true'" />
     <Compile Include="Latin1Encoding\Latin1EncodingEncode.cs" />
     <Compile Include="Latin1Encoding\Latin1EncodingDecode.cs" />
     <Compile Include="Latin1Encoding\Latin1EncodingGetMaxByteCount.cs" />