Imported Upstream version 5.10.0.69

Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-29 19:03:06 +00:00
parent d8f8abd549
commit e2950ec768
6283 changed files with 453847 additions and 91879 deletions

View File

@ -8,7 +8,6 @@
namespace System.Text
{
[System.Security.SecurityCriticalAttribute]
public sealed partial class CodePagesEncodingProvider
{
internal CodePagesEncodingProvider() { }

View File

@ -3,11 +3,12 @@
<PropertyGroup>
<PackageConfigurations>
netstandard;
netcoreapp-Windows_NT;
netcoreapp2.0-Windows_NT;
netstandard-Windows_NT;
</PackageConfigurations>
<BuildConfigurations>
$(PackageConfigurations);
netcoreapp-Windows_NT;
uap-Windows_NT;
</BuildConfigurations>
</PropertyGroup>

View File

@ -8,7 +8,6 @@ using System.Security;
namespace Microsoft.Win32.SafeHandles
{
[SecurityCritical]
internal sealed class SafeAllocHHandle : SafeBuffer
{
private SafeAllocHHandle() : base(true) { }
@ -23,7 +22,6 @@ namespace Microsoft.Win32.SafeHandles
get { return new SafeAllocHHandle(IntPtr.Zero); }
}
[System.Security.SecurityCritical]
override protected bool ReleaseHandle()
{
if (handle != IntPtr.Zero)

View File

@ -12,6 +12,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp2.0-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp2.0-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
@ -64,7 +66,6 @@
<None Include="Data\CodePageNameMappings.csv" />
<None Include="Data\PreferredCodePageNames.csv" />
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Tools" />
<Reference Include="System.Resources.ResourceManager" />

View File

@ -55,13 +55,11 @@ namespace System.Text
protected char[] arrayUnicodeBestFit = null;
protected char[] arrayBytesBestFit = null;
[System.Security.SecurityCritical] // auto-generated
internal BaseCodePageEncoding(int codepage)
: this(codepage, codepage)
{
}
[System.Security.SecurityCritical] // auto-generated
internal BaseCodePageEncoding(int codepage, int dataCodePage)
: base(codepage, new InternalEncoderBestFitFallback(null), new InternalDecoderBestFitFallback(null))
{
@ -157,7 +155,6 @@ namespace System.Text
protected int m_dataSize;
// Safe handle wrapper around section map view
[System.Security.SecurityCritical] // auto-generated
protected SafeAllocHHandle safeNativeMemoryHandle = null;
internal static Stream GetEncodingDataStream(String tableName)
@ -182,7 +179,6 @@ namespace System.Text
}
// We need to load tables for our code page
[System.Security.SecurityCritical] // auto-generated
private unsafe void LoadCodePageTables()
{
if (!FindCodePage(dataTableCodePage))
@ -196,7 +192,6 @@ namespace System.Text
}
// Look up the code page pointer
[System.Security.SecurityCritical] // auto-generated
private unsafe bool FindCodePage(int codePage)
{
Debug.Assert(m_codePageHeader != null && m_codePageHeader.Length == CODEPAGE_HEADER_SIZE, "m_codePageHeader expected to match in size the struct CodePageHeader");
@ -255,7 +250,6 @@ namespace System.Text
}
// Get our code page byte count
[System.Security.SecurityCritical] // auto-generated
internal static unsafe int GetCodePageByteSize(int codePage)
{
// Loop through all of the m_pCodePageIndex[] items to find our code page
@ -296,11 +290,9 @@ namespace System.Text
}
// We have a managed code page entry, so load our tables
[System.Security.SecurityCritical]
protected abstract unsafe void LoadManagedCodePage();
// Allocate memory to load our code page
[System.Security.SecurityCritical] // auto-generated
protected unsafe byte* GetNativeMemory(int iSize)
{
if (safeNativeMemoryHandle == null)
@ -314,10 +306,8 @@ namespace System.Text
return (byte*)safeNativeMemoryHandle.DangerousGetHandle();
}
[System.Security.SecurityCritical]
protected abstract unsafe void ReadBestFitTable();
[System.Security.SecuritySafeCritical]
internal char[] GetBestFitUnicodeToBytesData()
{
// Read in our best fit table if necessary
@ -329,7 +319,6 @@ namespace System.Text
return arrayUnicodeBestFit;
}
[System.Security.SecuritySafeCritical]
internal char[] GetBestFitBytesToUnicodeData()
{
// Read in our best fit table if necessary
@ -345,7 +334,6 @@ namespace System.Text
// invalid. We detect that by validating the memory section handle then re-initializing the memory
// section by calling LoadManagedCodePage() method and eventually the mapped file handle and
// the memory section pointer will get finalized one more time.
[System.Security.SecurityCritical] // auto-generated
internal unsafe void CheckMemorySection()
{
if (safeNativeMemoryHandle != null && safeNativeMemoryHandle.DangerousGetHandle() == IntPtr.Zero)

View File

@ -2,7 +2,6 @@
// 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.Diagnostics.Contracts;
using System.Collections.Generic;
using System.Threading;

View File

@ -5,7 +5,6 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Text;
using System.Threading;
using System.Security;
@ -18,9 +17,7 @@ namespace System.Text
internal class DBCSCodePageEncoding : BaseCodePageEncoding
{
// Pointers to our memory section parts
[SecurityCritical]
protected unsafe char* mapBytesToUnicode = null; // char 65536
[SecurityCritical]
protected unsafe ushort* mapUnicodeToBytes = null; // byte 65536
protected const char UNKNOWN_CHAR_FLAG = (char)0x0;
@ -33,17 +30,14 @@ namespace System.Text
private int _byteCountUnknown;
protected char charUnknown = (char)0;
[System.Security.SecurityCritical] // auto-generated
public DBCSCodePageEncoding(int codePage) : this(codePage, codePage)
{
}
[System.Security.SecurityCritical] // auto-generated
internal DBCSCodePageEncoding(int codePage, int dataCodePage) : base(codePage, dataCodePage)
{
}
[System.Security.SecurityCritical] // auto-generated
internal DBCSCodePageEncoding(int codePage, int dataCodePage, EncoderFallback enc, DecoderFallback dec) : base(codePage, dataCodePage, enc, dec)
{
}
@ -76,7 +70,6 @@ namespace System.Text
// correspond to those unicode code points.
// We have a managed code page entry, so load our tables
//
[System.Security.SecurityCritical] // auto-generated
protected override unsafe void LoadManagedCodePage()
{
Debug.Assert(m_codePageHeader?.Length > 0);
@ -212,7 +205,6 @@ namespace System.Text
}
// Any special processing for this code page
[System.Security.SecurityCritical] // auto-generated
protected virtual unsafe void CleanUpEndBytes(char* chars)
{
}
@ -233,7 +225,6 @@ namespace System.Text
}
// Read in our best fit table
[System.Security.SecurityCritical] // auto-generated
protected unsafe override void ReadBestFitTable()
{
// Lock so we don't confuse ourselves.
@ -512,7 +503,6 @@ namespace System.Text
// GetByteCount
// Note: We start by assuming that the output will be the same as count. Having
// an encoder or fallback may change that assumption
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count, EncoderNLS encoder)
{
// Just need to ASSERT, this is called by something else internal that checked parameters already
@ -608,7 +598,6 @@ namespace System.Text
return (int)byteCount;
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetBytes(char* chars, int charCount,
byte* bytes, int byteCount, EncoderNLS encoder)
{
@ -759,7 +748,6 @@ namespace System.Text
}
// This is internal and called by something else,
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder)
{
// Just assert, we're called internally so these should be safe, checked already
@ -910,7 +898,6 @@ namespace System.Text
return charCount;
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, DecoderNLS baseDecoder)
{
@ -1120,7 +1107,6 @@ namespace System.Text
{
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Characters would be # of characters + 1 in case high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@ -1141,7 +1127,6 @@ namespace System.Text
{
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// DBCS is pretty much the same, but could have hanging high byte making extra ? and fallback for unknown
long charCount = ((long)byteCount + 1);

View File

@ -155,14 +155,12 @@ namespace System.Text
}
// Clear the buffer
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe void Reset()
{
iCount = -1;
}
// This version just counts the fallback and doesn't actually copy anything.
[System.Security.SecurityCritical] // auto-generated
internal unsafe int InternalFallback(byte[] bytes, byte* pBytes)
// Right now this has both bytes and bytes[], since we might have extra bytes, hence the
// array, and we might need the index, hence the byte*

View File

@ -94,7 +94,6 @@ namespace System.Text
}
// This version just counts the fallback and doesn't actually copy anything.
[System.Security.SecurityCritical] // auto-generated
internal unsafe int InternalFallback(byte[] bytes, byte* pBytes)
// Right now this has both bytes and bytes[], since we might have extra bytes, hence the
// array, and we might need the index, hence the byte*

View File

@ -5,7 +5,6 @@
using System.Text;
using System;
using System.Globalization;
using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Text
@ -91,7 +90,6 @@ namespace System.Text
return GetCharCount(bytes, index, count, false);
}
[System.Security.SecuritySafeCritical] // auto-generated
public override unsafe int GetCharCount(byte[] bytes, int index, int count, bool flush)
{
// Validate Parameters
@ -104,8 +102,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// Avoid null fixed problem
if (bytes.Length == 0)
bytes = new byte[1];
@ -115,7 +111,6 @@ namespace System.Text
return GetCharCount(pBytes + index, count, flush);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetCharCount(byte* bytes, int count, bool flush)
{
// Validate parameters
@ -124,7 +119,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Remember the flush
m_mustFlush = flush;
@ -140,7 +134,6 @@ namespace System.Text
return GetChars(bytes, byteIndex, byteCount, chars, charIndex, false);
}
[System.Security.SecuritySafeCritical] // auto-generated
public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex, bool flush)
{
@ -157,8 +150,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index);
Contract.EndContractBlock();
// Avoid empty input fixed problem
if (bytes.Length == 0)
bytes = new byte[1];
@ -175,7 +166,6 @@ namespace System.Text
pChars + charIndex, charCount, flush);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, bool flush)
{
@ -185,7 +175,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Remember our flush
m_mustFlush = flush;
@ -197,7 +186,6 @@ namespace System.Text
// This method is used when the output buffer might not be big enough.
// Just call the pointer version. (This gets chars)
[System.Security.SecuritySafeCritical] // auto-generated
public override unsafe void Convert(byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex, int charCount, bool flush,
out int bytesUsed, out int charsUsed, out bool completed)
@ -218,8 +206,6 @@ namespace System.Text
if (chars.Length - charIndex < charCount)
throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// Avoid empty input problem
if (bytes.Length == 0)
bytes = new byte[1];
@ -239,7 +225,6 @@ namespace System.Text
// This is the version that used pointers. We call the base encoding worker function
// after setting our appropriate internal variables. This is getting chars
[System.Security.SecurityCritical] // auto-generated
public override unsafe void Convert(byte* bytes, int byteCount,
char* chars, int charCount, bool flush,
out int bytesUsed, out int charsUsed, out bool completed)
@ -250,7 +235,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// We don't want to throw
m_mustFlush = flush;

View File

@ -49,7 +49,6 @@ namespace System.Text
internal class EUCJPEncoding : DBCSCodePageEncoding
{
// This pretends to be CP 932 as far as memory tables are concerned.
[System.Security.SecurityCritical] // auto-generated
public EUCJPEncoding() : base(51932, 932)
{
}
@ -146,7 +145,6 @@ namespace System.Text
return true;
}
[System.Security.SecurityCritical] // auto-generated
protected override unsafe void CleanUpEndBytes(char* chars)
{
// Need to special case CP 51932

View File

@ -8,7 +8,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Text;
using System.Threading;
@ -122,7 +121,6 @@ namespace System.Text
if (!Char.IsLowSurrogate(charUnknownLow))
throw new ArgumentOutOfRangeException(nameof(charUnknownLow), SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF));
Contract.EndContractBlock();
// If we had a buffer already we're being recursive, throw, it's probably at the suspect
// character in our array. 0 is processing last character, < 0 is not falling back
@ -180,7 +178,6 @@ namespace System.Text
}
// Clear the buffer
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe void Reset()
{
_iCount = -1;

View File

@ -30,7 +30,6 @@ namespace System.Text
// Internal Reset
// For example, what if someone fails a conversion and wants to reset one of our fallback buffers?
[System.Security.SecurityCritical] // auto-generated
internal unsafe void InternalReset()
{
charStart = null;
@ -41,7 +40,6 @@ namespace System.Text
// Set the above values
// This can't be part of the constructor because EncoderFallbacks would have to know how to implement these.
[System.Security.SecurityCritical] // auto-generated
internal unsafe void InternalInitialize(char* _charStart, char* _charEnd, EncoderNLS _encoder, bool _setEncoder)
{
charStart = _charStart;
@ -69,7 +67,6 @@ namespace System.Text
// Note that this could also change the contents of encoder, which is the same
// object that the caller is using, so the caller could mess up the encoder for us
// if they aren't careful.
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool InternalFallback(char ch, ref char* chars)
{
// Shouldn't have null charStart

View File

@ -4,7 +4,6 @@
using System.Text;
using System;
using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Text
@ -89,7 +88,6 @@ namespace System.Text
m_fallbackBuffer.Reset();
}
[System.Security.SecuritySafeCritical] // auto-generated
public override unsafe int GetByteCount(char[] chars, int index, int count, bool flush)
{
// Validate input parameters
@ -101,7 +99,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// Avoid empty input problem
if (chars.Length == 0)
@ -116,7 +113,6 @@ namespace System.Text
return result;
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count, bool flush)
{
// Validate input parameters
@ -125,14 +121,12 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
m_mustFlush = flush;
m_throwOnOverflow = true;
return m_encoding.GetByteCount(chars, count, this);
}
[System.Security.SecuritySafeCritical] // auto-generated
public override unsafe int GetBytes(char[] chars, int charIndex, int charCount,
byte[] bytes, int byteIndex, bool flush)
{
@ -148,7 +142,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index);
Contract.EndContractBlock();
if (chars.Length == 0)
chars = new char[1];
@ -166,7 +159,6 @@ namespace System.Text
pBytes + byteIndex, byteCount, flush);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, bool flush)
{
// Validate parameters
@ -175,7 +167,6 @@ namespace System.Text
if (byteCount < 0 || charCount < 0)
throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
m_mustFlush = flush;
m_throwOnOverflow = true;
@ -184,7 +175,6 @@ namespace System.Text
// This method is used when your output buffer might not be large enough for the entire result.
// Just call the pointer version. (This gets bytes)
[System.Security.SecuritySafeCritical] // auto-generated
public override unsafe void Convert(char[] chars, int charIndex, int charCount,
byte[] bytes, int byteIndex, int byteCount, bool flush,
out int charsUsed, out int bytesUsed, out bool completed)
@ -205,8 +195,6 @@ namespace System.Text
if (bytes.Length - byteIndex < byteCount)
throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// Avoid empty input problem
if (chars.Length == 0)
chars = new char[1];
@ -226,7 +214,6 @@ namespace System.Text
// This is the version that uses pointers. We call the base encoding worker function
// after setting our appropriate internal variables. This is getting bytes
[System.Security.SecurityCritical] // auto-generated
public override unsafe void Convert(char* chars, int charCount,
byte* bytes, int byteCount, bool flush,
out int charsUsed, out int bytesUsed, out bool completed)
@ -237,7 +224,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// We don't want to throw
m_mustFlush = flush;

View File

@ -20,7 +20,6 @@ namespace System.Text
private DecoderFallbackBuffer _fallbackBuffer;
private DecoderFallbackBufferHelper _fallbackBufferHelper;
[System.Security.SecurityCritical] // auto-generated
internal unsafe EncodingCharBuffer(EncodingNLS enc, DecoderNLS decoder, char* charStart, int charCount, byte* byteStart, int byteCount)
{
_enc = enc;
@ -47,7 +46,6 @@ namespace System.Text
_fallbackBufferHelper.InternalInitialize(_bytes, _charEnd);
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool AddChar(char ch, int numBytes)
{
if (_chars != null)
@ -66,14 +64,12 @@ namespace System.Text
return true;
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool AddChar(char ch)
{
return AddChar(ch, 1);
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool AddChar(char ch1, char ch2, int numBytes)
{
// Need room for 2 chars
@ -87,7 +83,6 @@ namespace System.Text
return AddChar(ch1, numBytes) && AddChar(ch2, numBytes);
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe void AdjustBytes(int count)
{
_bytes = unchecked(_bytes + count);
@ -95,7 +90,6 @@ namespace System.Text
internal unsafe bool MoreData
{
[System.Security.SecurityCritical] // auto-generated
get
{
return _bytes < _byteEnd;
@ -103,7 +97,6 @@ namespace System.Text
}
// Do we have count more bytes?
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool EvenMoreData(int count)
{
return (_bytes <= _byteEnd - count);
@ -111,7 +104,6 @@ namespace System.Text
// GetNextByte shouldn't be called unless the caller's already checked more data or even more data,
// but we'll double check just to make sure.
[System.Security.SecurityCritical] // auto-generated
internal unsafe byte GetNextByte()
{
Debug.Assert(_bytes < _byteEnd, "[EncodingCharBuffer.GetNextByte]Expected more date");
@ -122,14 +114,12 @@ namespace System.Text
internal unsafe int BytesUsed
{
[System.Security.SecurityCritical] // auto-generated
get
{
return unchecked((int)(_bytes - _byteStart));
}
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool Fallback(byte fallbackByte)
{
// Build our buffer
@ -139,7 +129,6 @@ namespace System.Text
return Fallback(byteBuffer);
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool Fallback(byte byte1, byte byte2)
{
// Build our buffer
@ -149,7 +138,6 @@ namespace System.Text
return Fallback(byteBuffer);
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool Fallback(byte byte1, byte byte2, byte byte3, byte byte4)
{
// Build our buffer
@ -159,7 +147,6 @@ namespace System.Text
return Fallback(byteBuffer);
}
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool Fallback(byte[] byteBuffer)
{
// Do the fallback and add the data.

View File

@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics.Contracts;
using System.Collections;
using System.Globalization;
using System.Resources;
@ -47,7 +46,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe int GetByteCount(char[] chars, int index, int count)
{
// Validate input parameters
@ -59,7 +57,6 @@ namespace System.Text
if (chars.Length - index < count)
throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// If no input, return 0, avoid fixed empty array problem
if (chars.Length == 0)
@ -73,13 +70,11 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe int GetByteCount(String s)
{
// Validate input
if (s == null)
throw new ArgumentNullException(nameof(s));
Contract.EndContractBlock();
fixed (char* pChars = s)
return GetByteCount(pChars, s.Length, null);
@ -87,7 +82,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count)
{
// Validate Parameters
@ -96,7 +90,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Call it with empty encoder
return GetByteCount(chars, count, null);
@ -106,7 +99,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe int GetBytes(String s, int charIndex, int charCount,
byte[] bytes, int byteIndex)
{
@ -121,7 +113,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index);
Contract.EndContractBlock();
int byteCount = bytes.Length - byteIndex;
@ -147,7 +138,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe int GetBytes(char[] chars, int charIndex, int charCount,
byte[] bytes, int byteIndex)
{
@ -163,7 +153,6 @@ namespace System.Text
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index);
Contract.EndContractBlock();
// If nothing to encode return 0, avoid fixed problem
if (chars.Length == 0)
@ -185,7 +174,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
{
// Validate Parameters
@ -194,7 +182,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
return GetBytes(chars, charCount, bytes, byteCount, null);
}
@ -205,7 +192,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe int GetCharCount(byte[] bytes, int index, int count)
{
// Validate Parameters
@ -217,7 +203,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// If no input just return 0, fixed doesn't like 0 length arrays
if (bytes.Length == 0)
@ -230,7 +215,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetCharCount(byte* bytes, int count)
{
// Validate Parameters
@ -239,7 +223,6 @@ namespace System.Text
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
return GetCharCount(bytes, count, null);
}
@ -247,7 +230,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex)
{
@ -263,7 +245,6 @@ namespace System.Text
if (charIndex < 0 || charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index);
Contract.EndContractBlock();
// If no input, return 0 & avoid fixed problem
if (bytes.Length == 0)
@ -285,7 +266,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
[System.Security.SecurityCritical] // auto-generated
public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
{
// Validate Parameters
@ -294,7 +274,6 @@ namespace System.Text
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
return GetChars(bytes, byteCount, chars, charCount, null);
}
@ -305,7 +284,6 @@ namespace System.Text
// All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS)
// So if you fix this, fix the others.
// parent method is safe
[System.Security.SecuritySafeCritical] // overrides public transparent member
public override unsafe String GetString(byte[] bytes, int index, int count)
{
// Validate Parameters
@ -317,7 +295,6 @@ namespace System.Text
if (bytes.Length - index < count)
throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer);
Contract.EndContractBlock();
// Avoid problems with empty input buffer
if (bytes.Length == 0) return String.Empty;

View File

@ -85,7 +85,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
@ -116,7 +115,6 @@ namespace System.Text
private const int GBLastSurrogateOffset = 0x12E247; // GBE3329A35
// We have to load the 936 code page tables, so impersonate 936 as our base
[System.Security.SecurityCritical] // auto-generated
internal GB18030Encoding()
// For GB18030Encoding just use default replacement fallbacks because its only for bad surrogates
: base(GB18030, 936, EncoderFallback.ReplacementFallback, DecoderFallback.ReplacementFallback)
@ -125,7 +123,6 @@ namespace System.Text
// This loads our base 936 code page and then applies the changes from the tableUnicodeToGBDiffs table.
// See table comments for table format.
[System.Security.SecurityCritical] // auto-generated
protected override unsafe void LoadManagedCodePage()
{
// Use base code page loading algorithm.
@ -199,7 +196,6 @@ namespace System.Text
// Is4Byte
// Checks the 4 byte table and returns true if this is a 4 byte code.
// Its a 4 byte code if the flag is set in mapUnicodeTo4BytesFlags
[System.Security.SecurityCritical] // auto-generated
internal unsafe bool Is4Byte(char charTest)
{
// See what kind it is
@ -208,14 +204,12 @@ namespace System.Text
}
// GetByteCount
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count, EncoderNLS encoder)
{
// Just call GetBytes() with null bytes
return GetBytes(chars, count, null, 0, encoder);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetBytes(char* chars, int charCount,
byte* bytes, int byteCount, EncoderNLS encoder)
{
@ -396,14 +390,12 @@ namespace System.Text
}
// This is internal and called by something else,
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder)
{
// Just call GetChars() with null chars to count
return GetChars(bytes, count, null, 0, baseDecoder);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, DecoderNLS baseDecoder)
{
@ -753,7 +745,6 @@ namespace System.Text
{
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Characters would be # of characters + 1 in case high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@ -774,7 +765,6 @@ namespace System.Text
{
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Just return length, we could have a single char for each byte + whatever extra our decoder could do to us.
// If decoder is messed up it could spit out 3 ?s.

View File

@ -1 +1 @@
779fa4d26cd1990b1117f33b3e7ca94bbdd820dc
65577abf17686484e6183eac153faf7fdef3cfdc

View File

@ -34,7 +34,6 @@
using System.Globalization;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Text;
using System.Runtime.InteropServices;
using System;
@ -59,7 +58,6 @@ namespace System.Text
// We have to load the 936 code page tables, so impersonate 936 as our base
// This pretends to be other code pages as far as memory sections are concerned.
[System.Security.SecurityCritical] // auto-generated
internal ISO2022Encoding(int codePage) : base(codePage, s_tableBaseCodePages[codePage % 10])
{
}
@ -224,7 +222,6 @@ namespace System.Text
}
// GetByteCount
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count, EncoderNLS baseEncoder)
{
// Just need to ASSERT, this is called by something else internal that checked parameters already
@ -235,7 +232,6 @@ namespace System.Text
return GetBytes(chars, count, null, 0, baseEncoder);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetBytes(char* chars, int charCount,
byte* bytes, int byteCount, EncoderNLS baseEncoder)
{
@ -277,7 +273,6 @@ namespace System.Text
}
// This is internal and called by something else,
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder)
{
// Just assert, we're called internally so these should be safe, checked already
@ -288,7 +283,6 @@ namespace System.Text
return GetChars(bytes, count, null, 0, baseDecoder);
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, DecoderNLS baseDecoder)
{
@ -360,7 +354,6 @@ namespace System.Text
// undefined, so we maintain that behavior when decoding. We will never generate characters using
// that technique, but the decoder will process them.
//
[System.Security.SecurityCritical] // auto-generated
private unsafe int GetBytesCP5022xJP(char* chars, int charCount,
byte* bytes, int byteCount, ISO2022Encoder encoder)
{
@ -602,7 +595,6 @@ namespace System.Text
// Also Mlang always assumed KR mode, even if the designator wasn't found yet, so we do that as
// well. So basically we just ignore <ESC>$)C when decoding.
//
[System.Security.SecurityCritical] // auto-generated
private unsafe int GetBytesCP50225KR(char* chars, int charCount,
byte* bytes, int byteCount, ISO2022Encoder encoder)
{
@ -752,7 +744,6 @@ namespace System.Text
//
// This encoding is designed for transmission by e-mail and news. No bytes should have high bit set.
// (all bytes <= 0x7f)
[System.Security.SecurityCritical] // auto-generated
private unsafe int GetBytesCP52936(char* chars, int charCount,
byte* bytes, int byteCount, ISO2022Encoder encoder)
{
@ -886,7 +877,6 @@ namespace System.Text
return buffer.Count;
}
[System.Security.SecurityCritical] // auto-generated
private unsafe int GetCharsCP5022xJP(byte* bytes, int byteCount,
char* chars, int charCount, ISO2022Decoder decoder)
{
@ -1212,7 +1202,6 @@ namespace System.Text
// Note that in DBCS mode mlang passed through ' ', '\t' and '\n' as SBCS characters
// probably to allow mailer formatting without too much extra work.
[System.Security.SecurityCritical] // auto-generated
private unsafe int GetCharsCP50225KR(byte* bytes, int byteCount,
char* chars, int charCount, ISO2022Decoder decoder)
{
@ -1450,7 +1439,6 @@ namespace System.Text
//
// This encoding is designed for transmission by e-mail and news. No bytes should have high bit set.
// (all bytes <= 0x7f)
[System.Security.SecurityCritical] // auto-generated
private unsafe int GetCharsCP52936(byte* bytes, int byteCount,
char* chars, int charCount, ISO2022Decoder decoder)
{
@ -1708,7 +1696,6 @@ namespace System.Text
{
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Characters would be # of characters + 1 in case high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@ -1762,7 +1749,6 @@ namespace System.Text
{
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
int perChar = 1;
int extraDecoder = 1;

View File

@ -5,7 +5,6 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Text;
using System.Threading;
using System.Globalization;
@ -17,9 +16,7 @@ namespace System.Text
internal class SBCSCodePageEncoding : BaseCodePageEncoding
{
// Pointers to our memory section parts
[SecurityCritical]
private unsafe char* _mapBytesToUnicode = null; // char 256
[SecurityCritical]
private unsafe byte* _mapUnicodeToBytes = null; // byte 65536
private const char UNKNOWN_CHAR = (char)0xFFFD;
@ -28,12 +25,10 @@ namespace System.Text
private byte _byteUnknown;
private char _charUnknown;
[System.Security.SecurityCritical] // auto-generated
public SBCSCodePageEncoding(int codePage) : this(codePage, codePage)
{
}
[System.Security.SecurityCritical] // auto-generated
public SBCSCodePageEncoding(int codePage, int dataCodePage) : base(codePage, dataCodePage)
{
}
@ -72,7 +67,6 @@ namespace System.Text
// byte < 0x20 means skip the next n positions. (Where n is the byte #)
// byte == 1 means that next word is another unicode code point #
// byte == 0 is unknown. (doesn't override initial WCHAR[256] table!
[System.Security.SecurityCritical] // auto-generated
protected override unsafe void LoadManagedCodePage()
{
Debug.Assert(m_codePageHeader?.Length > 0);
@ -159,7 +153,6 @@ namespace System.Text
}
// Read in our best fit table
[System.Security.SecurityCritical] // auto-generated
protected unsafe override void ReadBestFitTable()
{
// Lock so we don't confuse ourselves.
@ -314,7 +307,6 @@ namespace System.Text
// GetByteCount
// Note: We start by assuming that the output will be the same as count. Having
// an encoder or fallback may change that assumption
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetByteCount(char* chars, int count, EncoderNLS encoder)
{
// Just need to ASSERT, this is called by something else internal that checked parameters already
@ -439,7 +431,6 @@ namespace System.Text
return (int)byteCount;
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetBytes(char* chars, int charCount,
byte* bytes, int byteCount, EncoderNLS encoder)
{
@ -675,7 +666,6 @@ namespace System.Text
}
// This is internal and called by something else,
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS decoder)
{
// Just assert, we're called internally so these should be safe, checked already
@ -763,7 +753,6 @@ namespace System.Text
return charCount;
}
[System.Security.SecurityCritical] // auto-generated
public override unsafe int GetChars(byte* bytes, int byteCount,
char* chars, int charCount, DecoderNLS decoder)
{
@ -926,7 +915,6 @@ namespace System.Text
{
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Characters would be # of characters + 1 in case high surrogate is ? * max fallback
long byteCount = (long)charCount + 1;
@ -945,7 +933,6 @@ namespace System.Text
{
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
// Just return length, SBCS stay the same length because they don't map to surrogate
long charCount = (long)byteCount;

Some files were not shown because too many files have changed in this diff Show More