コード例 #1
0
        public static Delegate CompileWithDebugInfo(this LambdaExpression node, ExpressionCompilationOptions?options = null)
        {
            try
            {
                var compiler = new ExpressionCompiler(options);
                compiler.AddFile(node);
                var assembly = compiler.CreateAssembly();

                var translator = compiler.Translators[0];
                return(translator.CreateDelegate(assembly));
            }
            catch (Exception ex)
            {
                if (options?.ThrowOnFailedCompilation == true)
                {
                    throw;
                }
                Debug.Print(ex.ToString());
                return(node.Compile());
            }
        }