Encoding code clean up (#12864)
[platform/upstream/coreclr.git] / src / mscorlib / shared / System / Text / DecoderReplacementFallback.cs
@@ -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;
 using System.Diagnostics;
 using System.Diagnostics.Contracts;
 
@@ -11,7 +10,7 @@ namespace System.Text
     public sealed class DecoderReplacementFallback : DecoderFallback
     {
         // Our variables
-        private String strDefault;
+        private String _strDefault;
 
         // Construction.  Default replacement fallback uses no best fit and ? replacement string
         public DecoderReplacementFallback() : this("?")
@@ -60,14 +59,14 @@ namespace System.Text
             if (bFoundHigh)
                 throw new ArgumentException(SR.Format(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement)));
 
-            strDefault = replacement;
+            _strDefault = replacement;
         }
 
         public String DefaultString
         {
             get
             {
-                return strDefault;
+                return _strDefault;
             }
         }
 
@@ -81,7 +80,7 @@ namespace System.Text
         {
             get
             {
-                return strDefault.Length;
+                return _strDefault.Length;
             }
         }
 
@@ -90,14 +89,14 @@ namespace System.Text
             DecoderReplacementFallback that = value as DecoderReplacementFallback;
             if (that != null)
             {
-                return (strDefault == that.strDefault);
+                return (_strDefault == that._strDefault);
             }
             return (false);
         }
 
         public override int GetHashCode()
         {
-            return strDefault.GetHashCode();
+            return _strDefault.GetHashCode();
         }
     }
 
@@ -106,14 +105,14 @@ namespace System.Text
     public sealed class DecoderReplacementFallbackBuffer : DecoderFallbackBuffer
     {
         // Store our default string
-        private String strDefault;
-        private int fallbackCount = -1;
-        private int fallbackIndex = -1;
+        private String _strDefault;
+        private int _fallbackCount = -1;
+        private int _fallbackIndex = -1;
 
         // Construction
         public DecoderReplacementFallbackBuffer(DecoderReplacementFallback fallback)
         {
-            strDefault = fallback.DefaultString;
+            _strDefault = fallback.DefaultString;
         }
 
         // Fallback Methods
@@ -121,17 +120,17 @@ namespace System.Text
         {
             // We expect no previous fallback in our buffer
             // We can't call recursively but others might (note, we don't test on last char!!!)
-            if (fallbackCount >= 1)
+            if (_fallbackCount >= 1)
             {
                 ThrowLastBytesRecursive(bytesUnknown);
             }
 
             // Go ahead and get our fallback
-            if (strDefault.Length == 0)
+            if (_strDefault.Length == 0)
                 return false;
 
-            fallbackCount = strDefault.Length;
-            fallbackIndex = -1;
+            _fallbackCount = _strDefault.Length;
+            _fallbackIndex = -1;
 
             return true;
         }
@@ -140,35 +139,35 @@ namespace System.Text
         {
             // We want it to get < 0 because == 0 means that the current/last character is a fallback
             // and we need to detect recursion.  We could have a flag but we already have this counter.
-            fallbackCount--;
-            fallbackIndex++;
+            _fallbackCount--;
+            _fallbackIndex++;
 
             // Do we have anything left? 0 is now last fallback char, negative is nothing left
-            if (fallbackCount < 0)
+            if (_fallbackCount < 0)
                 return '\0';
 
             // Need to get it out of the buffer.
             // Make sure it didn't wrap from the fast count-- path
-            if (fallbackCount == int.MaxValue)
+            if (_fallbackCount == int.MaxValue)
             {
-                fallbackCount = -1;
+                _fallbackCount = -1;
                 return '\0';
             }
 
             // Now make sure its in the expected range
-            Debug.Assert(fallbackIndex < strDefault.Length && fallbackIndex >= 0,
+            Debug.Assert(_fallbackIndex < _strDefault.Length && _fallbackIndex >= 0,
                             "Index exceeds buffer range");
 
-            return strDefault[fallbackIndex];
+            return _strDefault[_fallbackIndex];
         }
 
         public override bool MovePrevious()
         {
             // Back up one, only if we just processed the last character (or earlier)
-            if (fallbackCount >= -1 && fallbackIndex >= 0)
+            if (_fallbackCount >= -1 && _fallbackIndex >= 0)
             {
-                fallbackIndex--;
-                fallbackCount++;
+                _fallbackIndex--;
+                _fallbackCount++;
                 return true;
             }
 
@@ -182,15 +181,15 @@ namespace System.Text
             get
             {
                 // Our count is 0 for 1 character left.
-                return (fallbackCount < 0) ? 0 : fallbackCount;
+                return (_fallbackCount < 0) ? 0 : _fallbackCount;
             }
         }
 
         // Clear the buffer
         public override unsafe void Reset()
         {
-            fallbackCount = -1;
-            fallbackIndex = -1;
+            _fallbackCount = -1;
+            _fallbackIndex = -1;
             byteStart = null;
         }
 
@@ -200,7 +199,7 @@ namespace System.Text
         // array, and we might need the index, hence the byte*
         {
             // return our replacement string Length
-            return strDefault.Length;
+            return _strDefault.Length;
         }
     }
 }