mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 06:43:47 +00:00
Initial commit
This commit is contained in:
parent
bf63cf7d4b
commit
965e874957
4 changed files with 42 additions and 2 deletions
17
vscode/Chapter04/Instrumenting/Program.Methods.cs
Normal file
17
vscode/Chapter04/Instrumenting/Program.Methods.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue