msbuild: test fixes. Implemented GlobalEngine and project unloading
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / InvalidProjectFileException.cs
1 //
2 // InvalidProjectFileException.cs:
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 // 
7 // (C) 2005 Marek Sieradzki
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
27
28 #if NET_2_0
29
30 using System;
31 using System.Runtime.Serialization;
32 using System.Xml;
33
34 namespace Microsoft.Build.BuildEngine {
35         [Serializable]
36         public sealed class InvalidProjectFileException : Exception {
37                 
38                 int     columnNumber;
39                 int     endColumnNumber;
40                 string  errorCode;
41                 string  errorSubcategory;
42                 string  helpKeyword;
43                 int     lineNumber;
44                 int     endLineNumber;
45                 string  projectFile;
46                 
47                 public InvalidProjectFileException ()
48                         : base ("Invalid project file exception has occured")
49                 {
50                 }
51
52                 public InvalidProjectFileException (string message)
53                         : base (message)
54                 {
55                 }
56
57                 public InvalidProjectFileException (string projectFile,
58                                                     int lineNumber,
59                                                     int columnNumber,
60                                                     int endLineNumber,
61                                                     int endColumnNumber,
62                                                     string message,
63                                                     string errorSubcategory,
64                                                     string errorCode,
65                                                     string helpKeyword)
66                         : base (message)
67                 {
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;
76                 }
77
78                 public InvalidProjectFileException (string message,
79                                                     Exception innerException)
80                         : base (message, innerException)
81                 {
82                 }
83
84                 // FIXME: set line/column numbers?
85                 [MonoTODO]
86                 public InvalidProjectFileException (XmlNode xmlNode,
87                                                     string message,
88                                                     string errorSubcategory,
89                                                     string errorCode,
90                                                     string helpKeyword)
91                         : base (message)
92                 {
93                         this.errorSubcategory = errorSubcategory;
94                         this.errorCode = errorCode;
95                         this.helpKeyword = helpKeyword;
96                 }
97
98                 protected InvalidProjectFileException (SerializationInfo info, StreamingContext context)
99                         : base (info, context)
100                 {
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");
109                 }
110
111                 public override void GetObjectData (SerializationInfo info,
112                                                     StreamingContext context)
113                 {
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);
123                 }
124
125                 public string BaseMessage {
126                         get {
127                                 return base.Message;
128                         }
129                 }
130
131                 public int ColumnNumber {
132                         get {
133                                 return columnNumber;
134                         }
135                 }
136
137                 public int EndColumnNumber {
138                         get {
139                                 return endColumnNumber;
140                         }
141                 }
142
143                 public int EndLineNumber {
144                         get {
145                                 return endLineNumber;
146                         }
147                 }
148
149                 public string ErrorCode {
150                         get {
151                                 return errorCode;
152                         }
153                 }
154
155                 public string ErrorSubcategory {
156                         get {
157                                 return errorSubcategory;
158                         }
159                 }
160
161                 public string HelpKeyword {
162                         get {
163                                 return helpKeyword;
164                         }
165                 }
166
167                 public int LineNumber {
168                         get {
169                                 return lineNumber;
170                         }
171                 }
172
173                 public override string Message {
174                         get {
175                                 if (projectFile == null || projectFile == "") {
176                                         return BaseMessage;
177                                 } else {
178                                         return BaseMessage + "  " + ProjectFile;
179                                 }
180                         }
181                 }
182
183                 public string ProjectFile {
184                         get {
185                                 return projectFile;
186                         }
187                 }
188         }
189 }
190
191 #endif