Replace SIZEOF_REGISTER with sizeof(mgreg_t) for consistency with sizeof(gpointer)
[mono.git] / mcs / class / corlib / System / Exception.cs
index 059e036339f077419f34f2c63470ba87e8d5580f..01a2a5b134a6dc11af6cffd96ef41fadeea9ec9c 100644 (file)
@@ -40,17 +40,10 @@ using System.Security.Permissions;
 namespace System
 {
        [Serializable]
-#if NET_2_0
        [ComVisible(true)]
        [ComDefaultInterface (typeof (_Exception))]
        [ClassInterface (ClassInterfaceType.None)]
-#else
-       [ClassInterface (ClassInterfaceType.AutoDual)]
-#endif
-       public class Exception : ISerializable 
-#if NET_2_0
-       , _Exception
-#endif
+       public class Exception : ISerializable, _Exception
        {
 #pragma warning disable 169, 649
                #region Sync with object-internals.h
@@ -71,6 +64,15 @@ namespace System
                #endregion
 #pragma warning restore 169, 649               
 
+#if NET_4_0
+               protected event EventHandler<SafeSerializationEventArgs> SerializeObjectState {
+                       [MonoTODO]
+                       add { throw new NotImplementedException (); }
+                       [MonoTODO]
+                       remove { throw new NotImplementedException (); }
+               }
+#endif
+
                public Exception ()
                {
                }
@@ -95,14 +97,11 @@ namespace System
                        source              = info.GetString ("Source");
                        inner_exception     = (Exception) info.GetValue ("InnerException", typeof (Exception));
 
-#if NET_2_0
                        try {
                                _data = (IDictionary) info.GetValue ("Data", typeof (IDictionary));
                        } catch (SerializationException) {
                                // member did not exist in .NET 1.x
                        }
-#endif
-
                }
 
                public Exception (string message, Exception innerException)
@@ -146,11 +145,7 @@ namespace System
                public virtual string Message {
                        get {
                                if (message == null)
-#if NET_2_0
                                        message = string.Format (Locale.GetText ("Exception of type '{0}' was thrown."),
-#else
-                                       message = string.Format (Locale.GetText ("Exception of type {0} was thrown."),
-#endif
                                                ClassName);
 
                                return message;
@@ -158,9 +153,6 @@ namespace System
                }
 
                public virtual string Source {
-#if ONLY_1_1
-                       [ReflectionPermission (SecurityAction.Assert, TypeInformation = true)]
-#endif
                        get {
                                if (source == null) {
                                        StackTrace st = new StackTrace (this, true);
@@ -219,10 +211,9 @@ namespace System
                                                        else
                                                                sb.AppendFormat (" [0x{0:x5}] ", frame.GetILOffset ());
 
-                                                       string fileName = frame.GetFileName ();
-                                                       if (fileName != null)
-                                                               sb.AppendFormat ("in {0}:{1} ", fileName, frame.GetFileLineNumber ());
-                                                       }
+                                                       sb.AppendFormat ("in {0}:{1} ", frame.GetSecureFileName (), 
+                                                               frame.GetFileLineNumber ());
+                                               }
                                        }
                                        stack_trace = sb.ToString ();
                                }
@@ -232,9 +223,6 @@ namespace System
                }
 
                public MethodBase TargetSite {
-#if ONLY_1_1
-                       [ReflectionPermission (SecurityAction.Demand, TypeInformation = true)]
-#endif
                        get {
                                StackTrace st = new StackTrace (this, true);
                                if (st.FrameCount > 0)
@@ -244,7 +232,6 @@ namespace System
                        }
                }
 
-#if NET_2_0
                public virtual IDictionary Data {
                        get {
                                if (_data == null) {
@@ -254,7 +241,6 @@ namespace System
                                return _data;
                        }
                }
-#endif
 
                public virtual Exception GetBaseException ()
                {
@@ -271,9 +257,6 @@ namespace System
                        return this;
                }
 
-#if ONLY_1_1
-               [ReflectionPermission (SecurityAction.Assert, TypeInformation = true)]
-#endif
                [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
                public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
                {
@@ -288,16 +271,15 @@ namespace System
                        info.AddValue ("RemoteStackTraceString", _remoteStackTraceString);
                        info.AddValue ("RemoteStackIndex", remote_stack_index);
                        info.AddValue ("HResult", hresult);
+#if !MOONLIGHT
                        info.AddValue ("Source", Source);
+#else
+                       info.AddValue ("Source", null);
+#endif
                        info.AddValue ("ExceptionMethod", null);
-#if NET_2_0
                        info.AddValue ("Data", _data, typeof (IDictionary));
-#endif
                }
 
-#if ONLY_1_1
-               [ReflectionPermission (SecurityAction.Assert, TypeInformation = true)]
-#endif
                public override string ToString ()
                {
                        System.Text.StringBuilder result = new System.Text.StringBuilder (ClassName);
@@ -340,7 +322,6 @@ namespace System
                        sb.Append (".");
                        sb.Append (mi.Name);
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                        if (mi.IsGenericMethod) {
                                Type[] gen_params = mi.GetGenericArguments ();
                                sb.Append ("[");
@@ -351,7 +332,7 @@ namespace System
                                }
                                sb.Append ("]");
                        }
-#endif
+
                        sb.Append (" (");
                        for (int i = 0; i < p.Length; ++i) {
                                if (i > 0)
@@ -370,7 +351,6 @@ namespace System
                        sb.Append (")");
                }
 
-#if NET_2_0
                //
                // The documentation states that this is available in 1.x,
                // but it was not available (MemberRefing this would fail)
@@ -381,6 +361,5 @@ namespace System
                {
                        return base.GetType ();
                }
-#endif
        }
 }