diff --git a/PettingZoo.Core/PettingZoo.Core.csproj b/PettingZoo.Core/PettingZoo.Core.csproj
index e37010b..6302265 100644
--- a/PettingZoo.Core/PettingZoo.Core.csproj
+++ b/PettingZoo.Core/PettingZoo.Core.csproj
@@ -8,6 +8,7 @@
+
diff --git a/PettingZoo.Core/Settings/PettingZooPaths.cs b/PettingZoo.Core/Settings/PettingZooPaths.cs
index 0b52081..b432e3b 100644
--- a/PettingZoo.Core/Settings/PettingZooPaths.cs
+++ b/PettingZoo.Core/Settings/PettingZooPaths.cs
@@ -9,6 +9,16 @@ namespace PettingZoo.Core.Settings
public static string AppDataRoot { get; }
public static string InstallationRoot { get; }
+ public static string LogPath => Path.Combine(AppDataRoot, @"Logs");
+
+ public static string DatabasePath => AppDataRoot;
+
+
+ public const string AssembliesPath = @"Assemblies";
+
+ public static string AppDataAssemblies => Path.Combine(AppDataRoot, AssembliesPath);
+ public static string InstallationAssemblies => Path.Combine(InstallationRoot, AssembliesPath);
+
static PettingZooPaths()
{
diff --git a/PettingZoo.RabbitMQ/PettingZoo.RabbitMQ.csproj b/PettingZoo.RabbitMQ/PettingZoo.RabbitMQ.csproj
index 7a65453..45d6771 100644
--- a/PettingZoo.RabbitMQ/PettingZoo.RabbitMQ.csproj
+++ b/PettingZoo.RabbitMQ/PettingZoo.RabbitMQ.csproj
@@ -9,6 +9,7 @@
+
diff --git a/PettingZoo.Settings.LiteDB/BaseLiteDBRepository.cs b/PettingZoo.Settings.LiteDB/BaseLiteDBRepository.cs
index aebb52b..8a605e6 100644
--- a/PettingZoo.Settings.LiteDB/BaseLiteDBRepository.cs
+++ b/PettingZoo.Settings.LiteDB/BaseLiteDBRepository.cs
@@ -16,7 +16,7 @@ namespace PettingZoo.Settings.LiteDB
public BaseLiteDBRepository(string databaseName)
{
- databaseFilename = Path.Combine(PettingZooPaths.AppDataRoot, $"{databaseName}.litedb");
+ databaseFilename = Path.Combine(PettingZooPaths.DatabasePath, $"{databaseName}.litedb");
}
diff --git a/PettingZoo.Settings.LiteDB/PettingZoo.Settings.LiteDB.csproj b/PettingZoo.Settings.LiteDB/PettingZoo.Settings.LiteDB.csproj
index d6532ad..f5fef95 100644
--- a/PettingZoo.Settings.LiteDB/PettingZoo.Settings.LiteDB.csproj
+++ b/PettingZoo.Settings.LiteDB/PettingZoo.Settings.LiteDB.csproj
@@ -9,6 +9,7 @@
+
diff --git a/PettingZoo.Tapeti/AssemblyParser/AssemblyParser.cs b/PettingZoo.Tapeti/AssemblyParser/AssemblyParser.cs
index 6adb833..b7a5072 100644
--- a/PettingZoo.Tapeti/AssemblyParser/AssemblyParser.cs
+++ b/PettingZoo.Tapeti/AssemblyParser/AssemblyParser.cs
@@ -2,37 +2,37 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Reflection;
-using System.Runtime.InteropServices;
+using System.Runtime.Loader;
using Newtonsoft.Json;
using PettingZoo.Core.Generator;
-using Tapeti.DataAnnotations.Extensions;
namespace PettingZoo.Tapeti.AssemblyParser
{
public class AssemblyParser : IDisposable
{
- private readonly MetadataLoadContext loadContext;
+ private readonly AssemblyLoadContext loadContext;
- public AssemblyParser(params string[] extraAssemblies)
+ public AssemblyParser(params string[] extraAssembliesPaths)
{
- var runtimeAssemblies = Directory.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(), "*.dll");
- var paths = runtimeAssemblies
- .Concat(extraAssemblies)
+ // Using the MetadataLoadContext introduces extra complexity since types can not be compared
+ // (a string from the loaded assembly does not equal our typeof(string) for example).
+ // So instead we'll use a regular AssemblyLoadContext. Not ideal, and will probably cause other side-effects
+ // if we're not careful, but I don't feel like writing a full metadata parser right now.
+ // If you have a better idea, it's open-source! :-)
+ loadContext = new AssemblyLoadContext(null, true);
- // TODO find a cleaner way
- .Append(typeof(JsonSerializer).Assembly.Location)
- .Append(typeof(RequiredGuidAttribute).Assembly.Location);
-
-
- var resolver = new PathAssemblyResolver(paths);
- loadContext = new MetadataLoadContext(resolver);
+ foreach (var extraAssembly in extraAssembliesPaths.SelectMany(p => Directory.Exists(p)
+ ? Directory.GetFiles(p, "*.dll")
+ : Enumerable.Empty()))
+ {
+ loadContext.LoadFromAssemblyPath(extraAssembly);
+ }
}
public void Dispose()
{
- loadContext.Dispose();
+ loadContext.Unload();
GC.SuppressFinalize(this);
}
diff --git a/PettingZoo.Tapeti/NuGet/INuGetPackageManager.cs b/PettingZoo.Tapeti/NuGet/INuGetPackageManager.cs
index 9ac0f22..a7a7880 100644
--- a/PettingZoo.Tapeti/NuGet/INuGetPackageManager.cs
+++ b/PettingZoo.Tapeti/NuGet/INuGetPackageManager.cs
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
namespace PettingZoo.Tapeti.NuGet
{
- // TODO support logger
public interface INuGetPackageManager
{
public IReadOnlyList Sources { get; }
@@ -36,7 +35,6 @@ namespace PettingZoo.Tapeti.NuGet
{
public string Version { get; }
- // TODO support fetching dependencies
public Task Download(Stream destination, CancellationToken cancellationToken);
}
}
diff --git a/PettingZoo.Tapeti/NuGet/NuGetPackageManager.cs b/PettingZoo.Tapeti/NuGet/NuGetPackageManager.cs
index f618dc2..def5e42 100644
--- a/PettingZoo.Tapeti/NuGet/NuGetPackageManager.cs
+++ b/PettingZoo.Tapeti/NuGet/NuGetPackageManager.cs
@@ -9,23 +9,28 @@ using NuGet.Common;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
+using ILogger = Serilog.ILogger;
namespace PettingZoo.Tapeti.NuGet
{
public class NuGetPackageManager : INuGetPackageManager
{
+ private const string NuGetDefaultSource = @"https://api.nuget.org/v3/index.json";
+
+ private readonly ILogger logger;
private readonly SourceCacheContext cache;
private readonly List