[mcs] Better error message for conflict of types with the same name
authorMarek Safar <marek.safar@gmail.com>
Fri, 15 Apr 2016 15:28:19 +0000 (17:28 +0200)
committerMarek Safar <marek.safar@gmail.com>
Fri, 15 Apr 2016 15:29:14 +0000 (17:29 +0200)
mcs/errors/cs0029-26.cs
mcs/mcs/typespec.cs
mcs/tools/compiler-tester/compiler-tester.cs

index 723b603c5f26ed85bd85dcfc73f9826ccc440817..9fb47abf6d486d9ba4d78811a9d0e68f420f3d13 100644 (file)
@@ -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
 
index 81894f06c762ea1d6146e2e9d99905b2d3a7f4e1..fb02370dbb32cd2317827d323637b370d01e0048 100644 (file)
@@ -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 ()
index beafdfa555778472afda9b56e0d11d2fd3d52845..677403c049258a084fb8bfca2ebcbee87201c0cb 100644 (file)
@@ -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)