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?
86
public InvalidProjectFileException (XmlNode xmlNode,
88
string errorSubcategory,
93
this.errorSubcategory = errorSubcategory;
94
this.errorCode = errorCode;
95
this.helpKeyword = helpKeyword;
98
// FIXME: private temporarily
99
private InvalidProjectFileException (SerializationInfo info, StreamingContext context)
100
: base (info, context)
102
this.columnNumber = info.GetInt32 ("columnNumber");
103
this.endColumnNumber = info.GetInt32 ("endColumnNumber");
104
this.errorCode = info.GetString ("errorCode");
105
this.errorSubcategory = info.GetString ("errorSubcategory");
106
this.helpKeyword = info.GetString ("helpKeyword");
107
this.lineNumber = info.GetInt32 ("lineNumber");
108
this.endLineNumber = info.GetInt32 ("endLineNumber");
109
this.projectFile = info.GetString ("projectFile");
112
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
113
public override void GetObjectData (SerializationInfo info,
114
StreamingContext context)
116
base.GetObjectData (info, context);
117
info.AddValue ("columnNumber", columnNumber);
118
info.AddValue ("endColumnNumber", endColumnNumber);
119
info.AddValue ("errorCode", errorCode);
120
info.AddValue ("errorSubcategory", errorSubcategory);
121
info.AddValue ("helpKeyword", helpKeyword);
122
info.AddValue ("lineNumber", lineNumber);
123
info.AddValue ("endLineNumber", endLineNumber);
124
info.AddValue ("projectFile", projectFile);
127
public string BaseMessage {
133
public int ColumnNumber {
139
public int EndColumnNumber {
141
return endColumnNumber;
145
public int EndLineNumber {
147
return endLineNumber;
151
public string ErrorCode {
157
public string ErrorSubcategory {
159
return errorSubcategory;
163
public string HelpKeyword {
169
public int LineNumber {
175
public override string Message {
177
if (projectFile == null || projectFile == String.Empty) {
180
return BaseMessage + " " + ProjectFile;
185
public string ProjectFile {