Merge pull request #4540 from kumpera/android-changes-part1
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Construction / ProjectElement.cs
index 98362830806fdb6dbe8f42efa333268a3083fc5e..ef1b404ed8eebe4516af01d84cb0d211f3a44e59 100644 (file)
@@ -88,7 +88,7 @@ namespace Microsoft.Build.Construction
                                 Condition = value;
                                 break;
                         default:
-                                throw new InvalidProjectFileException (string.Format (
+                                throw new InvalidProjectFileException (Location, null, string.Format (
                                         "Attribute \"{0}\" is not known on node \"{1}\" [type {2}].", name, XmlName,
                                         GetType ()));
                         }
@@ -114,24 +114,25 @@ namespace Microsoft.Build.Construction
                                 writer.WriteAttributeString (attributeName, attributeValue);
                 }
                 
-#if NET_4_5
                 public ElementLocation Location { get; private set; }
                 public ElementLocation LabelLocation { get; private set; }
                 public ElementLocation ConditionLocation { get; private set; }
-#endif
-                
+                string GetFilePath (string baseURI)
+                {
+                        return string.IsNullOrEmpty (baseURI) ? string.Empty : new Uri (baseURI).LocalPath;
+                }
+
                 internal void FillLocation (XmlReader reader)
                 {
-#if NET_4_5
                         var l = reader as IXmlLineInfo;
+                        var path = GetFilePath (reader.BaseURI);
                         if (l != null && l.HasLineInfo ())
-                                Location = new ProjectElementLocation (reader.BaseURI, l);
+                                Location = new ProjectElementLocation (path, l);
                         if (reader.MoveToAttribute ("Condition") && l.HasLineInfo ())
-                                ConditionLocation = new ProjectElementLocation (reader.BaseURI, l);
+                                ConditionLocation = new ProjectElementLocation (path, l);
                         if (reader.MoveToAttribute ("Label") && l.HasLineInfo ())
-                                LabelLocation = new ProjectElementLocation (reader.BaseURI, l);
+                                LabelLocation = new ProjectElementLocation (path, l);
                         reader.MoveToElement ();
-#endif
                 }
                 
                 class ProjectElementLocation : ElementLocation