cs11dotnet7/vscode/Chapter04/Instrumenting/Program.Methods.cs

18 lines
518 B
C#
Raw Normal View History

2022-09-17 16:45:46 +02:00
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));
}
}