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;
32 using System.Security.Permissions;
35 namespace Microsoft.Build.BuildEngine {
37 public sealed class InvalidProjectFileException : Exception {
42 string errorSubcategory;
48 public InvalidProjectFileException ()
49 : base ("Invalid project file exception has occured")
53 public InvalidProjectFileException (string message)
58 public InvalidProjectFileException (string projectFile,
64 string errorSubcategory,
69 this.projectFile = projectFile;
70 this.lineNumber = lineNumber;
71 this.columnNumber = columnNumber;
72 this.endLineNumber = endLineNumber;
73 this.endColumnNumber = endColumnNumber;
74 this.errorSubcategory = errorSubcategory;
75 this.errorCode = errorCode;
76 this.helpKeyword = helpKeyword;
79 public InvalidProjectFileException (string message,
80 Exception innerException)
81 : base (message, innerException)
85 // FIXME: set line/column numbers?
87 public InvalidProjectFileException (XmlNode xmlNode,
89 string errorSubcategory,
94 this.errorSubcategory = errorSubcategory;
95 this.errorCode = errorCode;
96 this.helpKeyword = helpKeyword;
99 // FIXME: private temporarily
100 private InvalidProjectFileException (SerializationInfo info, StreamingContext context)
101 : base (info, context)
103 this.columnNumber = info.GetInt32 ("columnNumber");
104 this.endColumnNumber = info.GetInt32 ("endColumnNumber");
105 this.errorCode = info.GetString ("errorCode");
106 this.errorSubcategory = info.GetString ("errorSubcategory");
107 this.helpKeyword = info.GetString ("helpKeyword");
108 this.lineNumber = info.GetInt32 ("lineNumber");
109 this.endLineNumber = info.GetInt32 ("endLineNumber");
110 this.projectFile = info.GetString ("projectFile");
113 [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
114 public override void GetObjectData (SerializationInfo info,
115 StreamingContext context)
117 base.GetObjectData (info, context);
118 info.AddValue ("columnNumber", columnNumber);
119 info.AddValue ("endColumnNumber", endColumnNumber);
120 info.AddValue ("errorCode", errorCode);
121 info.AddValue ("errorSubcategory", errorSubcategory);
122 info.AddValue ("helpKeyword", helpKeyword);
123 info.AddValue ("lineNumber", lineNumber);
124 info.AddValue ("endLineNumber", endLineNumber);
125 info.AddValue ("projectFile", projectFile);
128 public string BaseMessage {
134 public int ColumnNumber {
140 public int EndColumnNumber {
142 return endColumnNumber;
146 public int EndLineNumber {
148 return endLineNumber;
152 public string ErrorCode {
158 public string ErrorSubcategory {
160 return errorSubcategory;
164 public string HelpKeyword {
170 public int LineNumber {
176 public override string Message {
178 if (projectFile == null || projectFile == String.Empty) {
181 return BaseMessage + " " + ProjectFile;
186 public string ProjectFile {