-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathBuildErrorEventArgs.cs
328 lines (294 loc) · 11.7 KB
/
BuildErrorEventArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using Microsoft.Build.Shared;
namespace Microsoft.Build.Framework
{
/// <summary>
/// Arguments for error events
/// </summary>
// WARNING: marking a type [Serializable] without implementing
// ISerializable imposes a serialization contract -- it is a
// promise to never change the type's fields i.e. the type is
// immutable; adding new fields in the next version of the type
// without following certain special FX guidelines, can break both
// forward and backward compatibility
[Serializable]
public class BuildErrorEventArgs : LazyFormattedBuildEventArgs
{
/// <summary>
/// Subcategory of the error
/// </summary>
private string subcategory;
/// <summary>
/// Error code
/// </summary>
private string code;
/// <summary>
/// File name
/// </summary>
private string file;
/// <summary>
/// The project which issued the event
/// </summary>
private string projectFile;
/// <summary>
/// Line number
/// </summary>
private int lineNumber;
/// <summary>
/// Column number
/// </summary>
private int columnNumber;
/// <summary>
/// End line number
/// </summary>
private int endLineNumber;
/// <summary>
/// End column number
/// </summary>
private int endColumnNumber;
/// <summary>
/// A link pointing to more information about the error
/// </summary>
private string helpLink;
/// <summary>
/// This constructor allows all event data to be initialized
/// </summary>
/// <param name="subcategory">event sub-category</param>
/// <param name="code">event code</param>
/// <param name="file">file associated with the event</param>
/// <param name="lineNumber">line number (0 if not applicable)</param>
/// <param name="columnNumber">column number (0 if not applicable)</param>
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
/// <param name="message">text message</param>
/// <param name="helpKeyword">help keyword </param>
/// <param name="senderName">name of event sender</param>
public BuildErrorEventArgs
(
string subcategory,
string code,
string file,
int lineNumber,
int columnNumber,
int endLineNumber,
int endColumnNumber,
string message,
string helpKeyword,
string senderName
)
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, DateTime.UtcNow)
{
}
/// <summary>
/// This constructor which allows a timestamp to be set
/// </summary>
/// <param name="subcategory">event sub-category</param>
/// <param name="code">event code</param>
/// <param name="file">file associated with the event</param>
/// <param name="lineNumber">line number (0 if not applicable)</param>
/// <param name="columnNumber">column number (0 if not applicable)</param>
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
/// <param name="message">text message</param>
/// <param name="helpKeyword">help keyword </param>
/// <param name="senderName">name of event sender</param>
/// <param name="eventTimestamp">Timestamp when event was created</param>
public BuildErrorEventArgs
(
string subcategory,
string code,
string file,
int lineNumber,
int columnNumber,
int endLineNumber,
int endColumnNumber,
string message,
string helpKeyword,
string senderName,
DateTime eventTimestamp
)
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, null, eventTimestamp, null)
{
// do nothing
}
/// <summary>
/// This constructor which allows a timestamp to be set
/// </summary>
/// <param name="subcategory">event sub-category</param>
/// <param name="code">event code</param>
/// <param name="file">file associated with the event</param>
/// <param name="lineNumber">line number (0 if not applicable)</param>
/// <param name="columnNumber">column number (0 if not applicable)</param>
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
/// <param name="message">text message</param>
/// <param name="helpKeyword">help keyword </param>
/// <param name="senderName">name of event sender</param>
/// <param name="eventTimestamp">Timestamp when event was created</param>
/// <param name="messageArgs">message arguments</param>
public BuildErrorEventArgs
(
string subcategory,
string code,
string file,
int lineNumber,
int columnNumber,
int endLineNumber,
int endColumnNumber,
string message,
string helpKeyword,
string senderName,
DateTime eventTimestamp,
params object[] messageArgs
)
: this(subcategory, code, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message, helpKeyword, senderName, null, eventTimestamp, messageArgs)
{
// do nothing
}
/// <summary>
/// This constructor which allows a timestamp to be set
/// </summary>
/// <param name="subcategory">event sub-category</param>
/// <param name="code">event code</param>
/// <param name="file">file associated with the event</param>
/// <param name="lineNumber">line number (0 if not applicable)</param>
/// <param name="columnNumber">column number (0 if not applicable)</param>
/// <param name="endLineNumber">end line number (0 if not applicable)</param>
/// <param name="endColumnNumber">end column number (0 if not applicable)</param>
/// <param name="message">text message</param>
/// <param name="helpKeyword">help keyword </param>
/// <param name="helpLink">A link pointing to more information about the error </param>
/// <param name="senderName">name of event sender</param>
/// <param name="eventTimestamp">Timestamp when event was created</param>
/// <param name="messageArgs">message arguments</param>
public BuildErrorEventArgs
(
string subcategory,
string code,
string file,
int lineNumber,
int columnNumber,
int endLineNumber,
int endColumnNumber,
string message,
string helpKeyword,
string senderName,
string helpLink,
DateTime eventTimestamp,
params object[] messageArgs
)
: base(message, helpKeyword, senderName, eventTimestamp, messageArgs)
{
this.subcategory = subcategory;
this.code = code;
this.file = file;
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
this.endLineNumber = endLineNumber;
this.endColumnNumber = endColumnNumber;
this.helpLink = helpLink;
}
/// <summary>
/// Default constructor
/// </summary>
protected BuildErrorEventArgs()
: base()
{
// do nothing
}
/// <summary>
/// The custom sub-type of the event.
/// </summary>
public string Subcategory => subcategory;
/// <summary>
/// Code associated with event.
/// </summary>
public string Code => code;
/// <summary>
/// File associated with event.
/// </summary>
public string File => file;
/// <summary>
/// The project file which issued this event.
/// </summary>
public string ProjectFile
{
get => projectFile;
set => projectFile = value;
}
/// <summary>
/// Line number of interest in associated file.
/// </summary>
public int LineNumber => lineNumber;
/// <summary>
/// Column number of interest in associated file.
/// </summary>
public int ColumnNumber => columnNumber;
/// <summary>
/// Ending line number of interest in associated file.
/// </summary>
public int EndLineNumber => endLineNumber;
/// <summary>
/// Ending column number of interest in associated file.
/// </summary>
public int EndColumnNumber => endColumnNumber;
/// <summary>
/// A link pointing to more information about the error.
/// </summary>
public string HelpLink => helpLink;
#region CustomSerializationToStream
/// <summary>
/// Serializes to a stream through a binary writer
/// </summary>
/// <param name="writer">Binary writer which is attached to the stream the event will be serialized into</param>
internal override void WriteToStream(BinaryWriter writer)
{
base.WriteToStream(writer);
writer.WriteOptionalString(subcategory);
writer.WriteOptionalString(code);
writer.WriteOptionalString(file);
writer.WriteOptionalString(projectFile);
writer.Write((Int32)lineNumber);
writer.Write((Int32)columnNumber);
writer.Write((Int32)endLineNumber);
writer.Write((Int32)endColumnNumber);
writer.WriteOptionalString(helpLink);
}
/// <summary>
/// Deserializes to a stream through a binary writer
/// </summary>
/// <param name="reader">Binary reader which the object will be deserialized from</param>
/// <param name="version">The version of the runtime the message packet was created from</param>
internal override void CreateFromStream(BinaryReader reader, int version)
{
base.CreateFromStream(reader, version);
subcategory = reader.ReadByte() == 0 ? null : reader.ReadString();
code = reader.ReadByte() == 0 ? null : reader.ReadString();
file = reader.ReadByte() == 0 ? null : reader.ReadString();
if (version > 20)
{
projectFile = reader.ReadByte() == 0 ? null : reader.ReadString();
}
else
{
projectFile = null;
}
lineNumber = reader.ReadInt32();
columnNumber = reader.ReadInt32();
endLineNumber = reader.ReadInt32();
endColumnNumber = reader.ReadInt32();
if (version >= 40)
{
helpLink = reader.ReadByte() == 0 ? null : reader.ReadString();
}
else
{
helpLink = null;
}
}
#endregion
}
}