Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorRodrigo Kumpera <kumpera@gmail.com>2017-11-15 01:41:08 +0300
committerMarek Safar <marek.safar@gmail.com>2017-11-15 11:31:21 +0300
commit115b29014394c9548e743f8580c3d96466dc1cf8 (patch)
treeca434abb59ab2df453328a680fec1351fee8d23c /mcs
parent43a23e71e5d1862e1dedf641574b9ac8ce2e9aac (diff)
[runtime/corlib] Improve MissingMethodExceptions by including messageā€¦ and signature. Fixes #60505
This fix is a bit weird but it's due to some restrictions of the managed API. MissingMemberException & friends require both ClassName and MemberName to be supplied independently, so the signature can't simply be applied to MemberName. So we pass it on a separate field. The next thing is that we want C#'esque signatures, where the return type comes before ClassName.MemberName, so we pass a format string and apply it in managed.
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/corlib/LinkerDescriptor/mscorlib.xml2
-rw-r--r--mcs/class/referencesource/mscorlib/system/missingmethodexception.cs21
2 files changed, 23 insertions, 0 deletions
diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml
index 68786da22a0..4d36758a43c 100644
--- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml
+++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml
@@ -250,6 +250,8 @@
<method signature="System.Void .ctor(System.String)" />
<!-- exception.c (mono_get_exception_type_load) mono_exception_from_name_two_strings -->
<method signature="System.Void .ctor(System.String,System.String)" />
+ <!-- exception.c mono_exception_from_name_four_strings -->
+ <method signature="System.Void .ctor(System.String,System.String,System.String,System.String)" />
</type>
<!-- threadpool.c: mono_thread_pool_init (assert) -->
diff --git a/mcs/class/referencesource/mscorlib/system/missingmethodexception.cs b/mcs/class/referencesource/mscorlib/system/missingmethodexception.cs
index bbc2521b853..abea8212eda 100644
--- a/mcs/class/referencesource/mscorlib/system/missingmethodexception.cs
+++ b/mcs/class/referencesource/mscorlib/system/missingmethodexception.cs
@@ -48,10 +48,19 @@ namespace System {
if (ClassName == null) {
return base.Message;
} else {
+#if MONO
+ string res = ClassName + "." + MemberName;
+ if (!string.IsNullOrEmpty(signature))
+ res = string.Format (CultureInfo.InvariantCulture, signature, res);
+ if (!string.IsNullOrEmpty(_message))
+ res += " Due to: " + _message;
+ return res;
+#else
// do any desired fixups to classname here.
return Environment.GetResourceString("MissingMethod_Name",
ClassName + "." + MemberName +
(Signature != null ? " " + FormatSignature(Signature) : ""));
+#endif
}
}
}
@@ -73,5 +82,17 @@ namespace System {
// If ClassName != null, Message will construct on the fly using it
// and the other variables. This allows customization of the
// format depending on the language environment.
+#if MONO
+ // Called from the EE
+ private MissingMethodException(String className, String methodName, String signature, String message) : base (message)
+ {
+ ClassName = className;
+ MemberName = methodName;
+ this.signature = signature;
+ }
+
+ [NonSerialized]
+ string signature;
+#endif
}
}