22#if DEBUG
33#define PRINTIL
44#define PRINTCS
5+ #define PRINTEXPR
56#endif
67
78using System ;
@@ -60,18 +61,20 @@ public static void AssertOpCodes(this MethodInfo method, params OpCode[] expecte
6061
6162 [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2026:RequiresUnreferencedCode" ,
6263 Justification = "The method is used for the testing purposes only." ) ]
63- [ Conditional ( "DEBUG" ) ]
64- public static void PrintExpression ( this Expression expr , bool completeTypeNames = false ) =>
64+ public static void PrintExpression ( this Expression expr , bool completeTypeNames = false )
65+ {
66+ #if PRINTEXPR
6567 Console . WriteLine (
6668 expr . ToExpressionString ( out var _ , out var _ , out var _ ,
6769 stripNamespace : true ,
6870 printType : completeTypeNames ? null : CodePrinter . PrintTypeStripOuterClasses ,
6971 indentSpaces : 4 )
7072 ) ;
73+ #endif
74+ }
7175
7276 [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2026:RequiresUnreferencedCode" ,
7377 Justification = "The method is used for the testing purposes only." ) ]
74- [ Conditional ( "DEBUG" ) ]
7578 public static void PrintCSharp ( this Expression expr , bool completeTypeNames = false ,
7679 [ CallerMemberName ] string caller = "" , [ CallerFilePath ] string filePath = "" )
7780 {
@@ -93,7 +96,6 @@ public static void PrintCSharp(this Expression expr, bool completeTypeNames = fa
9396
9497 [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2026:RequiresUnreferencedCode" ,
9598 Justification = "The method is used for the testing purposes only." ) ]
96- [ Conditional ( "DEBUG" ) ]
9799 public static void PrintCSharp ( this Expression expr , Func < string , string > transform ,
98100 [ CallerMemberName ] string caller = "" , [ CallerFilePath ] string filePath = "" )
99101 {
@@ -106,7 +108,6 @@ public static void PrintCSharp(this Expression expr, Func<string, string> transf
106108
107109 [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2026:RequiresUnreferencedCode" ,
108110 Justification = "The method is used for the testing purposes only." ) ]
109- [ Conditional ( "DEBUG" ) ]
110111 public static void PrintCSharp ( this Expression expr , CodePrinter . ObjectToCode objectToCode ,
111112 [ CallerMemberName ] string caller = "" , [ CallerFilePath ] string filePath = "" )
112113 {
@@ -119,23 +120,20 @@ public static void PrintCSharp(this Expression expr, CodePrinter.ObjectToCode ob
119120
120121 [ UnconditionalSuppressMessage ( "ReflectionAnalysis" , "IL2026:RequiresUnreferencedCode" ,
121122 Justification = "The method is used for the testing purposes only." ) ]
122- [ Conditional ( "DEBUG" ) ]
123123 public static void PrintCSharp ( this Expression expr , ref string result )
124124 {
125125#if PRINTCS
126126 Console . WriteLine ( result = expr . ToCSharpString ( ) ) ;
127127#endif
128128 }
129129
130- [ Conditional ( "DEBUG" ) ]
131130 public static void PrintIL ( this Delegate @delegate , [ CallerMemberName ] string tag = null )
132131 {
133132#if PRINTIL
134133 @delegate . Method . PrintIL ( tag ) ;
135134#endif
136135 }
137136
138- [ Conditional ( "DEBUG" ) ]
139137 public static void PrintIL ( this MethodInfo method , string tag = null )
140138 {
141139#if PRINTIL
0 commit comments