Merge remote-tracking branch 'joncham/sgen-msvc2'
[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 using System;
29 using System.Runtime.Serialization;
30 using System.Security.Permissions;
31 using System.Xml;
32
33 namespace Microsoft.Build.BuildEngine {
34         [Serializable]
35         public sealed class InvalidProjectFileException : Exception {
36                 
37                 int     columnNumber;
38                 int     endColumnNumber;
39                 string  errorCode;
40                 string  errorSubcategory;
41                 string  helpKeyword;
42                 int     lineNumber;
43                 int     endLineNumber;
44                 string  projectFile;
45                 
46                 public InvalidProjectFileException ()
47                         : base ("Invalid project file exception has occured")
48                 {
49                 }
50
51                 public InvalidProjectFileException (string message)
52                         : base (message)
53                 {
54                 }
55
56                 public InvalidProjectFileException (string projectFile,
57                                                     int lineNumber,
58                                                     int columnNumber,
59                                                     int endLineNumber,
60                                                     int endColumnNumber,
61                                                     string message,
62                                                     string errorSubcategory,
63                                                     string errorCode,
64                                                     string helpKeyword)
65                         : base (message)
66                 {
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;
75                 }
76
77                 public InvalidProjectFileException (string message,
78                                                     Exception innerException)
79                         : base (message, innerException)
80                 {
81                 }
82
83                 // FIXME: set line/column numbers?
84                 [MonoTODO]
85                 public InvalidProjectFileException (XmlNode xmlNode,
86                                                     string message,
87                                                     string errorSubcategory,
88                                                     string errorCode,
89                                                     string helpKeyword)
90                         : base (message)
91                 {
92                         this.errorSubcategory = errorSubcategory;
93                         this.errorCode = errorCode;
94                         this.helpKeyword = helpKeyword;
95                 }
96
97                 // FIXME: private temporarily
98                 private 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                 [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
112                 public override void GetObjectData (SerializationInfo info,
113                                                     StreamingContext context)
114                 {
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);
124                 }
125
126                 public string BaseMessage {
127                         get {
128                                 return base.Message;
129                         }
130                 }
131
132                 public int ColumnNumber {
133                         get {
134                                 return columnNumber;
135                         }
136                 }
137
138                 public int EndColumnNumber {
139                         get {
140                                 return endColumnNumber;
141                         }
142                 }
143
144                 public int EndLineNumber {
145                         get {
146                                 return endLineNumber;
147                         }
148                 }
149
150                 public string ErrorCode {
151                         get {
152                                 return errorCode;
153                         }
154                 }
155
156                 public string ErrorSubcategory {
157                         get {
158                                 return errorSubcategory;
159                         }
160                 }
161
162                 public string HelpKeyword {
163                         get {
164                                 return helpKeyword;
165                         }
166                 }
167
168                 public int LineNumber {
169                         get {
170                                 return lineNumber;
171                         }
172                 }
173
174                 public override string Message {
175                         get {
176                                 if (projectFile == null || projectFile == String.Empty) {
177                                         return BaseMessage;
178                                 } else {
179                                         return BaseMessage + "  " + ProjectFile;
180                                 }
181                         }
182                 }
183
184                 public string ProjectFile {
185                         get {
186                                 return projectFile;
187                         }
188                 }
189         }
190 }