@@ -30,7 +30,7 @@ public IRazorEngineCompiledTemplate<T> Compile<T>(string content, Action<IRazorE
3030
3131 public Task < IRazorEngineCompiledTemplate < T > > CompileAsync < T > ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null , CancellationToken cancellationToken = default ) where T : IRazorEngineTemplate
3232 {
33- return Task . Factory . StartNew ( ( ) => this . Compile < T > ( content : content , builderAction : builderAction , cancellationToken : cancellationToken ) ) ;
33+ return Task . Run ( ( ) => this . Compile < T > ( content : content , builderAction : builderAction , cancellationToken : cancellationToken ) ) ;
3434 }
3535
3636 public IRazorEngineCompiledTemplate Compile ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null , CancellationToken cancellationToken = default )
@@ -46,7 +46,7 @@ public IRazorEngineCompiledTemplate Compile(string content, Action<IRazorEngineC
4646
4747 public Task < IRazorEngineCompiledTemplate > CompileAsync ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null , CancellationToken cancellationToken = default )
4848 {
49- return Task . Factory . StartNew ( ( ) => this . Compile (
49+ return Task . Run ( ( ) => this . Compile (
5050 content ,
5151 builderAction ,
5252 cancellationToken ) ) ;
@@ -105,7 +105,9 @@ protected virtual RazorEngineCompiledTemplateMeta CreateAndCompileToStream(strin
105105 } )
106106 . Concat ( options . MetadataReferences )
107107 . ToList ( ) ,
108- new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
108+ new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary )
109+ . WithOptimizationLevel ( OptimizationLevel . Release )
110+ . WithOverflowChecks ( true ) ) ;
109111
110112
111113 MemoryStream assemblyStream = new MemoryStream ( ) ;
0 commit comments