Client LuaCsForBarotrauma
|
Provides functionality for the loading, unloading and management of plugins implementing IAssemblyPlugin. All plugins are loaded into their own AssemblyLoadContext along with their dependencies. More...
Classes | |
class | LoadedACL |
Public Member Functions | |
IEnumerable< Type > | GetSubTypesInLoadedAssemblies< T > () |
IEnumerable< Type > | GetSubTypesInLoadedAssemblies< T > (bool rebuildList) |
Allows iteration over all non-interface types in all loaded assemblies in the AsmMgr that are assignable to the given type (IsAssignableFrom). Warning: care should be used when using this method in hot paths as performance may be affected. More... | |
bool | TryGetSubTypesFromACL< T > (Guid id, out IEnumerable< Type > types) |
Tries to get types assignable to type from the ACL given the Guid. More... | |
bool | TryGetSubTypesFromACL (Guid id, out IEnumerable< Type > types) |
Tries to get types from the ACL given the Guid. More... | |
IEnumerable< Type > | GetTypesByName (string typeName) |
Allows iteration over all types, including interfaces, in all loaded assemblies in the AsmMgr who's names match the string. Note: Will return the by-reference equivalent type if the type name is prefixed with "out " or "ref ". More... | |
IEnumerable< Type > | GetAllTypesInLoadedAssemblies () |
Allows iteration over all types (including interfaces) in all loaded assemblies managed by the AsmMgr. Warning: High usage may result in performance issues. More... | |
IEnumerable< LoadedACL > | GetAllLoadedACLs () |
Returns a list of all loaded ACLs. WARNING: References to these ACLs outside of the AssemblyManager should be kept in a WeakReference in order to avoid causing issues with unloading/disposal. More... | |
AssemblyLoadingSuccessState | LoadAssemblyFromMemory ([NotNull] string compiledAssemblyName, [NotNull] IEnumerable< SyntaxTree > syntaxTree, IEnumerable< MetadataReference > externalMetadataReferences, [NotNull] CSharpCompilationOptions compilationOptions, string friendlyName, ref Guid id, IEnumerable< Assembly > externFileAssemblyRefs=null) |
Compiles an assembly from supplied references and syntax trees into the specified AssemblyContextLoader. A new ACL will be created if the Guid supplied is Guid.Empty. More... | |
bool | SetACLToTemplateMode (Guid guid) |
Switches the ACL with the given Guid to Template Mode, which disables assembly name resolution for any assemblies loaded in it. These ACLs are intended to be used to host Assemblies for information only and not for code execution. WARNING: This process is irreversible. More... | |
AssemblyLoadingSuccessState | LoadAssembliesFromLocations ([NotNull] IEnumerable< string > filePaths, string friendlyName, ref Guid id) |
Tries to load all assemblies at the supplied file paths list into the ACl with the given Guid. If the supplied Guid is Empty, then a new ACl will be created and the Guid will be assigned to it. More... | |
bool | TryBeginDispose () |
bool | FinalizeDispose () |
bool | TryGetACL (Guid id, out LoadedACL acl) |
Tries to retrieve the LoadedACL with the given ID or null if none is found. WARNING: External references to this ACL with long lifespans should be kept in a WeakReference to avoid causing unloading/disposal issues. More... | |
Properties | |
ImmutableList< WeakReference< MemoryFileAssemblyContextLoader > > | StillUnloadingACLs [get] |
[DEBUG ONLY] Returns a list of the current unloading ACLs. More... | |
bool | IsCurrentlyUnloading [get] |
Checks if there are any AssemblyLoadContexts still in the process of unloading. More... | |
Events | |
Action< Assembly > | OnAssemblyLoaded |
Called when an assembly is loaded. More... | |
Action< Assembly > | OnAssemblyUnloading |
Called when an assembly is marked for unloading, before unloading begins. You should use this to cleanup any references that you have to this assembly. More... | |
Action< string, Exception > | OnException |
Called whenever an exception is thrown. First arg is a formatted message, Second arg is the Exception. More... | |
Action< Guid > | OnACLUnload |
For unloading issue debugging. Called whenever MemoryFileAssemblyContextLoader [load context] is unloaded. More... | |
System.Func< LoadedACL, bool > | IsReadyToUnloadACL |
Used by content package and plugin management to stop unloading of a given ACL until all plugins have gracefully closed. More... | |
Provides functionality for the loading, unloading and management of plugins implementing IAssemblyPlugin. All plugins are loaded into their own AssemblyLoadContext along with their dependencies.
Definition at line 28 of file AssemblyManager.cs.
bool AssemblyManager.FinalizeDispose | ( | ) |
Definition at line 569 of file AssemblyManager.cs.
IEnumerable<LoadedACL> AssemblyManager.GetAllLoadedACLs | ( | ) |
Returns a list of all loaded ACLs. WARNING: References to these ACLs outside of the AssemblyManager should be kept in a WeakReference in order to avoid causing issues with unloading/disposal.
Definition at line 335 of file AssemblyManager.cs.
IEnumerable<Type> AssemblyManager.GetAllTypesInLoadedAssemblies | ( | ) |
Allows iteration over all types (including interfaces) in all loaded assemblies managed by the AsmMgr. Warning: High usage may result in performance issues.
Definition at line 308 of file AssemblyManager.cs.
IEnumerable<Type> AssemblyManager.GetSubTypesInLoadedAssemblies< T > | ( | ) |
Definition at line 100 of file AssemblyManager.cs.
IEnumerable<Type> AssemblyManager.GetSubTypesInLoadedAssemblies< T > | ( | bool | rebuildList | ) |
Allows iteration over all non-interface types in all loaded assemblies in the AsmMgr that are assignable to the given type (IsAssignableFrom). Warning: care should be used when using this method in hot paths as performance may be affected.
T | The type to compare against |
rebuildList | Forces caches to clear and for the lists of types to be rebuilt. |
Definition at line 113 of file AssemblyManager.cs.
IEnumerable<Type> AssemblyManager.GetTypesByName | ( | string | typeName | ) |
Allows iteration over all types, including interfaces, in all loaded assemblies in the AsmMgr who's names match the string. Note: Will return the by-reference equivalent type if the type name is prefixed with "out " or "ref ".
typeName | The string name of the type to search for. |
Definition at line 217 of file AssemblyManager.cs.
AssemblyLoadingSuccessState AssemblyManager.LoadAssembliesFromLocations | ( | [NotNull] IEnumerable< string > | filePaths, |
string | friendlyName, | ||
ref Guid | id | ||
) |
Tries to load all assemblies at the supplied file paths list into the ACl with the given Guid. If the supplied Guid is Empty, then a new ACl will be created and the Guid will be assigned to it.
filePaths | List of assemblies to try and load. |
friendlyName | A non-unique name for later reference. Optional. |
id | Guid of the ACL or Empty if none specified. Guid of ACL will be assigned to this var. |
ArgumentNullException |
Definition at line 468 of file AssemblyManager.cs.
AssemblyLoadingSuccessState AssemblyManager.LoadAssemblyFromMemory | ( | [NotNull] string | compiledAssemblyName, |
[NotNull] IEnumerable< SyntaxTree > | syntaxTree, | ||
IEnumerable< MetadataReference > | externalMetadataReferences, | ||
[NotNull] CSharpCompilationOptions | compilationOptions, | ||
string | friendlyName, | ||
ref Guid | id, | ||
IEnumerable< Assembly > | externFileAssemblyRefs = null |
||
) |
Compiles an assembly from supplied references and syntax trees into the specified AssemblyContextLoader. A new ACL will be created if the Guid supplied is Guid.Empty.
compiledAssemblyName | |
syntaxTree | |
externalMetadataReferences | |
compilationOptions | |
friendlyName | A non-unique name for later reference. Optional, set to null if unused. |
id | The guid of the assembly |
externFileAssemblyRefs |
Definition at line 391 of file AssemblyManager.cs.
bool AssemblyManager.SetACLToTemplateMode | ( | Guid | guid | ) |
Switches the ACL with the given Guid to Template Mode, which disables assembly name resolution for any assemblies loaded in it. These ACLs are intended to be used to host Assemblies for information only and not for code execution. WARNING: This process is irreversible.
guid | Guid of the ACL. |
Definition at line 451 of file AssemblyManager.cs.
bool AssemblyManager.TryBeginDispose | ( | ) |
Definition at line 513 of file AssemblyManager.cs.
bool AssemblyManager.TryGetACL | ( | Guid | id, |
out LoadedACL | acl | ||
) |
Tries to retrieve the LoadedACL with the given ID or null if none is found. WARNING: External references to this ACL with long lifespans should be kept in a WeakReference to avoid causing unloading/disposal issues.
id | GUID of the ACL. |
acl | The found ACL or null if none was found. |
Definition at line 619 of file AssemblyManager.cs.
bool AssemblyManager.TryGetSubTypesFromACL | ( | Guid | id, |
out IEnumerable< Type > | types | ||
) |
Tries to get types from the ACL given the Guid.
id | |
types |
Definition at line 198 of file AssemblyManager.cs.
bool AssemblyManager.TryGetSubTypesFromACL< T > | ( | Guid | id, |
out IEnumerable< Type > | types | ||
) |
Tries to get types assignable to type from the ACL given the Guid.
id | |
types |
T |
Definition at line 176 of file AssemblyManager.cs.
|
get |
Checks if there are any AssemblyLoadContexts still in the process of unloading.
Definition at line 79 of file AssemblyManager.cs.
|
get |
[DEBUG ONLY] Returns a list of the current unloading ACLs.
Definition at line 58 of file AssemblyManager.cs.
System.Func<LoadedACL, bool> AssemblyManager.IsReadyToUnloadACL |
Used by content package and plugin management to stop unloading of a given ACL until all plugins have gracefully closed.
Definition at line 377 of file AssemblyManager.cs.
Action<Guid> AssemblyManager.OnACLUnload |
For unloading issue debugging. Called whenever MemoryFileAssemblyContextLoader [load context] is unloaded.
Definition at line 51 of file AssemblyManager.cs.
Action<Assembly> AssemblyManager.OnAssemblyLoaded |
Called when an assembly is loaded.
Definition at line 35 of file AssemblyManager.cs.
Action<Assembly> AssemblyManager.OnAssemblyUnloading |
Called when an assembly is marked for unloading, before unloading begins. You should use this to cleanup any references that you have to this assembly.
Definition at line 41 of file AssemblyManager.cs.
Action<string, Exception> AssemblyManager.OnException |
Called whenever an exception is thrown. First arg is a formatted message, Second arg is the Exception.
Definition at line 46 of file AssemblyManager.cs.