mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2025-12-06 05:32:03 +01:00
18 lines
518 B
C#
18 lines
518 B
C#
|
|
using System.Diagnostics; // Trace
|
|||
|
|
using System.Runtime.CompilerServices; // [Caller...] attributes
|
|||
|
|
|
|||
|
|
partial class Program
|
|||
|
|
{
|
|||
|
|
static void LogSourceDetails(
|
|||
|
|
bool condition,
|
|||
|
|
[CallerMemberName] string member = "",
|
|||
|
|
[CallerFilePath] string filepath = "",
|
|||
|
|
[CallerLineNumber] int line = 0,
|
|||
|
|
[CallerArgumentExpression(nameof(condition))] string expression = "")
|
|||
|
|
{
|
|||
|
|
Trace.WriteLine(string.Format(
|
|||
|
|
"[{0}]\n {1} on line {2}. Expression: {3}",
|
|||
|
|
filepath, member, line, expression));
|
|||
|
|
}
|
|||
|
|
}
|