2 // InvalidProjectFileException.cs:
5 // Marek Sieradzki (marek.sieradzki@gmail.com)
7 // (C) 2005 Marek Sieradzki
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Runtime.Serialization;
34 namespace Microsoft.Build.BuildEngine {
36 public sealed class InvalidProjectFileException : Exception {
41 string errorSubcategory;
47 public InvalidProjectFileException ()
48 : base ("Invalid project file exception has occured")
52 public InvalidProjectFileException (string message)
57 public InvalidProjectFileException (string projectFile,
63 string errorSubcategory,
68 this.projectFile = projectFile;
69 this.lineNumber = lineNumber;
70 this.columnNumber = columnNumber;
71 this.endLineNumber = endLineNumber;
72 this.endColumnNumber = endColumnNumber;
73 this.errorSubcategory = errorSubcategory;
74 this.errorCode = errorCode;
75 this.helpKeyword = helpKeyword;
78 public InvalidProjectFileException (string message,
79 Exception innerException)
80 : base (message, innerException)
84 // FIXME: set line/column numbers?
86 public InvalidProjectFileException (XmlNode xmlNode,
88 string errorSubcategory,
93 this.errorSubcategory = errorSubcategory;
94 this.errorCode = errorCode;
95 this.helpKeyword = helpKeyword;
98 protected InvalidProjectFileException (SerializationInfo info, StreamingContext context)
99 : base (info, context)
101 this.columnNumber = info.GetInt32 ("ColumnNumber");
102 this.endColumnNumber = info.GetInt32 ("EndColumnNumber");
103 this.errorCode = info.GetString ("ErrorCode");
104 this.errorSubcategory = info.GetString ("ErrorSubcategory");
105 this.helpKeyword = info.GetString ("HelpKeyword");
106 this.lineNumber = info.GetInt32 ("LineNumber");
107 this.endLineNumber = info.GetInt32 ("EndLineNumber");
108 this.projectFile = info.GetString ("ProjectFile");
111 public override void GetObjectData (SerializationInfo info,
112 StreamingContext context)
114 base.GetObjectData (info, context);
115 info.AddValue ("ColumnNumber", columnNumber);
116 info.AddValue ("EndColumnNumber", endColumnNumber);
117 info.AddValue ("ErrorCode", errorCode);
118 info.AddValue ("ErrorSubcategory", errorSubcategory);
119 info.AddValue ("HelpKeyword", helpKeyword);
120 info.AddValue ("LineNumber", lineNumber);
121 info.AddValue ("EndLineNumber", endLineNumber);
122 info.AddValue ("ProjectFile", projectFile);
125 public string BaseMessage {
131 public int ColumnNumber {
137 public int EndColumnNumber {
139 return endColumnNumber;
143 public int EndLineNumber {
145 return endLineNumber;
149 public string ErrorCode {
155 public string ErrorSubcategory {
157 return errorSubcategory;
161 public string HelpKeyword {
167 public int LineNumber {
173 public override string Message {
175 if (projectFile == null || projectFile == "") {
178 return BaseMessage + " " + ProjectFile;
183 public string ProjectFile {