diff options
Diffstat (limited to 'lib')
7 files changed, 31 insertions, 30 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 94e7137..9ccb39a 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 @@ -48,7 +48,7 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" /> + <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" /> </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 d622a05..7e5f058 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 @@ -40,7 +40,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" /> + <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" /> </ItemGroup> <ItemGroup> diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs b/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs index 49ef4b3..2d47af5 100644 --- a/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs +++ b/lib/VNLib.Plugins.Extensions.Loading/src/AssemblyLoader.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Extensions.Loading @@ -48,19 +48,19 @@ namespace VNLib.Plugins.Extensions.Loading public sealed class AssemblyLoader<T> : ManagedLibrary, IDisposable { private readonly CancellationTokenRegistration _reg; - private readonly Lazy<T> _instance; + private readonly LazyInitializer<T> _instance; private bool disposedValue; /// <summary> /// The instance of the loaded type /// </summary> - public T Resource => _instance.Value; + public T Resource => _instance.Instance; private AssemblyLoader(string assemblyPath, AssemblyLoadContext parentContext, CancellationToken unloadToken) :base(assemblyPath, parentContext) { //Init lazy type loader - _instance = new(LoadTypeFromAssembly<T>, LazyThreadSafetyMode.PublicationOnly); + _instance = new(LoadTypeFromAssembly<T>); //Register dispose _reg = unloadToken.Register(Dispose); } @@ -96,7 +96,7 @@ namespace VNLib.Plugins.Extensions.Loading if (disposing) { //If the instance is disposable, call its dispose method on unload - if (_instance.IsValueCreated && _instance.Value is IDisposable disposable) + if (_instance.IsLoaded && _instance.Instance is IDisposable disposable) { disposable.Dispose(); } @@ -138,7 +138,7 @@ namespace VNLib.Plugins.Extensions.Loading /// <exception cref="FileNotFoundException"></exception> internal static AssemblyLoader<T> Load(string assemblyName, AssemblyLoadContext loadContext, CancellationToken unloadToken) { - _ = loadContext ?? throw new ArgumentNullException(nameof(loadContext)); + ArgumentNullException.ThrowIfNull(loadContext); //Make sure the file exists if (!FileOperations.FileExists(assemblyName)) diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/ConfigurationExtensions.cs b/lib/VNLib.Plugins.Extensions.Loading/src/ConfigurationExtensions.cs index d4ea8b0..30711fa 100644 --- a/lib/VNLib.Plugins.Extensions.Loading/src/ConfigurationExtensions.cs +++ b/lib/VNLib.Plugins.Extensions.Loading/src/ConfigurationExtensions.cs @@ -704,22 +704,22 @@ namespace VNLib.Plugins.Extensions.Loading return []; } - if (searchPaths.ValueKind == JsonValueKind.Array) + switch (searchPaths.ValueKind) { - //Get the plugins path or throw because it should ALWAYS be defined if this method is called - return searchPaths.EnumerateArray() - .Select(static p => p.GetString()!) - .Select(Path.GetFullPath) //Get absolute file paths - .ToArray(); - } - else if (searchPaths.ValueKind == JsonValueKind.String) - { - return [Path.GetFullPath(searchPaths.GetString()!)]; - } - else - { - return []; - } + case JsonValueKind.Array: + + //Get the plugins path or throw because it should ALWAYS be defined if this method is called + return searchPaths.EnumerateArray() + .Select(static p => p.GetString()!) + .Select(Path.GetFullPath) //Get absolute file paths + .ToArray(); + + case JsonValueKind.String: + return [ Path.GetFullPath(searchPaths.GetString()!) ]; + + default: + return []; + } } } } diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/IAsyncBackgroundWork.cs b/lib/VNLib.Plugins.Extensions.Loading/src/IAsyncBackgroundWork.cs index 9fb66a2..a86129c 100644 --- a/lib/VNLib.Plugins.Extensions.Loading/src/IAsyncBackgroundWork.cs +++ b/lib/VNLib.Plugins.Extensions.Loading/src/IAsyncBackgroundWork.cs @@ -1,12 +1,12 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Extensions.Loading -* File: LoadingExtensions.cs +* File: IAsyncBackgroundWork.cs * -* LoadingExtensions.cs is part of VNLib.Plugins.Extensions.Loading which is part of the larger -* VNLib collection of libraries and utilities. +* IAsyncBackgroundWork.cs is part of VNLib.Plugins.Extensions.Loading which is +* part of the larger VNLib collection of libraries and utilities. * * VNLib.Plugins.Extensions.Loading is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -22,9 +22,10 @@ * along with this program. If not, see https://www.gnu.org/licenses/. */ +using System.Threading; using System.Threading.Tasks; + using VNLib.Utils.Logging; -using System.Threading; namespace VNLib.Plugins.Extensions.Loading { diff --git a/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj b/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj index b27fc00..9df3236 100644 --- a/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj +++ b/lib/sql-providers/sqlite/VNLib.Plugins.Extensions.Loading.Sql.SQLite/src/VNLib.Plugins.Extensions.Loading.Sql.SQLite.csproj @@ -49,7 +49,7 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" /> </ItemGroup> <ItemGroup> diff --git a/lib/sql-providers/sqlserver/VNLib.Plugins.Extensions.Loading.Sql.SQLServer/src/VNLib.Plugins.Extensions.Loading.Sql.SQLServer.csproj b/lib/sql-providers/sqlserver/VNLib.Plugins.Extensions.Loading.Sql.SQLServer/src/VNLib.Plugins.Extensions.Loading.Sql.SQLServer.csproj index 7015b8c..d99249b 100644 --- a/lib/sql-providers/sqlserver/VNLib.Plugins.Extensions.Loading.Sql.SQLServer/src/VNLib.Plugins.Extensions.Loading.Sql.SQLServer.csproj +++ b/lib/sql-providers/sqlserver/VNLib.Plugins.Extensions.Loading.Sql.SQLServer/src/VNLib.Plugins.Extensions.Loading.Sql.SQLServer.csproj @@ -49,7 +49,7 @@ <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" /> </ItemGroup> |