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
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/class/referencesource
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/class/referencesource')
-rw-r--r--mcs/class/referencesource/mscorlib/system/missingmethodexception.cs21
1 files changed, 21 insertions, 0 deletions
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
}
}