forked from dotnet/java-interop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReport.cs
83 lines (73 loc) · 2.78 KB
/
Report.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
using System;
using System.Linq;
namespace MonoDroid.Generation
{
public class Report
{
public const int ErrorEnumMap = 0x4000;
public const int ErrorEnumMapping = 0x4100;
public const int ErrorParser = 0x4200;
public const int ErrorApiFixup = 0x4300;
public const int ErrorCodeGenerator = 0x4400;
public const int WarningClassGen = 0x8100;
public const int WarningCodeGenerator = 0x8200;
public const int WarningCtor = 0x8300;
public const int WarningField = 0x8400;
public const int WarningFieldNameCollision = 0x8401;
public const int WarningDuplicateField = 0x8402;
public const int WarningInterfaceGen = 0x8500;
public const int WarningParser = 0x8600;
public const int WarningReturnValue = 0x8700;
public const int WarningParameter = 0x8800;
public const int WarningGenBaseSupport = 0x8900;
public const int WarningApiFixup = 0x8A00;
public const int WarningGenericParameterDefinition = 0x8B00;
public const int WarningGenBase = 0x8C00;
public const int WarningMethodBase = 0x8D00;
public const int WarningAnnotationsProvider = 0x8E00;
public static int? Verbosity { get; set; }
public static void Error (int errorCode, string format, params object[] args)
{
Error (errorCode, null, format, args);
}
public static void Error (int errorCode, Exception innerException, string format, params object[] args)
{
throw new BindingGeneratorException (errorCode, string.Format (format, args), innerException);
}
public static void Warning (int verbosity, int errorCode, string format, params object[] args)
{
Warning (verbosity, errorCode, null, format, args);
}
public static void Warning (int verbosity, int errorCode, Exception innerException, string format, params object[] args)
{
if (verbosity > (Verbosity ?? 0))
return;
string supp = innerException != null ? " For details, see verbose output." : null;
Console.Error.WriteLine (Format (false, errorCode, format, args) + supp);
if (innerException != null)
Console.Error.WriteLine (innerException);
}
public static void Verbose (int verbosity, string format, params object[] args)
{
if (verbosity > (Verbosity ?? 0))
return;
Console.Error.WriteLine (format, args);
}
public static string Format (bool error, int errorCode, string format, params object[] args)
{
return string.Format ("{0}{1} BG{2:X04}: ", "" /* origin? */, error ? "error" : "warning", errorCode) +
string.Format (format, args);
}
}
public class BindingGeneratorException : Exception
{
public BindingGeneratorException (int errorCode, string message)
: this (errorCode, message, null)
{
}
public BindingGeneratorException (int errorCode, string message, Exception innerException)
: base (Report.Format (true, errorCode, message), innerException)
{
}
}
}