From 9dba437734eff215647d3a36a068a54828479fea Mon Sep 17 00:00:00 2001 From: Michael Cleverdon Date: Thu, 22 Feb 2024 16:09:35 -0700 Subject: [PATCH 1/2] mcleverdon Adding documentation to RazorEngineCompilationOptionsBuilder --- .../RazorEngineCompilationOptionsBuilder.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs b/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs index 0ea6e82..2e09194 100644 --- a/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs +++ b/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs @@ -15,17 +15,30 @@ public RazorEngineCompilationOptionsBuilder(RazorEngineCompilationOptions option this.Options = options ?? new RazorEngineCompilationOptions(); } + /// + /// Loads the Assembly by name and adds it to the Engine's Assembly Reference list + /// + /// Full Name of the Assembly to add to the assembly list public void AddAssemblyReferenceByName(string assemblyName) { Assembly assembly = Assembly.Load(new AssemblyName(assemblyName)); this.AddAssemblyReference(assembly); } + /// + /// Adds a loaded assembly to the Engine's Assembly Reference list + /// + /// Assembly to add to the assembly list public void AddAssemblyReference(Assembly assembly) { this.Options.ReferencedAssemblies.Add(assembly); } + /// + /// Adds a type's assembly to the Engine's Assembly Reference list + /// Also adds the type's GenericTypeArguments to the Reference list as well + /// + /// The type who's assembly should be added to the assembly list public void AddAssemblyReference(Type type) { this.AddAssemblyReference(type.Assembly); @@ -36,16 +49,35 @@ public void AddAssemblyReference(Type type) } } + /// + /// Adds a MetadataReference for use in the Engine's Assembly Reference generation + /// + /// Metadata Reference to add to the Engine's Referenced Assemblies public void AddMetadataReference(MetadataReference reference) { this.Options.MetadataReferences.Add(reference); } + /// + /// Adds a default using to the compiled view. This is equivalent to adding @using [NAMESPACE] to every template rendered by the engine' + /// Current Defaults: + /// + /// + /// System.Linq + /// System.Collections + /// System.Collections.Generic + /// + /// + /// Namespace to add to default usings public void AddUsing(string namespaceName) { this.Options.DefaultUsings.Add(namespaceName); } + /// + /// Adds type to @inherit from in the template + /// + /// Type to @inherit from public void Inherits(Type type) { this.Options.Inherits = this.RenderTypeName(type); @@ -94,6 +126,9 @@ private string RenderDeclaringType(Type type) return parent + "." + type.Name; } + /// + /// Enables debug info + /// public void IncludeDebuggingInfo() { this.Options.IncludeDebuggingInfo = true; From e32f1cc5e6522a44561c77ee94b24b4a63ba9505 Mon Sep 17 00:00:00 2001 From: Michael Cleverdon Date: Thu, 22 Feb 2024 16:22:17 -0700 Subject: [PATCH 2/2] mcleverdon forgot interface --- .../IRazorEngineCompilationOptionsBuilder.cs | 41 +++++++++++++++++++ .../RazorEngineCompilationOptionsBuilder.cs | 6 +-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs b/RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs index 6501ae7..5d6e2e2 100644 --- a/RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs +++ b/RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs @@ -8,12 +8,53 @@ public interface IRazorEngineCompilationOptionsBuilder { RazorEngineCompilationOptions Options { get; set; } + /// + /// Loads the Assembly by name and adds it to the Engine's Assembly Reference list + /// + /// Full Name of the Assembly to add to the assembly list void AddAssemblyReferenceByName(string assemblyName); + + /// + /// Adds a loaded assembly to the Engine's Assembly Reference list + /// + /// Assembly to add to the assembly list void AddAssemblyReference(Assembly assembly); + + /// + /// Adds a type's assembly to the Engine's Assembly Reference list + /// Also adds the type's GenericTypeArguments to the Reference list as well + /// + /// The type who's assembly should be added to the assembly list void AddAssemblyReference(Type type); + + /// + /// Adds a MetadataReference for use in the Engine's Assembly Reference generation + /// + /// Metadata Reference to add to the Engine's Referenced Assemblies void AddMetadataReference(MetadataReference reference); + + /// + /// Adds a default using to the compiled view. This is equivalent to adding @using [NAMESPACE] to every template rendered by the engine' + /// Current Defaults: + /// + /// + /// System.Linq + /// System.Collections + /// System.Collections.Generic + /// + /// + /// Namespace to add to default usings void AddUsing(string namespaceName); + + /// + /// Adds @inherits directive to the compiled template + /// + /// Type to @inherits from void Inherits(Type type); + + /// + /// Enables debug info + /// void IncludeDebuggingInfo(); } } \ No newline at end of file diff --git a/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs b/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs index 2e09194..16ba347 100644 --- a/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs +++ b/RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs @@ -59,7 +59,7 @@ public void AddMetadataReference(MetadataReference reference) } /// - /// Adds a default using to the compiled view. This is equivalent to adding @using [NAMESPACE] to every template rendered by the engine' + /// Adds a default using to the compiled view. This is equivalent to adding @using [NAMESPACE] to the template rendered by the engine' /// Current Defaults: /// /// @@ -75,9 +75,9 @@ public void AddUsing(string namespaceName) } /// - /// Adds type to @inherit from in the template + /// Adds @inherits directive to the compiled template /// - /// Type to @inherit from + /// Type to @inherits from public void Inherits(Type type) { this.Options.Inherits = this.RenderTypeName(type);