From 17078c2488cf25bdbc89e956caf20adb8b0cced0 Mon Sep 17 00:00:00 2001 From: James Ko Date: Mon, 4 Jul 2016 15:45:19 -0400 Subject: [PATCH] [EncodingNLS] Remove unncessary comments Commit migrated from https://github.com/dotnet/coreclr/commit/95ff597b07cf40532f6af52beab076bd80332b0f --- .../src/mscorlib/src/System/Text/EncodingNLS.cs | 79 ++++++---------------- 1 file changed, 21 insertions(+), 58 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs b/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs index 47cec13..fa988cb 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs @@ -14,18 +14,7 @@ namespace System.Text using Win32Native = Microsoft.Win32.Win32Native; // This class overrides Encoding with the things we need for our NLS Encodings - // - // All of the GetBytes/Chars GetByte/CharCount methods are just wrappers for the pointer - // plus decoder/encoder method that is our real workhorse. Note that this is an internal - // class, so our public classes cannot derive from this class. Because of this, all of the - // GetBytes/Chars GetByte/CharCount wrapper methods are duplicated in all of our public - // encodings, which currently include: - // - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, & UnicodeEncoding - // - // So if you change the wrappers in this class, you must change the wrappers in the other classes - // as well because they should have the same behavior. - // + [System.Runtime.InteropServices.ComVisible(true)] [Serializable] internal abstract class EncodingNLS : Encoding @@ -34,42 +23,41 @@ namespace System.Text { } + // NOTE: Many methods in this class forward to EncodingForwarder for + // validating arguments/wrapping the unsafe methods in this class + // which do the actual work. That class contains + // shared logic for doing this which is used by + // ASCIIEncoding, EncodingNLS, UnicodeEncoding, UTF32Encoding, + // UTF7Encoding, and UTF8Encoding. + // The reason the code is separated out into a static class, rather + // than a base class which overrides all of these methods for us + // (which is what EncodingNLS is for internal Encodings) is because + // that's really more of an implementation detail so it's internal. + // At the same time, C# doesn't allow a public class subclassing an + // internal/private one, so we end up having to re-override these + // methods in all of the public Encodings + EncodingNLS. + // Returns the number of bytes required to encode a range of characters in // a character array. - // - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - // parent method is safe + [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - // parent method is safe + [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetByteCount(String s) { return EncodingForwarder.GetByteCount(this, s); - } + } - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding [System.Security.SecurityCritical] // auto-generated public override unsafe int GetByteCount(char* chars, int count) { return EncodingForwarder.GetByteCount(this, chars, count); } - // Parent method is safe. - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetBytes(String s, int charIndex, int charCount, byte[] bytes, int byteIndex) @@ -85,11 +73,7 @@ namespace System.Text // Alternatively, the GetMaxByteCount method can be used to // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - // - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - // parent method is safe + [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) @@ -97,9 +81,6 @@ namespace System.Text return EncodingForwarder.GetBytes(this, chars, charIndex, charCount, bytes, byteIndex); } - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding [System.Security.SecurityCritical] // auto-generated public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int byteCount) { @@ -108,30 +89,19 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - // - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - // parent method is safe + [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); } - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding [System.Security.SecurityCritical] // auto-generated public override unsafe int GetCharCount(byte* bytes, int count) { return EncodingForwarder.GetCharCount(this, bytes, count); } - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - // parent method is safe [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) @@ -139,9 +109,6 @@ namespace System.Text return EncodingForwarder.GetChars(this, bytes, byteIndex, byteCount, chars, charIndex); } - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding [System.Security.SecurityCritical] // auto-generated public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount) { @@ -150,11 +117,7 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - // - // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) - // So if you fix this, fix the others. Currently those include: - // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - // parent method is safe + [System.Security.SecuritySafeCritical] // overrides public transparent member public override String GetString(byte[] bytes, int index, int count) { -- 2.7.4