Delete unused leftovers from binary serialization (#15140)
authorJan Kotas <jkotas@microsoft.com>
Tue, 21 Nov 2017 22:44:58 +0000 (14:44 -0800)
committerGitHub <noreply@github.com>
Tue, 21 Nov 2017 22:44:58 +0000 (14:44 -0800)
12 files changed:
src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
src/mscorlib/shared/System/Globalization/NumberFormatInfo.cs
src/mscorlib/shared/System/Globalization/SortKey.cs
src/mscorlib/shared/System/Globalization/StringInfo.cs
src/mscorlib/shared/System/Lazy.cs
src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs
src/mscorlib/src/System/Diagnostics/Stacktrace.cs
src/mscorlib/src/System/Globalization/CultureInfo.cs
src/mscorlib/src/System/Globalization/RegionInfo.cs
src/mscorlib/src/System/Resources/ResourceManager.cs
src/vm/debugdebugger.h
src/vm/mscorlib.h

index 9dbfeb2..2e824c9 100644 (file)
@@ -5,7 +5,6 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
-using System.Runtime.Serialization;
 
 namespace System.Globalization
 {
@@ -56,24 +55,18 @@ namespace System.Globalization
         private static volatile DateTimeFormatInfo s_invariantInfo;
 
         // an index which points to a record in Culture Data Table.
-        [NonSerialized]
         private CultureData _cultureData;
 
         // The culture name used to create this DTFI.
-
-        [OptionalField(VersionAdded = 2)]
         private String _name = null;
 
         // The language name of the culture used to create this DTFI.
-        [NonSerialized]
         private String _langName = null;
 
         // CompareInfo usually used by the parser.
-        [NonSerialized]
         private CompareInfo _compareInfo = null;
 
         // Culture matches current DTFI. mainly used for string comparisons during parsing.
-        [NonSerialized]
         private CultureInfo _cultureInfo = null;
 
         //
@@ -147,7 +140,6 @@ namespace System.Globalization
         private String longTimePattern = null;
         private String shortTimePattern = null;
 
-        [OptionalField(VersionAdded = 3)]
         private String[] allYearMonthPatterns = null;
 
         private String[] allShortDatePatterns = null;
@@ -347,7 +339,6 @@ namespace System.Globalization
             Debug.Assert(this.allYearMonthPatterns.Length > 0, "[DateTimeFormatInfo.Populate] Expected some year month patterns");
         }
 
-        [OptionalField(VersionAdded = 1)]
         private bool _useUserOverride;
 
         // This was synthesized by Whidbey so we knew what words might appear in the middle of a date string
@@ -355,65 +346,6 @@ namespace System.Globalization
 
         internal String[] m_dateWords = null;
 
-        [OnSerializing]
-        private void OnSerializing(StreamingContext ctx)
-        {
-            _name = this.CultureName; // make sure the _name is initialized.
-            _useUserOverride = _cultureData.UseUserOverride;
-
-            // Important to initialize these fields otherwise we may run into exception when deserializing on Whidbey
-            // because Whidbey try to initialize some of these fields using calendar data which could be null values 
-            // and then we get exceptions.  So we call the accessors to force the caches to get loaded.
-            Object o;
-            o = this.LongTimePattern;
-            o = this.LongDatePattern;
-            o = this.ShortTimePattern;
-            o = this.ShortDatePattern;
-            o = this.YearMonthPattern;
-            o = this.AllLongTimePatterns;
-            o = this.AllLongDatePatterns;
-            o = this.AllShortTimePatterns;
-            o = this.AllShortDatePatterns;
-            o = this.AllYearMonthPatterns;
-        }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext ctx)
-        {
-            if (_name != null)
-            {
-                _cultureData = CultureData.GetCultureData(_name, _useUserOverride);
-                if (_cultureData == null)
-                {
-                    throw new CultureNotFoundException("_name", _name, SR.Argument_CultureNotSupported);
-                }
-            }
-
-            if (calendar == null)
-            {
-                calendar = (Calendar)GregorianCalendar.GetDefaultInstance().Clone();
-                calendar.SetReadOnlyState(_isReadOnly);
-            }
-
-            InitializeOverridableProperties(_cultureData, calendar.ID);
-
-            //
-            //  turn off read only state till we finish initializing all fields and then store read only state after we are done.
-            //
-            bool isReadOnly = _isReadOnly;
-            _isReadOnly = false;
-
-            // If we deserialized defaults ala Whidbey, make sure they're still defaults
-            // Whidbey's arrays could get a bit mixed up.
-            if (longDatePattern != null) this.LongDatePattern = longDatePattern;
-            if (shortDatePattern != null) this.ShortDatePattern = shortDatePattern;
-            if (yearMonthPattern != null) this.YearMonthPattern = yearMonthPattern;
-            if (longTimePattern != null) this.LongTimePattern = longTimePattern;
-            if (shortTimePattern != null) this.ShortTimePattern = shortTimePattern;
-
-            _isReadOnly = isReadOnly;
-        }
-
         // Returns a default DateTimeFormatInfo that will be universally
         // supported and constant irrespective of the current culture.
         // Used by FromString methods.
@@ -2094,7 +2026,6 @@ namespace System.Globalization
         //
         // Positive TimeSpan Pattern
         //
-        [NonSerialized]
         private string _fullTimeSpanPositivePattern;
         internal String FullTimeSpanPositivePattern
         {
@@ -2118,7 +2049,6 @@ namespace System.Globalization
         //
         // Negative TimeSpan Pattern
         //
-        [NonSerialized]
         private string _fullTimeSpanNegativePattern;
         internal String FullTimeSpanNegativePattern
         {
@@ -2269,7 +2199,6 @@ namespace System.Globalization
         //
         // DateTimeFormatInfo tokenizer.  This is used by DateTime.Parse() to break input string into tokens.
         //
-        [NonSerialized]
         private TokenHashValue[] _dtfiTokenHash;
 
         private const int TOKEN_HASH_SIZE = 199;
index 787e364..7293642 100644 (file)
@@ -3,7 +3,6 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
-using System.Runtime.Serialization;
 using System.Text;
 
 namespace System.Globalization
@@ -69,7 +68,6 @@ namespace System.Globalization
         internal String perMilleSymbol = "\u2030";
 
 
-        [OptionalField(VersionAdded = 2)]
         internal String[] nativeDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
 
         internal int numberDecimalDigits = 2;
@@ -81,29 +79,17 @@ namespace System.Globalization
         internal int percentNegativePattern = 0;
         internal int percentDecimalDigits = 2;
 
-        [OptionalField(VersionAdded = 2)]
         internal int digitSubstitution = (int)DigitShapes.None;
 
         internal bool isReadOnly = false;
 
         // Is this NumberFormatInfo for invariant culture?
-
-        [OptionalField(VersionAdded = 2)]
         internal bool m_isInvariant = false;
 
         public NumberFormatInfo() : this(null)
         {
         }
 
-        [OnSerializing]
-        private void OnSerializing(StreamingContext ctx) { }
-
-        [OnDeserializing]
-        private void OnDeserializing(StreamingContext ctx) { }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext ctx) { }
-
         private static void VerifyDecimalSeparator(String decSep, String propertyName)
         {
             if (decSep == null)
index 9b706fd..647db75 100644 (file)
@@ -13,7 +13,6 @@
 
 using System;
 using System.Runtime.CompilerServices;
-using System.Runtime.Serialization;
 using System.Diagnostics;
 
 namespace System.Globalization
@@ -24,12 +23,8 @@ namespace System.Globalization
         //                        Internal Information                        //
         //--------------------------------------------------------------------//
 
-        [OptionalField(VersionAdded = 3)]
         internal string _localeName;       // locale identifier
 
-        [OptionalField(VersionAdded = 1)] // LCID field so serialization is Whidbey compatible though we don't officially support it
-        internal int _win32LCID;
-
         internal CompareOptions _options;  // options
         internal string _string;         // original string
         internal byte[] _keyData;        // sortkey data
@@ -46,26 +41,6 @@ namespace System.Globalization
             _string = str;
         }
 
-        [OnSerializing]
-        private void OnSerializing(StreamingContext context)
-        {
-            //set LCID to proper value for Whidbey serialization (no other use)
-            if (_win32LCID == 0)
-            {
-                _win32LCID = CultureInfo.GetCultureInfo(_localeName).LCID;
-            }
-        }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext context)
-        {
-            //set locale name to proper value after Whidbey deserialization
-            if (String.IsNullOrEmpty(_localeName) && _win32LCID != 0)
-            {
-                _localeName = CultureInfo.GetCultureInfo(_win32LCID).Name;
-            }
-        }
-
         ////////////////////////////////////////////////////////////////////////
         //
         //  GetOriginalString
index c2fbe5a..aa62b2c 100644 (file)
 
 using System;
 using System.Diagnostics;
-using System.Runtime.Serialization;
 
 namespace System.Globalization
 {
     public class StringInfo
     {
-        [OptionalField(VersionAdded = 2)] 
         private string _str;
 
-        [NonSerialized]
         private int[] _indexes;
 
         // Legacy constructor
@@ -35,21 +32,6 @@ namespace System.Globalization
             this.String = value;
         }
 
-        [OnDeserializing]
-        private void OnDeserializing(StreamingContext ctx)
-        {
-            _str = String.Empty;
-        }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext ctx)
-        {
-            if (_str.Length == 0)
-            {
-                _indexes = null;
-            }
-        }
-
         public override bool Equals(Object value)
         {
             StringInfo that = value as StringInfo;
index 4a56b18..6410c2e 100644 (file)
@@ -15,7 +15,6 @@
 using System.Diagnostics;
 using System.Runtime.ExceptionServices;
 using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
 using System.Threading;
 
 namespace System
@@ -191,17 +190,15 @@ namespace System
             return (T)LazyHelper.CreateViaDefaultConstructor(typeof(T));
         }
 
-        // _state, a volatile reference, is set to null after m_value has been set
-        [NonSerialized]
+        // _state, a volatile reference, is set to null after _value has been set
         private volatile LazyHelper _state;
 
         // we ensure that _factory when finished is set to null to allow garbage collector to clean up
         // any referenced items
-        [NonSerialized]
         private Func<T> _factory;
 
         // _value eventually stores the lazily created value. It is valid when _state = null.
-        private T m_value; // Do not rename (binary serialization)
+        private T _value;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="T:System.Threading.Lazy{T}"/> class that 
@@ -225,7 +222,7 @@ namespace System
         /// </remarks>
         public Lazy(T value)
         {
-            m_value = value;
+            _value = value;
         }
 
         /// <summary>
@@ -311,7 +308,7 @@ namespace System
 
         private void ViaConstructor()
         {
-            m_value = CreateViaDefaultConstructor();
+            _value = CreateViaDefaultConstructor();
             _state = null; // volatile write, must occur after setting _value
         }
 
@@ -324,7 +321,7 @@ namespace System
                     throw new InvalidOperationException(SR.Lazy_Value_RecursiveCallsToValue);
                 _factory = null;
 
-                m_value = factory();
+                _value = factory();
                 _state = null; // volatile write, must occur after setting _value
             }
             catch (Exception exception)
@@ -360,7 +357,7 @@ namespace System
             if (previous == publicationOnly)
             {
                 _factory = null;
-                m_value = possibleValue;
+                _value = possibleValue;
                 _state = null; // volatile write, must occur after setting _value
             }
         }
@@ -439,15 +436,6 @@ namespace System
             return Value;
         }
 
-        /// <summary>Forces initialization during serialization.</summary>
-        /// <param name="context">The StreamingContext for the serialization operation.</param>
-        [OnSerializing]
-        private void OnSerializing(StreamingContext context)
-        {
-            // Force initialization
-            T dummy = Value;
-        }
-
         /// <summary>Creates and returns a string representation of this instance.</summary>
         /// <returns>The result of calling <see cref="System.Object.ToString"/> on the <see
         /// cref="Value"/>.</returns>
@@ -468,7 +456,7 @@ namespace System
                 {
                     return default(T);
                 }
-                return m_value;
+                return _value;
             }
         }
 
@@ -515,7 +503,7 @@ namespace System
         /// from initialization delegate.
         /// </remarks>
         [DebuggerBrowsable(DebuggerBrowsableState.Never)]
-        public T Value => _state == null ? m_value : CreateValue();
+        public T Value => _state == null ? _value : CreateValue();
     }
 
     /// <summary>A debugger view of the Lazy&lt;T&gt; to surface additional debugging properties and 
index 2337439..25d0335 100644 (file)
@@ -23,11 +23,8 @@ namespace System.Collections.ObjectModel
     internal class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>
     {
         private readonly IDictionary<TKey, TValue> m_dictionary;
-        [NonSerialized]
         private Object m_syncRoot;
-        [NonSerialized]
         private KeyCollection m_keys;
-        [NonSerialized]
         private ValueCollection m_values;
 
         public ReadOnlyDictionary(IDictionary<TKey, TValue> dictionary)
@@ -429,7 +426,6 @@ namespace System.Collections.ObjectModel
         public sealed class KeyCollection : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey>
         {
             private readonly ICollection<TKey> m_collection;
-            [NonSerialized]
             private Object m_syncRoot;
 
             internal KeyCollection(ICollection<TKey> collection)
@@ -539,7 +535,6 @@ namespace System.Collections.ObjectModel
         public sealed class ValueCollection : ICollection<TValue>, ICollection, IReadOnlyCollection<TValue>
         {
             private readonly ICollection<TValue> m_collection;
-            [NonSerialized]
             private Object m_syncRoot;
 
             internal ValueCollection(ICollection<TValue> collection)
index 5c7e7b3..1db7358 100644 (file)
@@ -12,7 +12,6 @@ using System.Reflection;
 using System.Runtime.InteropServices;
 using System.Runtime.CompilerServices;
 using System.Globalization;
-using System.Runtime.Serialization;
 using System.Runtime.Versioning;
 
 namespace System.Diagnostics
@@ -23,19 +22,15 @@ namespace System.Diagnostics
     // VM\DebugDebugger.h. The binder will catch some of these layout problems.
     internal class StackFrameHelper : IDisposable
     {
-        [NonSerialized]
         private Thread targetThread;
         private int[] rgiOffset;
         private int[] rgiILOffset;
-        // this field is here only for backwards compatibility of serialization format
-        private MethodBase[] rgMethodBase;
 
 #pragma warning disable 414
         // dynamicMethods is an array of System.Resolver objects, used to keep
         // DynamicMethodDescs alive for the lifetime of StackFrameHelper.
         private Object dynamicMethods; // Field is not used from managed.        
 
-        [NonSerialized]
         private IntPtr[] rgMethodHandle;
         private String[] rgAssemblyPath;
         private IntPtr[] rgLoadedPeAddress;
@@ -47,7 +42,6 @@ namespace System.Diagnostics
         private String[] rgFilename;
         private int[] rgiLineNumber;
         private int[] rgiColumnNumber;
-        [OptionalField]
         private bool[] rgiLastFrameFromForeignExceptionStackTrace;
         private GetSourceLineInfoDelegate getSourceLineInfo;
         private int iFrameCount;
@@ -66,7 +60,6 @@ namespace System.Diagnostics
         public StackFrameHelper(Thread target)
         {
             targetThread = target;
-            rgMethodBase = null;
             rgMethodHandle = null;
             rgiMethodToken = null;
             rgiOffset = null;
@@ -198,49 +191,6 @@ namespace System.Diagnostics
         }
 
         public virtual int GetNumberOfFrames() { return iFrameCount; }
-
-        //
-        // serialization implementation
-        //
-        [OnSerializing]
-        private void OnSerializing(StreamingContext context)
-        {
-            // this is called in the process of serializing this object.
-            // For compatibility with Everett we need to assign the rgMethodBase field as that is the field
-            // that will be serialized
-            rgMethodBase = (rgMethodHandle == null) ? null : new MethodBase[rgMethodHandle.Length];
-            if (rgMethodHandle != null)
-            {
-                for (int i = 0; i < rgMethodHandle.Length; i++)
-                {
-                    if (!rgMethodHandle[i].IsNull())
-                        rgMethodBase[i] = RuntimeType.GetMethodBase(new RuntimeMethodInfoStub(rgMethodHandle[i], this));
-                }
-            }
-        }
-
-        [OnSerialized]
-        private void OnSerialized(StreamingContext context)
-        {
-            // after we are done serializing null the rgMethodBase field
-            rgMethodBase = null;
-        }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext context)
-        {
-            // after we are done deserializing we need to transform the rgMethodBase in rgMethodHandle
-            rgMethodHandle = (rgMethodBase == null) ? null : new IntPtr[rgMethodBase.Length];
-            if (rgMethodBase != null)
-            {
-                for (int i = 0; i < rgMethodBase.Length; i++)
-                {
-                    if (rgMethodBase[i] != null)
-                        rgMethodHandle[i] = rgMethodBase[i].MethodHandle.Value;
-                }
-            }
-            rgMethodBase = null;
-        }
     }
 
 
index fb7176a..f700678 100644 (file)
@@ -28,7 +28,6 @@
 
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Runtime.Serialization;
 using System.Threading;
 
 namespace System.Globalization
@@ -49,10 +48,6 @@ namespace System.Globalization
         //                        Internal Information                        //
         //--------------------------------------------------------------------//
 
-        //--------------------------------------------------------------------//
-        // Data members to be serialized:
-        //--------------------------------------------------------------------//
-
         // We use an RFC4646 type string to construct CultureInfo.
         // This string is stored in _name and is authoritative.
         // We use the _cultureData to get the data for our object
@@ -68,13 +63,10 @@ namespace System.Globalization
         // For supported culture, this will be the CultureData instance that read data from mscorlib assembly.
         // For customized culture, this will be the CultureData instance that read data from user customized culture binary file.
         //
-        [NonSerialized]
         internal CultureData _cultureData;
 
-        [NonSerialized]
         internal bool _isInherited;
 
-        [NonSerialized]
         private CultureInfo _consoleFallbackCulture;
 
         // Names are confusing.  Here are 3 names we have:
@@ -88,20 +80,16 @@ namespace System.Globalization
         // Note that in Silverlight we ask the OS for the text and sort behavior, so the 
         // textinfo and compareinfo names are the same as the name
 
-        // Note that the name used to be serialized for Everett; it is now serialized
-        // because alernate sorts can have alternate names.
         // This has a de-DE, de-DE_phoneb or fj-FJ style name
         internal string _name;
 
         // This will hold the non sorting name to be returned from CultureInfo.Name property.
         // This has a de-DE style name even for de-DE_phoneb type cultures
-        [NonSerialized]
         private string _nonSortName;
 
         // This will hold the sorting name to be returned from CultureInfo.SortName property.
         // This might be completely unrelated to the culture name if a custom culture.  Ie en-US for fj-FJ.
         // Otherwise its the sort name, ie: de-DE or de-DE_phoneb
-        [NonSerialized]
         private string _sortName;
 
         //--------------------------------------------------------------------//
@@ -149,7 +137,6 @@ namespace System.Globalization
         private static volatile StringLcidDictionary s_LcidCachedCultures;       
 
         //The parent culture.
-        [NonSerialized]
         private CultureInfo _parent;
 
         // LOCALE constants of interest to us internally and privately for LCID functions
@@ -419,20 +406,6 @@ namespace System.Globalization
 
         // We need to store the override from the culture data record.
         private bool _useUserOverride;
-
-        [OnSerializing]
-        private void OnSerializing(StreamingContext ctx)
-        {
-            _name = _cultureData.CultureName;
-            _useUserOverride = _cultureData.UseUserOverride;
-        }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext ctx)
-        {
-            Debug.Assert(_name != null, "[CultureInfo.OnDeserialized] _name != null");
-            InitializeFromName(_name, _useUserOverride);
-        }
         
         internal static CultureInfo GetCurrentUICultureNoAppX()
         {
index 3acfa16..2cad7bb 100644 (file)
@@ -15,7 +15,6 @@
 ////////////////////////////////////////////////////////////////////////////
 
 using System.Diagnostics;
-using System.Runtime.Serialization;
 
 namespace System.Globalization
 {
@@ -125,24 +124,6 @@ namespace System.Globalization
             _name = _cultureData.SREGIONNAME;
         }
 
-        [OnSerializing]
-        private void OnSerializing(StreamingContext ctx) { }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext ctx)
-        {
-            _cultureData = CultureData.GetCultureData(_name, true);
-
-            if (_cultureData == null)
-            {
-                throw new ArgumentException(
-                    String.Format(CultureInfo.CurrentCulture, SR.Argument_InvalidCultureName, _name),
-                    "_name");
-            }
-
-            _name = _cultureData.SREGIONNAME;
-        }
-
         ////////////////////////////////////////////////////////////////////////
         //
         //  GetCurrentRegion
index f730d86..cd3364a 100644 (file)
@@ -22,7 +22,6 @@ namespace System.Resources
     using System.Collections;
     using System.Text;
     using System.Reflection;
-    using System.Runtime.Serialization;
     using System.Security;
     using System.Threading;
     using System.Runtime.InteropServices;
@@ -112,13 +111,9 @@ namespace System.Resources
     // We encapsulate fallback logic in a fallback iterator class, so that 
     // this logic isn't duplicated in several methods.
     // 
-    // In the future, we can look into either breaking serialization if we
-    // decide this doesn't make sense for ResourceManager (i.e. how common
-    // is the scenario), manually make serialization work by providing 
-    // appropriate OnSerialization, Deserialization methods. We can also 
-    // look into further factoring and better design of IResourceGroveler
-    // interface to accommodate unused parameters that don't make sense
-    // for either file-based or manifest-based lookup paths.
+    // In the future, we can also look into further factoring and better
+    // design of IResourceGroveler interface to accommodate unused parameters
+    // that don't make sense for either file-based or manifest-based lookup paths.
     //
     // Benefits of this refactoring:
     // - Makes it possible to understand what the ResourceManager does, 
@@ -162,8 +157,6 @@ namespace System.Resources
         internal Hashtable ResourceSets;
 
 
-        // don't serialize the cache of ResourceSets
-        [NonSerialized]
         private Dictionary<String, ResourceSet> _resourceSets;
         private String moduleDir;      // For assembly-ignorant directory location
         protected Assembly MainAssembly;   // Need the assembly manifest sometimes.
@@ -171,17 +164,12 @@ namespace System.Resources
         private Type _userResourceSet;  // Which ResourceSet instance to create
         private CultureInfo _neutralResourcesCulture;  // For perf optimizations.
 
-        [NonSerialized]
         private CultureNameResourceSetPair _lastUsedResourceCache;
 
         private bool _ignoreCase;   // Whether case matters in GetString & GetObject
 
         private bool UseManifest;  // Use Assembly manifest, or grovel disk.
 
-        // unused! But need to keep for serialization
-        [OptionalField(VersionAdded = 1)]
-        private bool UseSatelliteAssem;  // Are all the .resources files in the 
-                                         // main assembly, or in satellite assemblies for each culture?
 #if RESOURCE_SATELLITE_CONFIG
         private static volatile Hashtable _installedSatelliteInfo;  // Give the user the option  
                                                                     // to prevent certain satellite assembly probes via a config file.
@@ -191,24 +179,13 @@ namespace System.Resources
 
         // Whether to fall back to the main assembly or a particular 
         // satellite for the neutral resources.
-        [OptionalField]
         private UltimateResourceFallbackLocation _fallbackLoc;
         // Version number of satellite assemblies to look for.  May be null.
-        [OptionalField]
         private Version _satelliteContractVersion;
-        [OptionalField]
         private bool _lookedForSatelliteContractVersion;
 
-        // unused! But need to keep for serialization
-        [OptionalField(VersionAdded = 1)]
-        private Assembly _callingAssembly;  // Assembly who created the ResMgr.
+        private RuntimeAssembly _callingAssembly;  // Assembly who created the ResMgr.
 
-        // replaces _callingAssembly
-        [OptionalField(VersionAdded = 4)]
-        private RuntimeAssembly m_callingAssembly;  // Assembly who created the ResMgr.
-
-        // no need to serialize this; just create a new one on deserialization
-        [NonSerialized]
         private IResourceGroveler resourceGroveler;
 
         public static readonly int MagicNumber = unchecked((int)0xBEEFCACE);  // If only hex had a K...
@@ -247,7 +224,7 @@ namespace System.Resources
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         private void Init()
         {
-            m_callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
+            _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
         }
 
         protected ResourceManager()
@@ -310,14 +287,14 @@ namespace System.Resources
 
             CommonAssemblyInit();
 
-            m_callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
+            _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
             // Special case for mscorlib - protect mscorlib's private resources.
             // This isn't for security reasons, but to ensure we can make
             // breaking changes to mscorlib's internal resources without 
             // assuming users may have taken a dependency on them.
-            if (assembly == typeof(Object).Assembly && m_callingAssembly != assembly)
+            if (assembly == typeof(Object).Assembly && _callingAssembly != assembly)
             {
-                m_callingAssembly = null;
+                _callingAssembly = null;
             }
         }
 
@@ -340,13 +317,13 @@ namespace System.Resources
             _userResourceSet = usingResourceSet;
 
             CommonAssemblyInit();
-            m_callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
+            _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
             // Special case for mscorlib - protect mscorlib's private resources.
             // This isn't for security reasons, but to ensure we can make
             // breaking changes to mscorlib's internal resources without 
             // assuming users may have taken a dependency on them.
-            if (assembly == typeof(Object).Assembly && m_callingAssembly != assembly)
-                m_callingAssembly = null;
+            if (assembly == typeof(Object).Assembly && _callingAssembly != assembly)
+                _callingAssembly = null;
         }
 
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
@@ -366,64 +343,14 @@ namespace System.Resources
 
             CommonAssemblyInit();
 
-            m_callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
+            _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
             // Special case for mscorlib - protect mscorlib's private resources.
-            if (MainAssembly == typeof(Object).Assembly && m_callingAssembly != MainAssembly)
-            {
-                m_callingAssembly = null;
-            }
-        }
-
-        [OnDeserializing]
-        private void OnDeserializing(StreamingContext ctx)
-        {
-            _resourceSets = null;
-            resourceGroveler = null;
-            _lastUsedResourceCache = null;
-        }
-
-        [OnDeserialized]
-        private void OnDeserialized(StreamingContext ctx)
-        {
-            _resourceSets = new Dictionary<String, ResourceSet>();
-            _lastUsedResourceCache = new CultureNameResourceSetPair();
-            // set up resource groveler, depending on whether this ResourceManager
-            // is looking for files or assemblies
-            ResourceManagerMediator mediator = new ResourceManagerMediator(this);
-            if (UseManifest)
-            {
-                resourceGroveler = new ManifestBasedResourceGroveler(mediator);
-            }
-            else
-            {
-                resourceGroveler = new FileBasedResourceGroveler(mediator);
-            }
-
-            // correct callingAssembly for v2
-            if (m_callingAssembly == null)
-            {
-                m_callingAssembly = (RuntimeAssembly)_callingAssembly;
-            }
-
-            // v2 does this lazily
-            if (UseManifest && _neutralResourcesCulture == null)
+            if (MainAssembly == typeof(Object).Assembly && _callingAssembly != MainAssembly)
             {
-                _neutralResourcesCulture = ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(MainAssembly, ref _fallbackLoc);
+                _callingAssembly = null;
             }
         }
 
-        [OnSerializing]
-        private void OnSerializing(StreamingContext ctx)
-        {
-            // Initialize the fields Whidbey expects
-            _callingAssembly = m_callingAssembly;
-            UseSatelliteAssem = UseManifest;
-#pragma warning disable 618
-            ResourceSets = new Hashtable(); // for backward compatibility
-#pragma warning restore 618
-        }
-
-
         // Trying to unify code as much as possible, even though having to do a
         // security check in each constructor prevents it.
         private void CommonAssemblyInit()
@@ -605,7 +532,7 @@ namespace System.Resources
             {
                 string fileName = GetResourceFileName(culture);
                 RuntimeAssembly mainAssembly = (RuntimeAssembly)MainAssembly;
-                Stream stream = mainAssembly.GetManifestResourceStream(_locationInfo, fileName, m_callingAssembly == MainAssembly, ref stackMark);
+                Stream stream = mainAssembly.GetManifestResourceStream(_locationInfo, fileName, _callingAssembly == MainAssembly, ref stackMark);
                 if (createIfNotExists && stream != null)
                 {
                     rs = ((ManifestBasedResourceGroveler)resourceGroveler).CreateResourceSet(stream, MainAssembly);
@@ -851,17 +778,13 @@ namespace System.Resources
         }
 #endif
 
-        [NonSerialized]
         private bool _bUsingModernResourceManagement; // Written only by SetAppXConfiguration
 
 #if FEATURE_APPX
-        [NonSerialized]
         private WindowsRuntimeResourceManagerBase _WinRTResourceManager; // Written only by SetAppXConfiguration
 
-        [NonSerialized]
         private bool _PRIonAppXInitialized; // Written only by SetAppXConfiguration
 
-        [NonSerialized]
         private PRIExceptionInfo _PRIExceptionInfo; // Written only by SetAppXConfiguration
 
         // When running under AppX, the following rules apply for resource lookup:
@@ -919,7 +842,7 @@ namespace System.Resources
             RuntimeAssembly resourcesAssembly = (RuntimeAssembly)MainAssembly;
 
             if (resourcesAssembly == null)
-                resourcesAssembly = m_callingAssembly;
+                resourcesAssembly = _callingAssembly;
 
             if (resourcesAssembly != null)
             {
@@ -1389,7 +1312,7 @@ namespace System.Resources
 
             internal RuntimeAssembly CallingAssembly
             {
-                get { return _rm.m_callingAssembly; }
+                get { return _rm._callingAssembly; }
             }
 
             internal RuntimeAssembly MainAssembly
index 11045d3..14005e6 100644 (file)
@@ -45,7 +45,6 @@ public:
     THREADBASEREF targetThread;
     I4ARRAYREF rgiOffset;
     I4ARRAYREF rgiILOffset;
-    BASEARRAYREF rgMethodBase;
     PTRARRAYREF dynamicMethods;
     BASEARRAYREF rgMethodHandle;
     PTRARRAYREF rgAssemblyPath;
index 0039471..8129e4c 100644 (file)
@@ -823,7 +823,6 @@ DEFINE_CLASS_U(Diagnostics,                StackFrameHelper,   StackFrameHelper)
 DEFINE_FIELD_U(targetThread,               StackFrameHelper,   targetThread)
 DEFINE_FIELD_U(rgiOffset,                  StackFrameHelper,   rgiOffset)
 DEFINE_FIELD_U(rgiILOffset,                StackFrameHelper,   rgiILOffset)
-DEFINE_FIELD_U(rgMethodBase,               StackFrameHelper,   rgMethodBase)
 DEFINE_FIELD_U(dynamicMethods,             StackFrameHelper,   dynamicMethods)
 DEFINE_FIELD_U(rgMethodHandle,             StackFrameHelper,   rgMethodHandle)
 DEFINE_FIELD_U(rgAssemblyPath,             StackFrameHelper,   rgAssemblyPath)