Last active
May 7, 2022 15:43
-
-
Save MaxAtoms/9b9f14f7bab6d7ed7a64316d211d5f5d to your computer and use it in GitHub Desktop.
Trying out C# Caller Attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CallerAttributeExtensions | |
{ | |
public static void WriteCallerAttributeValuesToConsole<T>( this T? obj, | |
[CallerMemberName] string? member = null, | |
[CallerFilePath] string? filePath = null, | |
[CallerLineNumber] int lineNum = 0, | |
[CallerArgumentExpression("obj")] string? expr = null ) | |
{ | |
Console.Out.WriteLine( $"{member} {filePath} {lineNum} {expr}" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment