809, 824,
1030, 1058, 1060, 1066,
1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 1587, 1589, 1590, 1591, 1592,
- 1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1699,
+ 1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1697, 1699,
1700, 1701, 1702, 1709, 1711, 1717, 1718, 1720, 1735,
1901, 1956, 1981, 1998,
2002, 2023, 2029,
3000, 3001, 3002, 3003, 3005, 3006, 3007, 3008, 3009,
3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019,
- 3021, 3022, 3023, 3024, 3026, 3027
+ 3021, 3022, 3023, 3024, 3026, 3027,
+ 4014
};
static HashSet<int> AllWarningsHashSet;
extra_information.Add (msg);
}
- public bool CheckWarningCode (string code, Location loc)
- {
- Warning (1691, 1, loc, "`{0}' is not a valid warning number", code);
- return false;
- }
-
public bool CheckWarningCode (int code, Location loc)
{
if (AllWarningsHashSet == null)
if (AllWarningsHashSet.Contains (code))
return true;
- return CheckWarningCode (code.ToString (), loc);
+ Warning (1691, 1, loc, "`{0}' is not a valid warning number", code);
+ return false;
}
public void ExtraInformation (Location loc, string msg)
}
extra_information.Clear ();
- printer.Print (msg);
+ printer.Print (msg, settings.ShowFullPaths);
}
public void Warning (int code, int level, Location loc, string format, string arg)
ErrorMessage msg = new ErrorMessage (code, loc, error, extra_information);
extra_information.Clear ();
- printer.Print (msg);
+ printer.Print (msg, settings.ShowFullPaths);
+
+ if (settings.Stacktrace)
+ Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
+
+ if (printer.ErrorsCount == settings.FatalCounter)
+ throw new FatalException (msg.Text);
}
public void Error (int code, Location loc, string format, string arg)
sb.Append (")");
return sb.ToString ();
}
-*/
+*/
+ static string FriendlyStackTrace (StackTrace t)
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ bool foundUserCode = false;
+
+ for (int i = 0; i < t.FrameCount; i++) {
+ StackFrame f = t.GetFrame (i);
+ var mb = f.GetMethod ();
+
+ if (!foundUserCode && mb.ReflectedType == typeof (Report))
+ continue;
+
+ foundUserCode = true;
+
+ sb.Append ("\tin ");
+
+ if (f.GetFileLineNumber () > 0)
+ sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ());
+
+ sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name);
+
+ bool first = true;
+ foreach (var pi in mb.GetParameters ()) {
+ if (!first)
+ sb.Append (", ");
+ first = false;
+
+ sb.Append (pi.ParameterType.FullName);
+ }
+ sb.Append (")\n");
+ }
+
+ return sb.ToString ();
+ }
}
public abstract class AbstractMessage
//
public abstract class ReportPrinter
{
- #region Properties
+ protected HashSet<ITypeDefinition> reported_missing_definitions;
- public int FatalCounter { get; set; }
+ #region Properties
public int ErrorsCount { get; protected set; }
-
- public bool ShowFullPaths { get; set; }
-
- //
- // Whether to dump a stack trace on errors.
- //
- public bool Stacktrace { get; set; }
-
+
public int WarningsCount { get; private set; }
//
return txt;
}
- public virtual void Print (AbstractMessage msg)
+ public virtual void Print (AbstractMessage msg, bool showFullPath)
{
if (msg.IsWarning) {
++WarningsCount;
} else {
++ErrorsCount;
-
- if (ErrorsCount == FatalCounter)
- throw new Exception (msg.Text);
}
}
- protected void Print (AbstractMessage msg, TextWriter output)
+ protected void Print (AbstractMessage msg, TextWriter output, bool showFullPath)
{
StringBuilder txt = new StringBuilder ();
if (!msg.Location.IsNull) {
- if (ShowFullPaths)
+ if (showFullPath)
txt.Append (msg.Location.ToStringFullName ());
else
txt.Append (msg.Location.ToString ());
}
}
+ //
+ // Tracks reported missing types. It needs to be session specific
+ // because we can run in probing mode
+ //
+ public bool MissingTypeReported (ITypeDefinition typeDefinition)
+ {
+ if (reported_missing_definitions == null)
+ reported_missing_definitions = new HashSet<ITypeDefinition> ();
+
+ if (reported_missing_definitions.Contains (typeDefinition))
+ return true;
+
+ reported_missing_definitions.Add (typeDefinition);
+ return false;
+ }
+
public void Reset ()
{
// HACK: Temporary hack for broken repl flow
//
List<AbstractMessage> merged_messages;
- public override void Print (AbstractMessage msg)
+ bool showFullPaths;
+
+ public void ClearSession ()
+ {
+ session_messages = null;
+ }
+
+ public override void Print (AbstractMessage msg, bool showFullPath)
{
//
// This line is useful when debugging recorded messages
//
- // Console.WriteLine ("RECORDING: {0}", msg.ToString ());
+ // Console.WriteLine ("RECORDING: {0}", msg.Text);
if (session_messages == null)
session_messages = new List<AbstractMessage> ();
session_messages.Add (msg);
- base.Print (msg);
+ this.showFullPaths = showFullPath;
+ base.Print (msg, showFullPath);
}
public void EndSession ()
bool error_msg = false;
foreach (AbstractMessage msg in messages_to_print) {
- dest.Print (msg);
+ dest.Print (msg, showFullPaths);
error_msg |= !msg.IsWarning;
}
+ if (reported_missing_definitions != null) {
+ foreach (var missing in reported_missing_definitions)
+ dest.MissingTypeReported (missing);
+ }
+
return error_msg;
}
}
this.writer = writer;
}
- public override void Print (AbstractMessage msg)
+ public override void Print (AbstractMessage msg, bool showFullPath)
{
- Print (msg, writer);
- base.Print (msg);
+ Print (msg, writer, showFullPath);
+ base.Print (msg, showFullPath);
}
}
return txt;
}
-
- static string FriendlyStackTrace (StackTrace t)
- {
- StringBuilder sb = new StringBuilder ();
-
- bool foundUserCode = false;
-
- for (int i = 0; i < t.FrameCount; i++) {
- StackFrame f = t.GetFrame (i);
- var mb = f.GetMethod ();
-
- if (!foundUserCode && mb.ReflectedType == typeof (Report))
- continue;
-
- foundUserCode = true;
-
- sb.Append ("\tin ");
-
- if (f.GetFileLineNumber () > 0)
- sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ());
-
- sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name);
-
- bool first = true;
- foreach (var pi in mb.GetParameters ()) {
- if (!first)
- sb.Append (", ");
- first = false;
-
- sb.Append (pi.ParameterType.FullName);
- }
- sb.Append (")\n");
- }
-
- return sb.ToString ();
- }
-
- public override void Print (AbstractMessage msg)
- {
- base.Print (msg);
-
- if (Stacktrace)
- Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
- }
-
- public static string FriendlyStackTrace (Exception e)
- {
- return FriendlyStackTrace (new StackTrace (e, true));
- }
-
- public static void StackTrace ()
- {
- Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
- }
}
class TimeReporter
if (timers == null)
return;
- Dictionary<TimerType, string> timer_names = new Dictionary<TimerType,string> () {
+ Dictionary<TimerType, string> timer_names = new Dictionary<TimerType,string> {
{ TimerType.ParseTotal, "Parsing source files" },
{ TimerType.AssemblyBuilderSetup, "Assembly builder setup" },
{ TimerType.CreateTypeTotal, "Compiled types created" },
}
}
+ class FatalException : Exception
+ {
+ public FatalException (string message)
+ : base (message)
+ {
+ }
+ }
+
/// <summary>
/// Handles #pragma warning
/// </summary>
public override bool IsEnabled (int code, bool previous)
{
- return this.code == code ? false : previous;
+ return this.code != code && previous;
}
}
public override bool IsEnabled(int code, bool previous)
{
- return this.code == code ? true : previous;
+ return this.code == code || previous;
}
}