Holds the default message sink for this thread (Current), Symbols for the common message types, such as Warning and Error, and default instances of ConsoleMessageSink, TraceMessageSink and NullMessageSink.
More...
Source file:
Holds the default message sink for this thread (Current), Symbols for the common message types, such as Warning and Error, and default instances of ConsoleMessageSink, TraceMessageSink and NullMessageSink.
- See also
- IMessageSink
Sends all messages to a user-defined method.
static object Loyc.MessageSink.LocationOf |
( |
object |
context | ) |
|
|
inlinestatic |
Returns context.Location if context implements IHasLocation; otherwise, returns context itself.
static string Loyc.MessageSink.LocationString |
( |
object |
context | ) |
|
|
inlinestatic |
Gets the location information from the specified object, or converts the object to a string.
- Parameters
-
context | A value whose string representation you want to get. |
- Returns
- If
context
implements IHasLocation, this function returns IHasLocation.Location; if context
is null, this method returns null
; otherwise it returns context.ToString()
.
Message sinks are commonly used to display error and warning messages, and when you write a message with IMessageSink.Write()
, the second parameter is a "context" argument which specifies the object to which the message is related (for example, when writing compiler output, the context might be a node in a syntax tree). Most message sinks display the message in text form (in a log file or terminal), and in that case the best option is to display the location information associated with the context object (e.g. Foo.cpp:45), rather than a string representation of the object itself.
Therefore, message sinks that display a message in text form will call this method to convert the context object to a string, and if available, this method calls the IHasLocation.Location property of the context object.
Sends all messages to the System.Console.WriteLine(string).
Sends all messages to System.Diagnostics.Trace.WriteLine(string).