@@ -7,41 +7,32 @@ namespace RazorEngineCore
77{
88 public class RazorEngineCompilationOptions
99 {
10- private HashSet < Assembly > _referencedAssemblies ;
11- public HashSet < Assembly > ReferencedAssemblies {
12- get
13- {
14- if ( this . _referencedAssemblies != null )
15- return this . _referencedAssemblies ;
16-
17- this . _referencedAssemblies = new HashSet < Assembly > ( )
18- {
19- typeof ( object ) . Assembly ,
20- Assembly . Load ( new AssemblyName ( "Microsoft.CSharp" ) ) ,
21- typeof ( RazorEngineTemplateBase ) . Assembly ,
22- Assembly . Load ( new AssemblyName ( "System.Runtime" ) ) ,
23- Assembly . Load ( new AssemblyName ( "System.Linq" ) ) ,
24- Assembly . Load ( new AssemblyName ( "System.Linq.Expressions" ) )
25- } ;
26-
27- // Loading netstandard explicitly causes runtime error on Linux/OSX
28- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
29- {
30- this . _referencedAssemblies . Add ( Assembly . Load ( new AssemblyName ( "netstandard" ) ) ) ;
31- }
32-
33- return this . _referencedAssemblies ;
34- }
35- }
10+ public HashSet < Assembly > ReferencedAssemblies { get ; set ; } = new HashSet < Assembly > ( )
11+ {
12+ typeof ( object ) . Assembly ,
13+ Assembly . Load ( new AssemblyName ( "Microsoft.CSharp" ) ) ,
14+ typeof ( RazorEngineTemplateBase ) . Assembly ,
15+ Assembly . Load ( new AssemblyName ( "System.Runtime" ) ) ,
16+ Assembly . Load ( new AssemblyName ( "System.Linq" ) ) ,
17+ Assembly . Load ( new AssemblyName ( "System.Linq.Expressions" ) )
18+ } ;
3619
3720 public HashSet < MetadataReference > MetadataReferences { get ; set ; } = new HashSet < MetadataReference > ( ) ;
38-
3921 public string TemplateNamespace { get ; set ; } = "TemplateNamespace" ;
4022 public string Inherits { get ; set ; } = "RazorEngineCore.RazorEngineTemplateBase" ;
4123
4224 public HashSet < string > DefaultUsings { get ; set ; } = new HashSet < string > ( )
4325 {
4426 "System.Linq"
4527 } ;
28+
29+ public RazorEngineCompilationOptions ( )
30+ {
31+ // Loading netstandard explicitly causes runtime error on Linux/OSX
32+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
33+ {
34+ this . ReferencedAssemblies . Add ( Assembly . Load ( new AssemblyName ( "netstandard" ) ) ) ;
35+ }
36+ }
4637 }
4738}
0 commit comments