From a6580cc3c57ac807fe1ba217bdd3bc71f88d0944 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 8 Sep 2020 12:24:34 +0200 Subject: [PATCH] Add documentation comments to RoslynCompiler and LoadContext --- .../RoslynCompiler.cs | 13 +++++++++++-- .../UmbracoAssemblyLoadContext.cs | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.ModelsBuilder.Embedded/RoslynCompiler.cs b/src/Umbraco.ModelsBuilder.Embedded/RoslynCompiler.cs index 256b429ad9..7f1443b156 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/RoslynCompiler.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/RoslynCompiler.cs @@ -15,6 +15,10 @@ namespace Umbraco.ModelsBuilder.Embedded private CSharpParseOptions _parseOptions; private List _refs; + /// + /// Roslyn compiler which can be used to compile a c# file to a Dll assembly + /// + /// Referenced assemblies used in the source file public RoslynCompiler(IEnumerable referenceAssemblies) { _outputKind = OutputKind.DynamicallyLinkedLibrary; @@ -37,7 +41,12 @@ namespace Umbraco.ModelsBuilder.Embedded _refs.Add(MetadataReference.CreateFromFile(typeof(System.CodeDom.Compiler.GeneratedCodeAttribute).Assembly.Location)); } - public void CompileToFile(string pathToSourceFile, string saveLocation) + /// + /// Compile a source file to a dll + /// + /// Path to the source file containing the code to be compiled. + /// The path where the output assembly will be saved. + public void CompileToFile(string pathToSourceFile, string savePath) { var sourceCode = File.ReadAllText(pathToSourceFile); @@ -53,7 +62,7 @@ namespace Umbraco.ModelsBuilder.Embedded // Not entirely certain that assemblyIdentityComparer is nececary? assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default)); - compilation.Emit(saveLocation); + compilation.Emit(savePath); } } diff --git a/src/Umbraco.ModelsBuilder.Embedded/UmbracoAssemblyLoadContext.cs b/src/Umbraco.ModelsBuilder.Embedded/UmbracoAssemblyLoadContext.cs index 638f4b17a9..b7feeaaaeb 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/UmbracoAssemblyLoadContext.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/UmbracoAssemblyLoadContext.cs @@ -9,6 +9,10 @@ namespace Umbraco.ModelsBuilder.Embedded class UmbracoAssemblyLoadContext : AssemblyLoadContext { + /// + /// Collectible AssemblyLoadContext used to load in the compiled generated models. + /// Must be a collectible assembly in order to be able to be unloaded. + /// public UmbracoAssemblyLoadContext() : base(isCollectible: true) {