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.
29 using System.Runtime.Serialization;
30 using System.Security.Permissions;
33 namespace Microsoft.Build.BuildEngine {
35 public sealed class InvalidProjectFileException : Exception {
40 string errorSubcategory;
46 public InvalidProjectFileException ()
47 : base ("Invalid project file exception has occured")
51 public InvalidProjectFileException (string message)
56 public InvalidProjectFileException (string projectFile,
62 string errorSubcategory,
67 this.projectFile = projectFile;
68 this.lineNumber = lineNumber;
69 this.columnNumber = columnNumber;
70 this.endLineNumber = endLineNumber;
71 this.endColumnNumber = endColumnNumber;
72 this.errorSubcategory = errorSubcategory;
73 this.errorCode = errorCode;
74 this.helpKeyword = helpKeyword;
77 public InvalidProjectFileException (string message,
78 Exception innerException)
79 : base (message, innerException)
83 // FIXME: set line/column numbers?
85 public InvalidProjectFileException (XmlNode xmlNode,
87 string errorSubcategory,
92 this.errorSubcategory = errorSubcategory;
93 this.errorCode = errorCode;
94 this.helpKeyword = helpKeyword;
97 // FIXME: private temporarily
98 private 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 [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
112 public override void GetObjectData (SerializationInfo info,
113 StreamingContext context)
115 base.GetObjectData (info, context);
116 info.AddValue ("columnNumber", columnNumber);
117 info.AddValue ("endColumnNumber", endColumnNumber);
118 info.AddValue ("errorCode", errorCode);
119 info.AddValue ("errorSubcategory", errorSubcategory);
120 info.AddValue ("helpKeyword", helpKeyword);
121 info.AddValue ("lineNumber", lineNumber);
122 info.AddValue ("endLineNumber", endLineNumber);
123 info.AddValue ("projectFile", projectFile);
126 public string BaseMessage {
132 public int ColumnNumber {
138 public int EndColumnNumber {
140 return endColumnNumber;
144 public int EndLineNumber {
146 return endLineNumber;
150 public string ErrorCode {
156 public string ErrorSubcategory {
158 return errorSubcategory;
162 public string HelpKeyword {
168 public int LineNumber {
174 public override string Message {
176 if (projectFile == null || projectFile == String.Empty) {
179 return BaseMessage + " " + ProjectFile;
184 public string ProjectFile {