From: Marek Safar Date: Fri, 15 Apr 2016 15:28:19 +0000 (+0200) Subject: [mcs] Better error message for conflict of types with the same name X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=3aacd09c285e56f6ea7dd4d6692a8a106a997321;p=mono.git [mcs] Better error message for conflict of types with the same name --- diff --git a/mcs/errors/cs0029-26.cs b/mcs/errors/cs0029-26.cs index 723b603c5f2..9fb47abf6d4 100644 --- a/mcs/errors/cs0029-26.cs +++ b/mcs/errors/cs0029-26.cs @@ -1,4 +1,4 @@ -// CS0029: Cannot implicitly convert type `B [cs0029-26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]' to `B [CS0029-26-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3]' +// CS0029: Cannot implicitly convert type `B [cs0029-26, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -- *PATH*/cs0029-26.cs]' to `B [CS0029-26-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3 -- *PATH*/CS0029-26-lib.dll]' // Line: 16 // Compiler options: -r:R1=CS0029-26-lib.dll diff --git a/mcs/mcs/typespec.cs b/mcs/mcs/typespec.cs index 81894f06c76..fb02370dbb3 100644 --- a/mcs/mcs/typespec.cs +++ b/mcs/mcs/typespec.cs @@ -547,7 +547,15 @@ namespace Mono.CSharp public string GetSignatureForErrorIncludingAssemblyName () { - return string.Format ("{0} [{1}]", GetSignatureForError (), MemberDefinition.DeclaringAssembly.FullName); + var imported = MemberDefinition.DeclaringAssembly as ImportedAssemblyDefinition; + + var location = imported != null ? + System.IO.Path.GetFullPath (imported.Location) : + ((MemberCore)MemberDefinition).Location.NameFullPath; + + return string.Format ("{0} [{1} -- {2}]", GetSignatureForError (), + MemberDefinition.DeclaringAssembly.FullName, + location); } protected virtual string GetTypeNameSignature () diff --git a/mcs/tools/compiler-tester/compiler-tester.cs b/mcs/tools/compiler-tester/compiler-tester.cs index beafdfa5557..677403c0492 100644 --- a/mcs/tools/compiler-tester/compiler-tester.cs +++ b/mcs/tools/compiler-tester/compiler-tester.cs @@ -1440,20 +1440,16 @@ namespace TestRunner { static bool TryToMatchErrorMessage (string actual, string expected) { actual = actual.Replace ("\\", "/"); - var path_mask_start = expected.IndexOf ("*PATH*"); + var path_mask_start = expected.IndexOf ("*PATH*", StringComparison.Ordinal); if (path_mask_start > 0 && actual.Length > path_mask_start) { - var path_mask_continue = expected.Substring (path_mask_start + 6); - var expected_continue = actual.IndexOf (path_mask_continue, path_mask_start); - if (expected_continue > 0) { - var path = actual.Substring (path_mask_start, expected_continue - path_mask_start); - if (actual == expected.Replace ("*PATH*", path)) - return true; - - throw new ApplicationException (expected.Replace ("*PATH*", path)); + var parts = expected.Split (new [] { "*PATH*" }, StringSplitOptions.None); + foreach (var part in parts) { + if (!actual.Contains (part)) + return false; } } - return false; + return true; } bool HandleFailure (string file, CompilerError status)