Client LuaCsForBarotrauma
MemoryFileAssemblyContextLoader Class Reference

AssemblyLoadContext to compile from syntax trees in memory and to load from disk/file. Provides dependency resolution. [IMPORTANT] Only supports 1 in-memory compiled assembly at a time. Use more instances if you need more. [IMPORTANT] All file assemblies required for the compilation of syntax trees should be loaded first. More...

Inheritance diagram for MemoryFileAssemblyContextLoader:

Public Member Functions

 MemoryFileAssemblyContextLoader (AssemblyManager assemblyManager)
 
AssemblyLoadingSuccessState LoadFromFiles ([NotNull] IEnumerable< string > assemblyFilePaths)
 Try to load the list of disk-file assemblies. More...
 
AssemblyLoadingSuccessState CompileAndLoadScriptAssembly ([NotNull] string assemblyName, [NotNull] IEnumerable< SyntaxTree > syntaxTrees, IEnumerable< MetadataReference > externMetadataReferences, [NotNull] CSharpCompilationOptions compilationOptions, out string compilationMessages, IEnumerable< Assembly > externFileAssemblyReferences=null)
 Compiles the supplied syntaxtrees and options into an in-memory assembly image. Builds metadata from loaded assemblies, only supply your own if you have in-memory images not managed by the AssemblyManager class. More...
 

Protected Member Functions

override Assembly Load (AssemblyName assemblyName)
 

Protected Attributes

bool IsResolving
 

Properties

string FriendlyName [get, set]
 
Assembly CompiledAssembly [get]
 
byte[] CompiledAssemblyImage [get]
 
bool IsTemplateMode [get, set]
 
bool IsDisposed [get]
 

Detailed Description

AssemblyLoadContext to compile from syntax trees in memory and to load from disk/file. Provides dependency resolution. [IMPORTANT] Only supports 1 in-memory compiled assembly at a time. Use more instances if you need more. [IMPORTANT] All file assemblies required for the compilation of syntax trees should be loaded first.

Definition at line 23 of file MemoryFileAssemblyContextLoader.cs.

Constructor & Destructor Documentation

◆ MemoryFileAssemblyContextLoader()

MemoryFileAssemblyContextLoader.MemoryFileAssemblyContextLoader ( AssemblyManager  assemblyManager)

Definition at line 38 of file MemoryFileAssemblyContextLoader.cs.

Member Function Documentation

◆ CompileAndLoadScriptAssembly()

AssemblyLoadingSuccessState MemoryFileAssemblyContextLoader.CompileAndLoadScriptAssembly ( [NotNull] string  assemblyName,
[NotNull] IEnumerable< SyntaxTree >  syntaxTrees,
IEnumerable< MetadataReference >  externMetadataReferences,
[NotNull] CSharpCompilationOptions  compilationOptions,
out string  compilationMessages,
IEnumerable< Assembly >  externFileAssemblyReferences = null 
)

Compiles the supplied syntaxtrees and options into an in-memory assembly image. Builds metadata from loaded assemblies, only supply your own if you have in-memory images not managed by the AssemblyManager class.

Parameters
assemblyNameName of the assembly. Must be supplied for in-memory assemblies.
syntaxTreesSyntax trees to compile into the assembly.
externMetadataReferencesMetadata to be used for compilation. [IMPORTANT] This method builds metadata from loaded assemblies, only supply your own if you have in-memory images not managed by the AssemblyManager class.
compilationOptionsCSharp compilation options. This method automatically adds the 'IgnoreAccessChecks' property for compilation.
compilationMessagesWill contain any diagnostic messages for compilation failure.
externFileAssemblyReferencesAdditional assemblies located in the FileSystem to build metadata references from. Assemblies here will have duplicates by the same name that are currently loaded filtered out.
Returns
Success state of the operation.
Exceptions
ArgumentNullExceptionThrows exception if any of the required arguments are null.

Definition at line 135 of file MemoryFileAssemblyContextLoader.cs.

◆ Load()

override Assembly MemoryFileAssemblyContextLoader.Load ( AssemblyName  assemblyName)
protected

Definition at line 260 of file MemoryFileAssemblyContextLoader.cs.

◆ LoadFromFiles()

AssemblyLoadingSuccessState MemoryFileAssemblyContextLoader.LoadFromFiles ( [NotNull] IEnumerable< string >  assemblyFilePaths)

Try to load the list of disk-file assemblies.

Parameters
assemblyFilePathsOperation success or failure reason.

Definition at line 50 of file MemoryFileAssemblyContextLoader.cs.

Member Data Documentation

◆ IsResolving

bool MemoryFileAssemblyContextLoader.IsResolving
protected

Definition at line 33 of file MemoryFileAssemblyContextLoader.cs.

Property Documentation

◆ CompiledAssembly

Assembly MemoryFileAssemblyContextLoader.CompiledAssembly
get

Definition at line 28 of file MemoryFileAssemblyContextLoader.cs.

◆ CompiledAssemblyImage

byte [] MemoryFileAssemblyContextLoader.CompiledAssemblyImage
get

Definition at line 29 of file MemoryFileAssemblyContextLoader.cs.

◆ FriendlyName

string MemoryFileAssemblyContextLoader.FriendlyName
getset

Definition at line 26 of file MemoryFileAssemblyContextLoader.cs.

◆ IsDisposed

bool MemoryFileAssemblyContextLoader.IsDisposed
get

Definition at line 36 of file MemoryFileAssemblyContextLoader.cs.

◆ IsTemplateMode

bool MemoryFileAssemblyContextLoader.IsTemplateMode
getset

Definition at line 35 of file MemoryFileAssemblyContextLoader.cs.