From a97119967dcf658805b7c7ea9181e9c7470f9130 Mon Sep 17 00:00:00 2001 From: Tarek Mahmoud Sayed Date: Wed, 5 Jul 2017 14:59:08 -0700 Subject: [PATCH 1/2] Move more Encoding code to the shared folder This fix is moving more encoding source files to the shared folder and fixing some minor issues too. this should fix the corefx text encoding tests running against uapaot [tfs-changeset: 1664704] --- .../System.Private.CoreLib.Shared.projitems | 3 + .../{src => shared}/System/Text/Encoding.cs | 274 +++++++++++++----- .../System/Text/Latin1Encoding.cs | 236 ++++++++------- .../System/Text/UTF7Encoding.cs | 72 +++-- .../src/System.Private.CoreLib.csproj | 3 - .../src/System/Text/EncodingData.cs | 4 +- 6 files changed, 388 insertions(+), 204 deletions(-) rename src/System.Private.CoreLib/{src => shared}/System/Text/Encoding.cs (88%) rename src/System.Private.CoreLib/{src => shared}/System/Text/Latin1Encoding.cs (83%) rename src/System.Private.CoreLib/{src => shared}/System/Text/UTF7Encoding.cs (94%) diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index 50d0b8fb412..0982ec1f0cd 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -366,13 +366,16 @@ + + + diff --git a/src/System.Private.CoreLib/src/System/Text/Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs similarity index 88% rename from src/System.Private.CoreLib/src/System/Text/Encoding.cs rename to src/System.Private.CoreLib/shared/System/Text/Encoding.cs index 6c50e7cd5b0..9e89514b7ea 100644 --- a/src/System.Private.CoreLib/src/System/Text/Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs @@ -5,6 +5,8 @@ using System.Diagnostics; using System.Diagnostics.Contracts; using System.Threading; +using System.Runtime.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Text { @@ -73,8 +75,16 @@ namespace System.Text public abstract class Encoding : ICloneable { - private static Encoding defaultEncoding; - + // For netcore we use UTF8 as default encoding since ANSI isn't available + private static readonly UTF8Encoding.UTF8EncodingSealed s_defaultEncoding = new UTF8Encoding.UTF8EncodingSealed(encoderShouldEmitUTF8Identifier: false); + + // Returns an encoding for the system's current ANSI code page. + public static Encoding Default => s_defaultEncoding; + + // + // The following values are from mlang.idl. These values + // should be in sync with those in mlang.idl. + // internal const int MIMECONTF_MAILNEWS = 0x00000001; internal const int MIMECONTF_BROWSER = 0x00000002; internal const int MIMECONTF_SAVABLE_MAILNEWS = 0x00000100; @@ -144,16 +154,22 @@ public abstract class Encoding : ICloneable private const int CodePageUTF32BE = 12001; internal int m_codePage = 0; - + + // dataItem should be internal (not private). otherwise it will break during the deserialization + // of the data came from Everett internal CodePageDataItem dataItem = null; - private string _encodingName = null; + [NonSerialized] + internal bool m_deserializedFromEverett = false; // Because of encoders we may be read only - private bool _isReadOnly = true; + [OptionalField(VersionAdded = 2)] + private bool m_isReadOnly = true; // Encoding (encoder) fallback + [OptionalField(VersionAdded = 2)] internal EncoderFallback encoderFallback = null; + [OptionalField(VersionAdded = 2)] internal DecoderFallback decoderFallback = null; protected Encoding() : this(0) @@ -205,6 +221,113 @@ internal virtual void SetDefaultFallbacks() this.decoderFallback = new InternalDecoderBestFitFallback(this); } + + #region Serialization + internal void OnDeserializing() + { + // intialize the optional Whidbey fields + encoderFallback = null; + decoderFallback = null; + m_isReadOnly = true; + } + + internal void OnDeserialized() + { + if (encoderFallback == null || decoderFallback == null) + { + m_deserializedFromEverett = true; + SetDefaultFallbacks(); + } + + // dataItem is always recalculated from the code page # + dataItem = null; + } + + [OnDeserializing] + private void OnDeserializing(StreamingContext ctx) + { + OnDeserializing(); + } + + + [OnDeserialized] + private void OnDeserialized(StreamingContext ctx) + { + OnDeserialized(); + } + + [OnSerializing] + private void OnSerializing(StreamingContext ctx) + { + // to be consistent with SerializeEncoding + dataItem = null; + } + + // the following two methods are used for the inherited classes which implemented ISerializable + // Deserialization Helper + internal void DeserializeEncoding(SerializationInfo info, StreamingContext context) + { + // Any info? + if (info == null) throw new ArgumentNullException(nameof(info)); + Contract.EndContractBlock(); + + // All versions have a code page + this.m_codePage = (int)info.GetValue("m_codePage", typeof(int)); + + // We can get dataItem on the fly if needed, and the index is different between versions + // so ignore whatever dataItem data we get from Everett. + this.dataItem = null; + + // See if we have a code page + try + { + // + // Try Whidbey V2.0 Fields + // + + m_isReadOnly = (bool)info.GetValue("m_isReadOnly", typeof(bool)); + + this.encoderFallback = (EncoderFallback)info.GetValue("encoderFallback", typeof(EncoderFallback)); + this.decoderFallback = (DecoderFallback)info.GetValue("decoderFallback", typeof(DecoderFallback)); + } + catch (SerializationException) + { + // + // Didn't have Whidbey things, must be Everett + // + this.m_deserializedFromEverett = true; + + // May as well be read only + m_isReadOnly = true; + SetDefaultFallbacks(); + } + } + + // Serialization Helper + internal void SerializeEncoding(SerializationInfo info, StreamingContext context) + { + // Any Info? + if (info == null) throw new ArgumentNullException(nameof(info)); + Contract.EndContractBlock(); + + // These are new V2.0 Whidbey stuff + info.AddValue("m_isReadOnly", m_isReadOnly); + info.AddValue("encoderFallback", this.EncoderFallback); + info.AddValue("decoderFallback", this.DecoderFallback); + + // These were in Everett V1.1 as well + info.AddValue("m_codePage", this.m_codePage); + + // This was unique to Everett V1.1 + info.AddValue("dataItem", null); + + // Everett duplicated these fields, so these are needed for portability + info.AddValue("Encoding+m_codePage", this.m_codePage); + info.AddValue("Encoding+dataItem", null); + } + + #endregion Serialization + // Converts a byte array from one encoding to another. The bytes in the // bytes array are converted from srcEncoding to // dstEncoding, and the returned value is a new byte array @@ -262,20 +385,19 @@ public static Encoding GetEncoding(int codepage) // NOTE: If you add a new encoding that can be retrieved by codepage, be sure to // add the corresponding item in EncodingTable. // Otherwise, the code below will throw exception when trying to call - // EncodingTable.GetWebNameFromCodePage(). + // EncodingTable.GetDataItem(). // if (codepage < 0 || codepage > 65535) { throw new ArgumentOutOfRangeException( - nameof(codepage), SR.Format(SR.ArgumentOutOfRange_Range, - 0, 65535)); + nameof(codepage), SR.Format(SR.ArgumentOutOfRange_Range, 0, 65535)); } Contract.EndContractBlock(); switch (codepage) { - case CodePageDefault: return UTF8; // 0 + case CodePageDefault: return Default; // 0 case CodePageUnicode: return Unicode; // 1200 case CodePageBigEndian: return BigEndianUnicode; // 1201 case CodePageUTF32: return UTF32; // 12000 @@ -290,8 +412,7 @@ public static Encoding GetEncoding(int codepage) case CodePageNoMac: // 2 CP_MACCP case CodePageNoThread: // 3 CP_THREAD_ACP case CodePageNoSymbol: // 42 CP_SYMBOL - throw new ArgumentException(SR.Format( - SR.Argument_CodepageNotSupported, codepage), nameof(codepage)); + throw new ArgumentException(SR.Format(SR.Argument_CodepageNotSupported, codepage), nameof(codepage)); } // Is it a valid code page? @@ -403,36 +524,31 @@ public virtual String BodyName } // Returns the human-readable description of the encoding ( e.g. Hebrew (DOS)). - +#if PROJECTN public virtual String EncodingName { get { - if (_encodingName == null) + string encodingName = GetLocalizedEncodingNameResource(this.CodePage); + if (encodingName == null) { - _encodingName = GetLocalizedEncodingNameResource(this.CodePage); - if (_encodingName == null) - { - throw new NotSupportedException( - SR.Format(SR.MissingEncodingNameResource, this.CodePage)); - } + throw new NotSupportedException(SR.Format(SR.MissingEncodingNameResource, this.CodePage)); + } - if (_encodingName.StartsWith("Globalization_cp_", StringComparison.Ordinal)) + if (encodingName.StartsWith("Globalization_cp_", StringComparison.Ordinal)) + { + // On ProjectN, resource strings are stripped from retail builds and replaced by + // their identifier names. Since this property is meant to be a localized string, + // but we don't localize ProjectN, we specifically need to do something reasonable + // in this case. This currently returns the English name of the encoding from a + // static data table. + encodingName = EncodingTable.GetCodePageDataItem(this.CodePage).EnglishName; + if (encodingName == null) { - // On ProjectN, resource strings are stripped from retail builds and replaced by - // their identifier names. Since this property is meant to be a localized string, - // but we don't localize ProjectN, we specifically need to do something reasonable - // in this case. This currently returns the English name of the encoding from a - // static data table. - _encodingName = EncodingTable.GetCodePageDataItem(this.CodePage).EnglishName; - if (_encodingName == null) - { - throw new NotSupportedException( - SR.Format(SR.MissingEncodingNameResource, this.WebName, this.CodePage)); - } + throw new NotSupportedException(SR.Format(SR.MissingEncodingNameResource, this.WebName, this.CodePage)); } } - return _encodingName; + return encodingName; } } @@ -451,7 +567,15 @@ private static string GetLocalizedEncodingNameResource(int codePage) default: return null; } } - +#else + public virtual String EncodingName + { + get + { + return SR.GetResourceString("Globalization_cp_" + m_codePage.ToString()); + } + } +#endif // Returns the name for this encoding that can be used with mail agent header // tags. If the encoding may not be used, the string is empty. @@ -611,7 +735,7 @@ public virtual Object Clone() Encoding newEncoding = (Encoding)this.MemberwiseClone(); // New one should be readable - newEncoding._isReadOnly = false; + newEncoding.m_isReadOnly = false; return newEncoding; } @@ -620,7 +744,7 @@ public bool IsReadOnly { get { - return (_isReadOnly); + return (m_isReadOnly); } } @@ -1130,26 +1254,6 @@ public virtual Decoder GetDecoder() return new DefaultDecoder(this); } - private static Encoding CreateDefaultEncoding() - { - // defaultEncoding should be null if we get here, but we can't - // assert that in case another thread beat us to the initialization - - Encoding enc; - - - // For silverlight we use UTF8 since ANSI isn't available - enc = UTF8; - - - // This method should only ever return one Encoding instance - return Interlocked.CompareExchange(ref defaultEncoding, enc, null) ?? enc; - } - - // Returns an encoding for the system's current ANSI code page. - - public static Encoding Default => defaultEncoding ?? CreateDefaultEncoding(); - // Returns an Encoder object for this encoding. The returned object // can be used to encode a sequence of characters into a sequence of bytes. // Contrary to the GetBytes family of methods, an Encoder can @@ -1290,8 +1394,7 @@ internal void ThrowBytesOverflow() // Special message to include fallback type in case fallback's GetMaxCharCount is broken // This happens if user has implimented an encoder fallback with a broken GetMaxCharCount throw new ArgumentException( - SR.Format(SR.Argument_EncodingConversionOverflowBytes, - EncodingName, EncoderFallback.GetType()), "bytes"); + SR.Format(SR.Argument_EncodingConversionOverflowBytes, EncodingName, EncoderFallback.GetType()), "bytes"); } internal void ThrowBytesOverflow(EncoderNLS encoder, bool nothingEncoded) @@ -1314,8 +1417,7 @@ internal void ThrowCharsOverflow() // Special message to include fallback type in case fallback's GetMaxCharCount is broken // This happens if user has implimented a decoder fallback with a broken GetMaxCharCount throw new ArgumentException( - SR.Format(SR.Argument_EncodingConversionOverflowChars, - EncodingName, DecoderFallback.GetType()), "chars"); + SR.Format(SR.Argument_EncodingConversionOverflowChars, EncodingName, DecoderFallback.GetType()), "chars"); } internal void ThrowCharsOverflow(DecoderNLS decoder, bool nothingDecoded) @@ -1334,13 +1436,24 @@ internal void ThrowCharsOverflow(DecoderNLS decoder, bool nothingDecoded) decoder.ClearMustFlush(); } - internal class DefaultEncoder : Encoder // , IObjectReference + internal sealed class DefaultEncoder : Encoder, IObjectReference, ISerializable { - private Encoding _encoding; + private Encoding m_encoding; public DefaultEncoder(Encoding encoding) { - _encoding = encoding; + m_encoding = encoding; + } + + public Object GetRealObject(StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + + // ISerializable implementation, get data for this object + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); } // Returns the number of bytes the next call to GetBytes will @@ -1353,12 +1466,13 @@ public DefaultEncoder(Encoding encoding) public override int GetByteCount(char[] chars, int index, int count, bool flush) { - return _encoding.GetByteCount(chars, index, count); + return m_encoding.GetByteCount(chars, index, count); } + [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public unsafe override int GetByteCount(char* chars, int count, bool flush) { - return _encoding.GetByteCount(chars, count); + return m_encoding.GetByteCount(chars, count); } // Encodes a range of characters in a character array into a range of bytes @@ -1384,23 +1498,35 @@ public unsafe override int GetByteCount(char* chars, int count, bool flush) public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush) { - return _encoding.GetBytes(chars, charIndex, charCount, bytes, byteIndex); + return m_encoding.GetBytes(chars, charIndex, charCount, bytes, byteIndex); } + [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, bool flush) { - return _encoding.GetBytes(chars, charCount, bytes, byteCount); + return m_encoding.GetBytes(chars, charCount, bytes, byteCount); } } - internal class DefaultDecoder : Decoder // , IObjectReference + internal sealed class DefaultDecoder : Decoder, IObjectReference, ISerializable { - private Encoding _encoding; + private Encoding m_encoding; public DefaultDecoder(Encoding encoding) { - _encoding = encoding; + m_encoding = encoding; + } + + public Object GetRealObject(StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + + // ISerializable implementation + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); } // Returns the number of characters the next call to GetChars will @@ -1417,13 +1543,14 @@ public override int GetCharCount(byte[] bytes, int index, int count) public override int GetCharCount(byte[] bytes, int index, int count, bool flush) { - return _encoding.GetCharCount(bytes, index, count); + return m_encoding.GetCharCount(bytes, index, count); } + [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public unsafe override int GetCharCount(byte* bytes, int count, bool flush) { // By default just call the encoding version, no flush by default - return _encoding.GetCharCount(bytes, count); + return m_encoding.GetCharCount(bytes, count); } // Decodes a range of bytes in a byte array into a range of characters @@ -1452,14 +1579,15 @@ public override int GetChars(byte[] bytes, int byteIndex, int byteCount, public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, bool flush) { - return _encoding.GetChars(bytes, byteIndex, byteCount, chars, charIndex); + return m_encoding.GetChars(bytes, byteIndex, byteCount, chars, charIndex); } + [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount, bool flush) { // By default just call the encoding's version - return _encoding.GetChars(bytes, byteCount, chars, charCount); + return m_encoding.GetChars(bytes, byteCount, chars, charCount); } } diff --git a/src/System.Private.CoreLib/src/System/Text/Latin1Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs similarity index 83% rename from src/System.Private.CoreLib/src/System/Text/Latin1Encoding.cs rename to src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs index 612f7dd9f90..3f65f552c44 100644 --- a/src/System.Private.CoreLib/src/System/Text/Latin1Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs @@ -2,8 +2,10 @@ // 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.Diagnostics; using System.Diagnostics.Contracts; +using System.Runtime.Serialization; namespace System.Text { @@ -11,7 +13,7 @@ namespace System.Text // Latin1Encoding is a simple override to optimize the GetString version of Latin1Encoding. // because of the best fit cases we can't do this when encoding the string, only when decoding // - internal class Latin1Encoding : EncodingNLS + internal class Latin1Encoding : EncodingNLS, ISerializable { // Used by Encoding.Latin1 for lazy initialization // The initialization code will not be run until a static member of the class is referenced @@ -22,6 +24,12 @@ public Latin1Encoding() : base(Encoding.ISO_8859_1) { } + // ISerializable implementation + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); + } + // GetByteCount // Note: We start by assuming that the output will be the same as count. Having // an encoder or fallback may change that assumption @@ -80,6 +88,7 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS // For fallback we may need a fallback buffer, we know we aren't default fallback. EncoderFallbackBuffer fallbackBuffer = null; + char* charsForFallback; // We may have a left over character from last time, try and process it. if (charLeftOver > 0) @@ -93,7 +102,9 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS // Since left over char was a surrogate, it'll have to be fallen back. // Get Fallback // This will fallback a pair if *chars is a low surrogate - fallbackBuffer.InternalFallback(charLeftOver, ref chars); + charsForFallback = chars; + fallbackBuffer.InternalFallback(charLeftOver, ref charsForFallback); + chars = charsForFallback; } // Now we may have fallback char[] already from the encoder @@ -126,7 +137,9 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS } // Get Fallback - fallbackBuffer.InternalFallback(ch, ref chars); + charsForFallback = chars; + fallbackBuffer.InternalFallback(ch, ref charsForFallback); + chars = charsForFallback; continue; } @@ -240,6 +253,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, // For fallback we may need a fallback buffer, we know we aren't default fallback, create & init it EncoderFallbackBuffer fallbackBuffer = null; + char* charsForFallback; // We may have a left over character from last time, try and process it. if (charLeftOver > 0) @@ -254,7 +268,10 @@ internal override unsafe int GetBytes(char* chars, int charCount, // Since left over char was a surrogate, it'll have to be fallen back. // Get Fallback // This will fallback a pair if *chars is a low surrogate - fallbackBuffer.InternalFallback(charLeftOver, ref chars); + charsForFallback = chars; + fallbackBuffer.InternalFallback(charLeftOver, ref charsForFallback); + chars = charsForFallback; + if (fallbackBuffer.Remaining > byteEnd - bytes) { // Throw it, if we don't have enough for this we never will @@ -292,7 +309,9 @@ internal override unsafe int GetBytes(char* chars, int charCount, } // Get Fallback - fallbackBuffer.InternalFallback(ch, ref chars); + charsForFallback = chars; + fallbackBuffer.InternalFallback(ch, ref charsForFallback); + chars = charsForFallback; // Make sure we have enough room. Each fallback char will be 1 output char // (or else cause a recursion exception) @@ -452,113 +471,122 @@ public override bool IsSingleByte } } + public override bool IsAlwaysNormalized(NormalizationForm form) + { + // Latin-1 contains precomposed characters, so normal for Form C. + // Since some are composed, not normal for D & KD. + // Also some letters like 0x00A8 (spacing diarisis) have compatibility decompositions, so false for KD & KC. + + // Only true for form C. + return (form == NormalizationForm.FormC); + } // Since our best fit table is small we'll hard code it internal override char[] GetBestFitUnicodeToBytesData() { // Get our best fit data - return Latin1Encoding.s_arrayCharBestFit; + return Latin1Encoding.arrayCharBestFit; } // Best fit for ASCII, and since it works for ASCII, we use it for latin1 as well. - private static readonly char[] s_arrayCharBestFit = + private static readonly char[] arrayCharBestFit = { - // The first many are in case you wanted to use this for ASCIIEncoding, which we don't need to do any more. - // (char)0x00a0, (char)0x0020, // No-Break Space -> Space - // (char)0x00a1, (char)0x0021, // Inverted Exclamation Mark -> ! - // (char)0x00a2, (char)0x0063, // Cent Sign -> c - // (char)0x00a3, (char)0x003f, // Pound Sign - // (char)0x00a4, (char)0x0024, // Currency Sign -> $ - // (char)0x00a5, (char)0x0059, // Yen Sign -> Y - // (char)0x00a6, (char)0x007c, // Broken Bar -> | - // (char)0x00a7, (char)0x003f, // Section Sign - // (char)0x00a8, (char)0x003f, // Diaeresis - // (char)0x00a9, (char)0x0043, // Copyright Sign -> C - // (char)0x00aa, (char)0x0061, // Feminine Ordinal Indicator -> a - // (char)0x00ab, (char)0x003c, // Left-Pointing Double Angle Quotation Mark -> < - // (char)0x00ac, (char)0x003f, // Not Sign - // (char)0x00ad, (char)0x002d, // Soft Hyphen -> - - // (char)0x00ae, (char)0x0052, // Registered Sign -> R - // (char)0x00af, (char)0x003f, // Macron - // (char)0x00b0, (char)0x003f, // Degree Sign - // (char)0x00b1, (char)0x003f, // Plus-Minus Sign - // (char)0x00b2, (char)0x0032, // Superscript Two -> 2 - // (char)0x00b3, (char)0x0033, // Superscript Three -> 3 - // (char)0x00b4, (char)0x003f, // Acute Accent - // (char)0x00b5, (char)0x003f, // Micro Sign - // (char)0x00b6, (char)0x003f, // Pilcrow Sign - // (char)0x00b7, (char)0x002e, // Middle Dot -> . - // (char)0x00b8, (char)0x002c, // Cedilla -> , - // (char)0x00b9, (char)0x0031, // Superscript One -> 1 - // (char)0x00ba, (char)0x006f, // Masculine Ordinal Indicator -> o - // (char)0x00bb, (char)0x003e, // Right-Pointing Double Angle Quotation Mark -> > - // (char)0x00bc, (char)0x003f, // Vulgar Fraction One Quarter - // (char)0x00bd, (char)0x003f, // Vulgar Fraction One Half - // (char)0x00be, (char)0x003f, // Vulgar Fraction Three Quarters - // (char)0x00bf, (char)0x003f, // Inverted Question Mark - // (char)0x00c0, (char)0x0041, // Latin Capital Letter A With Grave -> A - // (char)0x00c1, (char)0x0041, // Latin Capital Letter A With Acute -> A - // (char)0x00c2, (char)0x0041, // Latin Capital Letter A With Circumflex -> A - // (char)0x00c3, (char)0x0041, // Latin Capital Letter A With Tilde -> A - // (char)0x00c4, (char)0x0041, // Latin Capital Letter A With Diaeresis -> A - // (char)0x00c5, (char)0x0041, // Latin Capital Letter A With Ring Above -> A - // (char)0x00c6, (char)0x0041, // Latin Capital Ligature Ae -> A - // (char)0x00c7, (char)0x0043, // Latin Capital Letter C With Cedilla -> C - // (char)0x00c8, (char)0x0045, // Latin Capital Letter E With Grave -> E - // (char)0x00c9, (char)0x0045, // Latin Capital Letter E With Acute -> E - // (char)0x00ca, (char)0x0045, // Latin Capital Letter E With Circumflex -> E - // (char)0x00cb, (char)0x0045, // Latin Capital Letter E With Diaeresis -> E - // (char)0x00cc, (char)0x0049, // Latin Capital Letter I With Grave -> I - // (char)0x00cd, (char)0x0049, // Latin Capital Letter I With Acute -> I - // (char)0x00ce, (char)0x0049, // Latin Capital Letter I With Circumflex -> I - // (char)0x00cf, (char)0x0049, // Latin Capital Letter I With Diaeresis -> I - // (char)0x00d0, (char)0x0044, // Latin Capital Letter Eth -> D - // (char)0x00d1, (char)0x004e, // Latin Capital Letter N With Tilde -> N - // (char)0x00d2, (char)0x004f, // Latin Capital Letter O With Grave -> O - // (char)0x00d3, (char)0x004f, // Latin Capital Letter O With Acute -> O - // (char)0x00d4, (char)0x004f, // Latin Capital Letter O With Circumflex -> O - // (char)0x00d5, (char)0x004f, // Latin Capital Letter O With Tilde -> O - // (char)0x00d6, (char)0x004f, // Latin Capital Letter O With Diaeresis -> O - // (char)0x00d7, (char)0x003f, // Multiplication Sign - // (char)0x00d8, (char)0x004f, // Latin Capital Letter O With Stroke -> O - // (char)0x00d9, (char)0x0055, // Latin Capital Letter U With Grave -> U - // (char)0x00da, (char)0x0055, // Latin Capital Letter U With Acute -> U - // (char)0x00db, (char)0x0055, // Latin Capital Letter U With Circumflex -> U - // (char)0x00dc, (char)0x0055, // Latin Capital Letter U With Diaeresis -> U - // (char)0x00dd, (char)0x0059, // Latin Capital Letter Y With Acute -> Y - // (char)0x00de, (char)0x003f, // Latin Capital Letter Thorn - // (char)0x00df, (char)0x003f, // Latin Small Letter Sharp S - // (char)0x00e0, (char)0x0061, // Latin Small Letter A With Grave -> a - // (char)0x00e1, (char)0x0061, // Latin Small Letter A With Acute -> a - // (char)0x00e2, (char)0x0061, // Latin Small Letter A With Circumflex -> a - // (char)0x00e3, (char)0x0061, // Latin Small Letter A With Tilde -> a - // (char)0x00e4, (char)0x0061, // Latin Small Letter A With Diaeresis -> a - // (char)0x00e5, (char)0x0061, // Latin Small Letter A With Ring Above -> a - // (char)0x00e6, (char)0x0061, // Latin Small Ligature Ae -> a - // (char)0x00e7, (char)0x0063, // Latin Small Letter C With Cedilla -> c - // (char)0x00e8, (char)0x0065, // Latin Small Letter E With Grave -> e - // (char)0x00e9, (char)0x0065, // Latin Small Letter E With Acute -> e - // (char)0x00ea, (char)0x0065, // Latin Small Letter E With Circumflex -> e - // (char)0x00eb, (char)0x0065, // Latin Small Letter E With Diaeresis -> e - // (char)0x00ec, (char)0x0069, // Latin Small Letter I With Grave -> i - // (char)0x00ed, (char)0x0069, // Latin Small Letter I With Acute -> i - // (char)0x00ee, (char)0x0069, // Latin Small Letter I With Circumflex -> i - // (char)0x00ef, (char)0x0069, // Latin Small Letter I With Diaeresis -> i - // (char)0x00f0, (char)0x003f, // Latin Small Letter Eth - // (char)0x00f1, (char)0x006e, // Latin Small Letter N With Tilde -> n - // (char)0x00f2, (char)0x006f, // Latin Small Letter O With Grave -> o - // (char)0x00f3, (char)0x006f, // Latin Small Letter O With Acute -> o - // (char)0x00f4, (char)0x006f, // Latin Small Letter O With Circumflex -> o - // (char)0x00f5, (char)0x006f, // Latin Small Letter O With Tilde -> o - // (char)0x00f6, (char)0x006f, // Latin Small Letter O With Diaeresis -> o - // (char)0x00f7, (char)0x003f, // Division Sign - // (char)0x00f8, (char)0x006f, // Latin Small Letter O With Stroke -> o - // (char)0x00f9, (char)0x0075, // Latin Small Letter U With Grave -> u - // (char)0x00fa, (char)0x0075, // Latin Small Letter U With Acute -> u - // (char)0x00fb, (char)0x0075, // Latin Small Letter U With Circumflex -> u - // (char)0x00fc, (char)0x0075, // Latin Small Letter U With Diaeresis -> u - // (char)0x00fd, (char)0x0079, // Latin Small Letter Y With Acute -> y - // (char)0x00fe, (char)0x003f, // Latin Small Letter Thorn - // (char)0x00ff, (char)0x0079, // Latin Small Letter Y With Diaeresis -> y +// The first many are in case you wanted to use this for ASCIIEncoding, which we don't need to do any more. +// (char)0x00a0, (char)0x0020, // No-Break Space -> Space +// (char)0x00a1, (char)0x0021, // Inverted Exclamation Mark -> ! +// (char)0x00a2, (char)0x0063, // Cent Sign -> c +// (char)0x00a3, (char)0x003f, // Pound Sign +// (char)0x00a4, (char)0x0024, // Currency Sign -> $ +// (char)0x00a5, (char)0x0059, // Yen Sign -> Y +// (char)0x00a6, (char)0x007c, // Broken Bar -> | +// (char)0x00a7, (char)0x003f, // Section Sign +// (char)0x00a8, (char)0x003f, // Diaeresis +// (char)0x00a9, (char)0x0043, // Copyright Sign -> C +// (char)0x00aa, (char)0x0061, // Feminine Ordinal Indicator -> a +// (char)0x00ab, (char)0x003c, // Left-Pointing Double Angle Quotation Mark -> < +// (char)0x00ac, (char)0x003f, // Not Sign +// (char)0x00ad, (char)0x002d, // Soft Hyphen -> - +// (char)0x00ae, (char)0x0052, // Registered Sign -> R +// (char)0x00af, (char)0x003f, // Macron +// (char)0x00b0, (char)0x003f, // Degree Sign +// (char)0x00b1, (char)0x003f, // Plus-Minus Sign +// (char)0x00b2, (char)0x0032, // Superscript Two -> 2 +// (char)0x00b3, (char)0x0033, // Superscript Three -> 3 +// (char)0x00b4, (char)0x003f, // Acute Accent +// (char)0x00b5, (char)0x003f, // Micro Sign +// (char)0x00b6, (char)0x003f, // Pilcrow Sign +// (char)0x00b7, (char)0x002e, // Middle Dot -> . +// (char)0x00b8, (char)0x002c, // Cedilla -> , +// (char)0x00b9, (char)0x0031, // Superscript One -> 1 +// (char)0x00ba, (char)0x006f, // Masculine Ordinal Indicator -> o +// (char)0x00bb, (char)0x003e, // Right-Pointing Double Angle Quotation Mark -> > +// (char)0x00bc, (char)0x003f, // Vulgar Fraction One Quarter +// (char)0x00bd, (char)0x003f, // Vulgar Fraction One Half +// (char)0x00be, (char)0x003f, // Vulgar Fraction Three Quarters +// (char)0x00bf, (char)0x003f, // Inverted Question Mark +// (char)0x00c0, (char)0x0041, // Latin Capital Letter A With Grave -> A +// (char)0x00c1, (char)0x0041, // Latin Capital Letter A With Acute -> A +// (char)0x00c2, (char)0x0041, // Latin Capital Letter A With Circumflex -> A +// (char)0x00c3, (char)0x0041, // Latin Capital Letter A With Tilde -> A +// (char)0x00c4, (char)0x0041, // Latin Capital Letter A With Diaeresis -> A +// (char)0x00c5, (char)0x0041, // Latin Capital Letter A With Ring Above -> A +// (char)0x00c6, (char)0x0041, // Latin Capital Ligature Ae -> A +// (char)0x00c7, (char)0x0043, // Latin Capital Letter C With Cedilla -> C +// (char)0x00c8, (char)0x0045, // Latin Capital Letter E With Grave -> E +// (char)0x00c9, (char)0x0045, // Latin Capital Letter E With Acute -> E +// (char)0x00ca, (char)0x0045, // Latin Capital Letter E With Circumflex -> E +// (char)0x00cb, (char)0x0045, // Latin Capital Letter E With Diaeresis -> E +// (char)0x00cc, (char)0x0049, // Latin Capital Letter I With Grave -> I +// (char)0x00cd, (char)0x0049, // Latin Capital Letter I With Acute -> I +// (char)0x00ce, (char)0x0049, // Latin Capital Letter I With Circumflex -> I +// (char)0x00cf, (char)0x0049, // Latin Capital Letter I With Diaeresis -> I +// (char)0x00d0, (char)0x0044, // Latin Capital Letter Eth -> D +// (char)0x00d1, (char)0x004e, // Latin Capital Letter N With Tilde -> N +// (char)0x00d2, (char)0x004f, // Latin Capital Letter O With Grave -> O +// (char)0x00d3, (char)0x004f, // Latin Capital Letter O With Acute -> O +// (char)0x00d4, (char)0x004f, // Latin Capital Letter O With Circumflex -> O +// (char)0x00d5, (char)0x004f, // Latin Capital Letter O With Tilde -> O +// (char)0x00d6, (char)0x004f, // Latin Capital Letter O With Diaeresis -> O +// (char)0x00d7, (char)0x003f, // Multiplication Sign +// (char)0x00d8, (char)0x004f, // Latin Capital Letter O With Stroke -> O +// (char)0x00d9, (char)0x0055, // Latin Capital Letter U With Grave -> U +// (char)0x00da, (char)0x0055, // Latin Capital Letter U With Acute -> U +// (char)0x00db, (char)0x0055, // Latin Capital Letter U With Circumflex -> U +// (char)0x00dc, (char)0x0055, // Latin Capital Letter U With Diaeresis -> U +// (char)0x00dd, (char)0x0059, // Latin Capital Letter Y With Acute -> Y +// (char)0x00de, (char)0x003f, // Latin Capital Letter Thorn +// (char)0x00df, (char)0x003f, // Latin Small Letter Sharp S +// (char)0x00e0, (char)0x0061, // Latin Small Letter A With Grave -> a +// (char)0x00e1, (char)0x0061, // Latin Small Letter A With Acute -> a +// (char)0x00e2, (char)0x0061, // Latin Small Letter A With Circumflex -> a +// (char)0x00e3, (char)0x0061, // Latin Small Letter A With Tilde -> a +// (char)0x00e4, (char)0x0061, // Latin Small Letter A With Diaeresis -> a +// (char)0x00e5, (char)0x0061, // Latin Small Letter A With Ring Above -> a +// (char)0x00e6, (char)0x0061, // Latin Small Ligature Ae -> a +// (char)0x00e7, (char)0x0063, // Latin Small Letter C With Cedilla -> c +// (char)0x00e8, (char)0x0065, // Latin Small Letter E With Grave -> e +// (char)0x00e9, (char)0x0065, // Latin Small Letter E With Acute -> e +// (char)0x00ea, (char)0x0065, // Latin Small Letter E With Circumflex -> e +// (char)0x00eb, (char)0x0065, // Latin Small Letter E With Diaeresis -> e +// (char)0x00ec, (char)0x0069, // Latin Small Letter I With Grave -> i +// (char)0x00ed, (char)0x0069, // Latin Small Letter I With Acute -> i +// (char)0x00ee, (char)0x0069, // Latin Small Letter I With Circumflex -> i +// (char)0x00ef, (char)0x0069, // Latin Small Letter I With Diaeresis -> i +// (char)0x00f0, (char)0x003f, // Latin Small Letter Eth +// (char)0x00f1, (char)0x006e, // Latin Small Letter N With Tilde -> n +// (char)0x00f2, (char)0x006f, // Latin Small Letter O With Grave -> o +// (char)0x00f3, (char)0x006f, // Latin Small Letter O With Acute -> o +// (char)0x00f4, (char)0x006f, // Latin Small Letter O With Circumflex -> o +// (char)0x00f5, (char)0x006f, // Latin Small Letter O With Tilde -> o +// (char)0x00f6, (char)0x006f, // Latin Small Letter O With Diaeresis -> o +// (char)0x00f7, (char)0x003f, // Division Sign +// (char)0x00f8, (char)0x006f, // Latin Small Letter O With Stroke -> o +// (char)0x00f9, (char)0x0075, // Latin Small Letter U With Grave -> u +// (char)0x00fa, (char)0x0075, // Latin Small Letter U With Acute -> u +// (char)0x00fb, (char)0x0075, // Latin Small Letter U With Circumflex -> u +// (char)0x00fc, (char)0x0075, // Latin Small Letter U With Diaeresis -> u +// (char)0x00fd, (char)0x0079, // Latin Small Letter Y With Acute -> y +// (char)0x00fe, (char)0x003f, // Latin Small Letter Thorn +// (char)0x00ff, (char)0x0079, // Latin Small Letter Y With Diaeresis -> y (char)0x0100, (char)0x0041, // Latin Capital Letter A With Macron -> A (char)0x0101, (char)0x0061, // Latin Small Letter A With Macron -> a (char)0x0102, (char)0x0041, // Latin Capital Letter A With Breve -> A diff --git a/src/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs similarity index 94% rename from src/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs rename to src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs index 18f6acbadef..0ac3b668898 100644 --- a/src/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs @@ -33,18 +33,18 @@ public class UTF7Encoding : Encoding internal static readonly UTF7Encoding s_default = new UTF7Encoding(); // The set of base 64 characters. - private byte[] _base64Bytes; + private byte[] base64Bytes; // The decoded bits for every base64 values. This array has a size of 128 elements. // The index is the code point value of the base 64 characters. The value is -1 if // the code point is not a valid base 64 character. Otherwise, the value is a value // from 0 ~ 63. - private sbyte[] _base64Values; + private sbyte[] base64Values; // The array to decide if a Unicode code point below 0x80 can be directly encoded in UTF7. // This array has a size of 128. - private bool[] _directEncode; + private bool[] directEncode; [OptionalField(VersionAdded = 2)] - private bool _allowOptionals; + private bool m_allowOptionals; private const int UTF7_CODEPAGE = 65000; @@ -58,7 +58,7 @@ public UTF7Encoding(bool allowOptionals) : base(UTF7_CODEPAGE) //Set the data item. { // Allowing optionals? - _allowOptionals = allowOptionals; + m_allowOptionals = allowOptionals; // Make our tables MakeTables(); @@ -67,24 +67,24 @@ public UTF7Encoding(bool allowOptionals) private void MakeTables() { // Build our tables - _base64Bytes = new byte[64]; - for (int i = 0; i < 64; i++) _base64Bytes[i] = (byte)base64Chars[i]; - _base64Values = new sbyte[128]; - for (int i = 0; i < 128; i++) _base64Values[i] = -1; - for (int i = 0; i < 64; i++) _base64Values[_base64Bytes[i]] = (sbyte)i; - _directEncode = new bool[128]; + base64Bytes = new byte[64]; + for (int i = 0; i < 64; i++) base64Bytes[i] = (byte)base64Chars[i]; + base64Values = new sbyte[128]; + for (int i = 0; i < 128; i++) base64Values[i] = -1; + for (int i = 0; i < 64; i++) base64Values[base64Bytes[i]] = (sbyte)i; + directEncode = new bool[128]; int count = directChars.Length; for (int i = 0; i < count; i++) { - _directEncode[directChars[i]] = true; + directEncode[directChars[i]] = true; } - if (_allowOptionals) + if (m_allowOptionals) { count = optionalChars.Length; for (int i = 0; i < count; i++) { - _directEncode[optionalChars[i]] = true; + directEncode[optionalChars[i]] = true; } } } @@ -99,12 +99,36 @@ internal override void SetDefaultFallbacks() this.decoderFallback = new DecoderUTF7Fallback(); } + + [OnDeserializing] + private void OnDeserializing(StreamingContext ctx) + { + // make sure the optional fields initialized correctly. + base.OnDeserializing(); + } + + [OnDeserialized] + private void OnDeserialized(StreamingContext ctx) + { + base.OnDeserialized(); + + if (m_deserializedFromEverett) + { + // If 1st optional char is encoded we're allowing optionals + m_allowOptionals = directEncode[optionalChars[0]]; + } + + MakeTables(); + } + + + public override bool Equals(Object value) { UTF7Encoding that = value as UTF7Encoding; if (that != null) { - return (_allowOptionals == that._allowOptionals) && + return (m_allowOptionals == that.m_allowOptionals) && (EncoderFallback.Equals(that.EncoderFallback)) && (DecoderFallback.Equals(that.DecoderFallback)); } @@ -458,7 +482,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, { bitCount -= 6; // If we fail we'll never really have enough room - if (!buffer.AddByte(_base64Bytes[(bits >> bitCount) & 0x3F])) + if (!buffer.AddByte(base64Bytes[(bits >> bitCount) & 0x3F])) ThrowBytesOverflow(encoder, buffer.Count == 0); } } @@ -467,14 +491,14 @@ internal override unsafe int GetBytes(char* chars, int charCount, { char currentChar = buffer.GetNextChar(); - if (currentChar < 0x80 && _directEncode[currentChar]) + if (currentChar < 0x80 && directEncode[currentChar]) { if (bitCount >= 0) { if (bitCount > 0) { // Try to add the next byte - if (!buffer.AddByte(_base64Bytes[bits << 6 - bitCount & 0x3F])) + if (!buffer.AddByte(base64Bytes[bits << 6 - bitCount & 0x3F])) break; // Stop here, didn't throw bitCount = 0; @@ -516,7 +540,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, while (bitCount >= 6) { bitCount -= 6; - if (!buffer.AddByte(_base64Bytes[(bits >> bitCount) & 0x3F])) + if (!buffer.AddByte(base64Bytes[(bits >> bitCount) & 0x3F])) { bitCount += 6; // We didn't use these bits currentChar = buffer.GetNextChar(); // We're processing this char still, but AddByte @@ -537,7 +561,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, // Do we have bits we have to stick in? if (bitCount > 0) { - if (buffer.AddByte(_base64Bytes[(bits << (6 - bitCount)) & 0x3F])) + if (buffer.AddByte(base64Bytes[(bits << (6 - bitCount)) & 0x3F])) { // Emitted spare bits, 0 bits left bitCount = 0; @@ -630,7 +654,7 @@ internal override unsafe int GetChars(byte* bytes, int byteCount, // Modified base 64 encoding. // sbyte v; - if (currentByte < 0x80 && ((v = _base64Values[currentByte]) >= 0)) + if (currentByte < 0x80 && ((v = base64Values[currentByte]) >= 0)) { firstByte = false; bits = (bits << 6) | ((byte)v); @@ -807,6 +831,8 @@ public override int GetMaxCharCount(int byteCount) return charCount; } + // Of all the amazing things... This MUST be Decoder so that our com name + // for System.Text.Decoder doesn't change private sealed class Decoder : DecoderNLS, ISerializable { /*private*/ @@ -821,7 +847,7 @@ public Decoder(UTF7Encoding encoding) : base(encoding) // base calls reset } - // ISerializable implementation + // ISerializable implementation, get data for this object void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { throw new PlatformNotSupportedException(); @@ -848,6 +874,8 @@ internal override bool HasState } } + // Of all the amazing things... This MUST be Encoder so that our com name + // for System.Text.Encoder doesn't change private sealed class Encoder : EncoderNLS, ISerializable { /*private*/ diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj index 5e1ac12f028..32cb40a81ad 100644 --- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -358,13 +358,10 @@ - - - diff --git a/src/System.Private.CoreLib/src/System/Text/EncodingData.cs b/src/System.Private.CoreLib/src/System/Text/EncodingData.cs index 3ea6ed2e6ec..bff11e74418 100644 --- a/src/System.Private.CoreLib/src/System/Text/EncodingData.cs +++ b/src/System.Private.CoreLib/src/System/Text/EncodingData.cs @@ -213,9 +213,9 @@ internal static partial class EncodingTable // private const string s_webNames = "utf-16" + // 1200 - "utf-16be" + // 1201 + "utf-16BE" + // 1201 "utf-32" + // 12000 - "utf-32be" + // 12001 + "utf-32BE" + // 12001 "us-ascii" + // 20127 "iso-8859-1" + // 28591 "utf-7" + // 65000 From dc5855e93189415ce4861b93c856af79f2af467a Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 5 Jul 2017 15:18:48 -0700 Subject: [PATCH 2/2] Debugger Support [tfs-changeset: 1664705] --- src/Native/Runtime/Debug.h | 1 + .../Runtime/DebuggerSupport/DebugFuncEval.cs | 30 +++++++++++++++++++ .../DebuggerSupport/DebuggerContract.cs | 1 + 3 files changed, 32 insertions(+) diff --git a/src/Native/Runtime/Debug.h b/src/Native/Runtime/Debug.h index 908963a9d8f..f8097ff0943 100644 --- a/src/Native/Runtime/Debug.h +++ b/src/Native/Runtime/Debug.h @@ -14,6 +14,7 @@ enum FuncEvalMode : uint32_t RegularFuncEval = 1, NewStringWithLength = 2, NewArray = 3, + NewParameterizedObjectNoConstructor = 4, }; enum DebuggerGcProtectionRequestKind : uint16_t diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebugFuncEval.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebugFuncEval.cs index faa35901b7e..d9730a36391 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebugFuncEval.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebugFuncEval.cs @@ -138,6 +138,9 @@ private unsafe static void HighLevelDebugFuncEvalHelper() case FuncEvalMode.NewArray: CreateNewArray(parameterBuffer, parameterBufferSize); break; + case FuncEvalMode.NewParameterizedObjectNoConstructor: + NewParameterizedObjectNoConstructor(parameterBuffer, parameterBufferSize); + break; default: Debug.Assert(false, "Debugger provided an unexpected func eval mode."); @@ -223,6 +226,33 @@ private unsafe static void RegularFuncEval(byte* parameterBuffer, uint parameter LocalVariableSet.SetupArbitraryLocalVariableSet(HighLevelDebugFuncEvalHelperWithVariables, ref typesAndValues, argumentTypes); } + private unsafe static void NewParameterizedObjectNoConstructor(byte* parameterBuffer, uint parameterBufferSize) + { + uint offset = 0; + NativeReader reader = new NativeReader(parameterBuffer, parameterBufferSize); + ulong[] debuggerPreparedExternalReferences; + offset = BuildDebuggerPreparedExternalReferences(reader, offset, out debuggerPreparedExternalReferences); + + NativeLayoutInfoLoadContext nativeLayoutContext = new NativeLayoutInfoLoadContext(); + TypeSystemContext typeSystemContext = TypeSystemContextFactory.Create(); + nativeLayoutContext._module = null; + nativeLayoutContext._typeSystemContext = typeSystemContext; + nativeLayoutContext._typeArgumentHandles = Instantiation.Empty; + nativeLayoutContext._methodArgumentHandles = Instantiation.Empty; + nativeLayoutContext._debuggerPreparedExternalReferences = debuggerPreparedExternalReferences; + + NativeParser parser = new NativeParser(reader, offset); + TypeDesc objectTypeDesc = TypeLoaderEnvironment.Instance.GetConstructedTypeFromParserAndNativeLayoutContext(ref parser, nativeLayoutContext); + + RuntimeTypeHandle objectTypeHandle = objectTypeDesc.GetRuntimeTypeHandle(); + object returnValue = RuntimeAugments.NewObject(objectTypeHandle); + + GCHandle returnValueHandle = GCHandle.Alloc(returnValue); + IntPtr returnValueHandlePointer = GCHandle.ToIntPtr(returnValueHandle); + uint returnHandleIdentifier = RuntimeAugments.RhpRecordDebuggeeInitiatedHandle(returnValueHandlePointer); + ReturnToDebuggerWithReturn(returnHandleIdentifier, returnValueHandlePointer, false); + } + private unsafe static void CreateNewArray(byte* parameterBuffer, uint parameterBufferSize) { uint offset = 0; diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebuggerContract.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebuggerContract.cs index a0bf7b7d2d7..03957fd7a77 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebuggerContract.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/DebuggerSupport/DebuggerContract.cs @@ -15,6 +15,7 @@ internal enum FuncEvalMode : uint RegularFuncEval = 1, NewStringWithLength = 2, NewArray = 3, + NewParameterizedObjectNoConstructor = 4, } internal enum DebuggerResponseKind : uint