aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-19 13:56:28 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-19 13:56:28 -0400
commit656dd4976249ca1ca707ed7e723796c3a0fde1a0 (patch)
tree5131738480c794203f2e68746306361850542076
parent1d97b54c3a1153b7fa8a9c99172bd21fb749da5f (diff)
RestSharp version update, PKI optional login endpoint
-rw-r--r--lib/VNLib.Plugins.Extensions.Data/src/VNLib.Plugins.Extensions.Data.csproj2
-rw-r--r--lib/VNLib.Plugins.Extensions.Loading.Sql/src/VNLib.Plugins.Extensions.Loading.Sql.csproj4
-rw-r--r--lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs25
-rw-r--r--lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs13
4 files changed, 29 insertions, 15 deletions
diff --git a/lib/VNLib.Plugins.Extensions.Data/src/VNLib.Plugins.Extensions.Data.csproj b/lib/VNLib.Plugins.Extensions.Data/src/VNLib.Plugins.Extensions.Data.csproj
index 0616048..12fb71c 100644
--- a/lib/VNLib.Plugins.Extensions.Data/src/VNLib.Plugins.Extensions.Data.csproj
+++ b/lib/VNLib.Plugins.Extensions.Data/src/VNLib.Plugins.Extensions.Data.csproj
@@ -41,7 +41,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.14" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.15" />
</ItemGroup>
<ItemGroup>
diff --git a/lib/VNLib.Plugins.Extensions.Loading.Sql/src/VNLib.Plugins.Extensions.Loading.Sql.csproj b/lib/VNLib.Plugins.Extensions.Loading.Sql/src/VNLib.Plugins.Extensions.Loading.Sql.csproj
index 3d61b67..5e7e2a5 100644
--- a/lib/VNLib.Plugins.Extensions.Loading.Sql/src/VNLib.Plugins.Extensions.Loading.Sql.csproj
+++ b/lib/VNLib.Plugins.Extensions.Loading.Sql/src/VNLib.Plugins.Extensions.Loading.Sql.csproj
@@ -33,8 +33,8 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="6.0.14" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.14" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="6.0.15" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.15" />
<PackageReference Include="MySqlConnector" Version="2.2.5" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
</ItemGroup>
diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs b/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs
index dcc5f59..5de6103 100644
--- a/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs
+++ b/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs
@@ -154,13 +154,14 @@ namespace VNLib.Plugins.Extensions.Loading
/// <summary>
/// Creates a new loader for the desired assembly. The assembly and its dependencies
- /// will be loaded into the parent context, meaning all loaded types belong to the
- /// current <see cref="AssemblyLoadContext"/> which belongs the current plugin instance.
+ /// will be loaded into the specified context. If no context is specified the current assemblie's load
+ /// context is captured.
/// </summary>
/// <param name="assemblyName">The name of the assmbly within the current plugin directory</param>
/// <param name="unloadToken">The plugin unload token</param>
+ /// <param name="explicitContext">Explicitly set an assembly load context to load the requested assembly into</param>
/// <exception cref="FileNotFoundException"></exception>
- internal static AssemblyLoader<T> Load(string assemblyName, CancellationToken unloadToken)
+ internal static AssemblyLoader<T> Load(string assemblyName, AssemblyLoadContext? explicitContext, CancellationToken unloadToken)
{
//Make sure the file exists
if (!FileOperations.FileExists(assemblyName))
@@ -168,15 +169,19 @@ namespace VNLib.Plugins.Extensions.Loading
throw new FileNotFoundException($"The desired assembly {assemblyName} could not be found at the file path");
}
- /*
- * Dynamic assemblies are loaded directly to the exe assembly context.
- * This should always be the plugin isolated context.
- */
- Assembly executingAsm = Assembly.GetExecutingAssembly();
- AssemblyLoadContext currentCtx = AssemblyLoadContext.GetLoadContext(executingAsm) ?? throw new InvalidOperationException("Could not get default assembly load context");
+ if(explicitContext == null)
+ {
+ /*
+ * Dynamic assemblies are loaded directly to the exe assembly context.
+ * This should always be the plugin isolated context.
+ */
+
+ Assembly executingAsm = Assembly.GetExecutingAssembly();
+ explicitContext = AssemblyLoadContext.GetLoadContext(executingAsm) ?? throw new InvalidOperationException("Could not get default assembly load context");
+ }
- return new(assemblyName, currentCtx, unloadToken);
+ return new(assemblyName, explicitContext, unloadToken);
}
}
diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs b/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs
index 0fbb66b..3e151b4 100644
--- a/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs
+++ b/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs
@@ -27,6 +27,7 @@ using System.IO;
using System.Linq;
using System.Text.Json;
using System.Reflection;
+using System.Runtime.Loader;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@@ -119,6 +120,10 @@ namespace VNLib.Plugins.Extensions.Loading
/// <param name="plugin"></param>
/// <param name="assemblyName">The name of the assembly (ex: 'file.dll') to search for</param>
/// <param name="dirSearchOption">Directory/file search option</param>
+ /// <param name="explictAlc">
+ /// Explicitly define an <see cref="AssemblyLoadContext"/> to load the assmbly, and it's dependencies
+ /// into. If null, uses the plugin's alc.
+ /// </param>
/// <returns>The <see cref="AssemblyLoader{T}"/> managing the loaded assmbly in the current AppDomain</returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="FileNotFoundException"></exception>
@@ -127,7 +132,11 @@ namespace VNLib.Plugins.Extensions.Loading
/// The assembly is searched within the 'assets' directory specified in the plugin config
/// or the global plugins ('path' key) directory if an assets directory is not defined.
/// </remarks>
- public static AssemblyLoader<T> LoadAssembly<T>(this PluginBase plugin, string assemblyName, SearchOption dirSearchOption = SearchOption.AllDirectories)
+ public static AssemblyLoader<T> LoadAssembly<T>(
+ this PluginBase plugin,
+ string assemblyName,
+ SearchOption dirSearchOption = SearchOption.AllDirectories,
+ AssemblyLoadContext? explictAlc = null)
{
plugin.ThrowIfUnloaded();
_ = assemblyName ?? throw new ArgumentNullException(nameof(assemblyName));
@@ -154,7 +163,7 @@ namespace VNLib.Plugins.Extensions.Loading
_ = asmFile ?? throw new FileNotFoundException($"Failed to load custom assembly {assemblyName} from plugin directory");
//Load the assembly
- return AssemblyLoader<T>.Load(asmFile, plugin.UnloadToken);
+ return AssemblyLoader<T>.Load(asmFile, explictAlc, plugin.UnloadToken);
}
/// <summary>