Merge pull request #97 from skolima/master
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Exceptions / InvalidProjectFileException.cs
1 //
2 // InvalidProjectFileException.cs
3 //
4 // Author:
5 //   Leszek Ciesielski (skolima@gmail.com)
6 //
7 // (C) 2011 Leszek Ciesielski
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
29 using System;
30 using System.Runtime.Serialization;
31
32 namespace Microsoft.Build.Exceptions
33 {
34         [Serializable]
35         public sealed class InvalidProjectFileException : Exception
36         {
37                 public InvalidProjectFileException ()
38                 {
39                 }
40                 public InvalidProjectFileException (string message) : base(message)
41                 {
42                 }
43                 private InvalidProjectFileException (SerializationInfo info, StreamingContext context)
44                         : base(info, context)
45                 {
46                         ProjectFile = info.GetString ("projectFile");
47                         LineNumber = info.GetInt32 ("lineNumber");
48                         ColumnNumber = info.GetInt32 ("columnNumber");
49                         EndLineNumber = info.GetInt32 ("endLineNumber");
50                         EndColumnNumber = info.GetInt32 ("endColumnNumber");
51                         ErrorSubcategory = info.GetString ("errorSubcategory");
52                         ErrorCode = info.GetString ("errorCode");
53                         HelpKeyword = info.GetString ("helpKeyword");
54                         HasBeenLogged = info.GetBoolean ("hasBeenLogged");
55                 }
56                 public InvalidProjectFileException (string message, Exception innerException)
57                         : base(message, innerException)
58                 {
59                 }
60                 public InvalidProjectFileException (string projectFile, int lineNumber, int columnNumber,
61                                                     int endLineNumber, int endColumnNumber, string message,
62                                                     string errorSubcategory, string errorCode, string helpKeyword)
63                 {
64                 }
65                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
66                 {
67                         base.GetObjectData (info, context);
68                         info.AddValue ("projectFile", ProjectFile);
69                         info.AddValue ("lineNumber", LineNumber);
70                         info.AddValue ("columnNumber", ColumnNumber);
71                         info.AddValue ("endLineNumber", EndLineNumber);
72                         info.AddValue ("endColumnNumber", EndColumnNumber);
73                         info.AddValue ("errorSubcategory", ErrorSubcategory);
74                         info.AddValue ("errorCode", ErrorCode);
75                         info.AddValue ("helpKeyword", HelpKeyword);
76                         info.AddValue ("hasBeenLogged", HasBeenLogged);
77                 }
78                 public string BaseMessage {
79                         get { return base.Message; }
80                 }
81                 public int ColumnNumber { get; private set; }
82                 public int EndColumnNumber { get; private set; }
83                 public int EndLineNumber { get; private set; }
84                 public string ErrorCode { get; private set; }
85                 public string ErrorSubcategory { get; private set; }
86                 public bool HasBeenLogged { get; private set; }
87                 public string HelpKeyword { get; private set; }
88                 public int LineNumber { get; private set; }
89                 public override string Message {
90                         get { return ProjectFile == null ? base.Message : base.Message + " " + ProjectFile; }
91                 }
92                 public string ProjectFile { get; private set; }
93         }
94 }