@@ -14,7 +14,7 @@ namespace RazorEngineCore
1414{
1515 public class RazorEngine : IRazorEngine
1616 {
17- public IRazorEngineCompiledTemplate < T > Compile < T > ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null , bool addPdb = false ) where T : IRazorEngineTemplate
17+ public IRazorEngineCompiledTemplate < T > Compile < T > ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null ) where T : IRazorEngineTemplate
1818 {
1919 IRazorEngineCompilationOptionsBuilder compilationOptionsBuilder = new RazorEngineCompilationOptionsBuilder ( ) ;
2020 compilationOptionsBuilder . AddAssemblyReference ( typeof ( T ) . Assembly ) ;
@@ -38,7 +38,7 @@ public Task<IRazorEngineCompiledTemplate<T>> CompileAsync<T>(string content, Act
3838 return Task . Factory . StartNew ( ( ) => this . Compile < T > ( content : content , builderAction : builderAction ) ) ;
3939 }
4040
41- public IRazorEngineCompiledTemplate Compile ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null , bool addPdb = false )
41+ public IRazorEngineCompiledTemplate Compile ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null )
4242 {
4343 IRazorEngineCompilationOptionsBuilder compilationOptionsBuilder = new RazorEngineCompilationOptionsBuilder ( ) ;
4444 compilationOptionsBuilder . Inherits ( typeof ( RazorEngineTemplateBase ) ) ;
@@ -66,12 +66,13 @@ protected virtual CompiledStreams CreateAndCompileToStream(string templateSource
6666 {
6767 templateSource = this . WriteDirectives ( templateSource , options ) ;
6868 string projectPath = @"." ;
69- string pdbfileName = Path . GetRandomFileName ( ) + ".cshtml" ;
69+ string fileName = string . IsNullOrWhiteSpace ( options . TemplateFilename ) ? Path . GetRandomFileName ( ) + ".cshtml" : options . TemplateFilename ;
70+
7071 if ( options . GeneratePdbStream )
7172 {
7273 projectPath = Path . GetTempPath ( ) ;
7374 Directory . CreateDirectory ( projectPath ) ;
74- File . WriteAllText ( Path . Combine ( projectPath , pdbfileName ) , templateSource ) ;
75+ File . WriteAllText ( Path . Combine ( projectPath , fileName ) , templateSource ) ;
7576 }
7677
7778 RazorProjectEngine engine = RazorProjectEngine . Create (
@@ -82,7 +83,6 @@ protected virtual CompiledStreams CreateAndCompileToStream(string templateSource
8283 builder . SetNamespace ( options . TemplateNamespace ) ;
8384 } ) ;
8485
85- string fileName = string . IsNullOrWhiteSpace ( options . TemplateFilename ) ? Path . GetRandomFileName ( ) : options . TemplateFilename ;
8686
8787 RazorSourceDocument document = RazorSourceDocument . Create ( templateSource , fileName ) ;
8888
0 commit comments