/// <summary>
/// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
/// </summary>
- static StringCollection related_symbols = new StringCollection ();
+ static StringCollection extra_information = new StringCollection ();
abstract class AbstractMessage {
}
}
+ public abstract bool IsWarning { get; }
+
public abstract string MessageType { get; }
public virtual void Print (int code, string location, string text)
msg.Append (' ');
}
msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text);
- Console.WriteLine (msg.ToString ());
+ Console.Error.WriteLine (msg.ToString ());
- foreach (string s in related_symbols) {
- Console.WriteLine (String.Concat (s, MessageType, ')'));
- }
- related_symbols.Clear ();
+ foreach (string s in extra_information)
+ Console.Error.WriteLine (s + MessageType);
+
+ extra_information.Clear ();
if (Stacktrace)
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
- if (Fatal)
- throw new Exception (text);
+ if (Fatal) {
+ if (!IsWarning || WarningsAreErrors)
+ throw new Exception (text);
+ }
Check (code);
}
Level = level;
}
+ public override bool IsWarning {
+ get { return true; }
+ }
+
bool IsEnabled (int code)
{
if (RootContext.WarningLevel < Level)
public override void Print(int code, string location, string text)
{
if (!IsEnabled (code)) {
- related_symbols.Clear ();
+ extra_information.Clear ();
return;
}
base.Print (code, location, text);
}
+ public override bool IsWarning {
+ get { return false; }
+ }
+
public override string MessageType {
get {
return "error";
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// IF YOU ADD A NEW WARNING YOU HAVE TO DUPLICATE ITS ID HERE
+ //
public static bool IsValidWarning (int code)
{
- int[] all_warnings = new int[] { 28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
- 659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
- };
+ int[] all_warnings = new int[] {
+ 28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
+ 659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
+ };
+
foreach (int i in all_warnings) {
if (i == code)
return true;
static public void LocationOfPreviousError (Location loc)
{
- Console.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
+ Console.Error.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
}
- static public void RuntimeMissingSupport (string feature)
+ static public void RuntimeMissingSupport (Location loc, string feature)
{
- Report.Error (-88, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.");
+ Report.Error (-88, loc, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
}
/// <summary>
static void SymbolRelatedToPreviousError (string loc, string symbol)
{
- related_symbols.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
+ extra_information.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
+ }
+
+ public static void ExtraInformation (Location loc, string msg)
+ {
+ extra_information.Add (String.Format ("{0}({1}) {2}", loc.Name, loc.Row, msg));
}
public static WarningRegions RegisterWarningRegion (Location location)