Skip to content

Commit

Permalink
Merge pull request #45 from espertechinc/hotfix-8.5.7
Browse files Browse the repository at this point in the history
Addressing compile & runtime issues for plugin-style assemblies
  • Loading branch information
bernhardttom authored Aug 9, 2023
2 parents f72bd0e + f961535 commit 3d62d5e
Show file tree
Hide file tree
Showing 69 changed files with 435 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- run: dotnet restore NEsperAll.sln
- run: msbuild NEsper.proj
- store_artifacts:
path: build/NEsper-8.5.6.zip
path: build/NEsper-8.5.7.zip
- store_artifacts:
path: build/packages
7 changes: 6 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix Condition="'$(VersionPrefix)' == ''">8.5.6</VersionPrefix>
<VersionPrefix Condition="'$(VersionPrefix)' == ''">8.5.7</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
</PropertyGroup>

Expand Down Expand Up @@ -46,6 +46,11 @@
<DefineConstants>$(DefineConstants);NETCORE;</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net7.0'">
<NetCore>true</NetCore>
<DefineConstants>$(DefineConstants);NETCORE;NET5;NET6;NET7;</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net6.0'">
<NetCore>true</NetCore>
<DefineConstants>$(DefineConstants);NETCORE;NET5;NET6;</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion NEsper.Documentation/NEsper.Documentation.shfbproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Name>NEsper.Documentation</Name>
<!-- SHFB properties -->
<FrameworkVersion>.NET Framework 4.6.2</FrameworkVersion>
<OutputPath>..\build\NEsper-8.5.6\docs\</OutputPath>
<OutputPath>..\build\NEsper-8.5.7\docs\</OutputPath>
<HtmlHelpName>NEsper</HtmlHelpName>
<Language>en-US</Language>
<TransformComponentArguments>
Expand Down
4 changes: 2 additions & 2 deletions NEsper.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NEsper</id>
<version>8.5.6</version>
<version>8.5.7</version>
<authors>EsperTech</authors>
<owners>EsperTech</owners>
<language>en-us</language>
Expand All @@ -27,7 +27,7 @@
</metadata>

<files>
<file src="build\NEsper-8.5.6\lib\**" target="lib\{framework name}[{version}]" />
<file src="build\NEsper-8.5.7\lib\**" target="lib\{framework name}[{version}]" />
</files>
</package>

2 changes: 1 addition & 1 deletion NEsper.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<SolutionDir>$(MSBuildProjectDirectory)</SolutionDir>
<!-- Distribution version -->
<Version Condition=" '$(CCNetLabel)' != '' ">$(CCNetLabel)</Version>
<Version Condition=" '$(Version)' == '' ">8.5.6</Version>
<Version Condition=" '$(Version)' == '' ">8.5.7</Version>

<!-- Build Directories -->
<BuildPath>$(MSBuildProjectDirectory)\build</BuildPath>
Expand Down
2 changes: 1 addition & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
variables:
MASTER_PROJECT: .\NEsper.proj
PACKAGE_DIRECTORY: .\packages
VERSION: 8.5.6
VERSION: 8.5.7

phases:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
using com.espertech.esper.compat.function;
using com.espertech.esper.compat.logging;

#if NETCORE
#if NETCOREAPP3_0_OR_GREATER
using System.Reflection;
using System.Runtime.Loader;
#endif

namespace com.espertech.esper.common.client.artifact
{
#if NETCORE
#if NETCOREAPP3_0_OR_GREATER
public class ArtifactRepositoryAssemblyLoadContext : BaseArtifactRepository, IDisposable
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

private AssemblyLoadContext _assemblyLoadContext;
private TypeResolver _typeResolver;
private readonly TypeResolver _typeResolver;

/// <summary>
/// Returns the assembly load context
Expand All @@ -34,10 +34,14 @@ public class ArtifactRepositoryAssemblyLoadContext : BaseArtifactRepository, IDi
/// Constructor.
/// </summary>
/// <param name="parentTypeResolver"></param>
public ArtifactRepositoryAssemblyLoadContext(TypeResolver parentTypeResolver)
/// <param name="assemblyResolver"></param>
public ArtifactRepositoryAssemblyLoadContext(
TypeResolver parentTypeResolver,
AssemblyResolver assemblyResolver)
{
_assemblyLoadContext = CreateAssemblyLoadContext(
this,
assemblyResolver,
"default-artifact-repository-assembly-load-context",
true);
_typeResolver = new ArtifactTypeResolver(this, parentTypeResolver);
Expand All @@ -48,12 +52,15 @@ public ArtifactRepositoryAssemblyLoadContext(TypeResolver parentTypeResolver)
/// </summary>
/// <param name="deploymentId"></param>
/// <param name="parentTypeResolver"></param>
/// <param name="assemblyResolver"></param>
public ArtifactRepositoryAssemblyLoadContext(
string deploymentId,
TypeResolver parentTypeResolver)
TypeResolver parentTypeResolver,
AssemblyResolver assemblyResolver)
{
_assemblyLoadContext = CreateAssemblyLoadContext(
this,
assemblyResolver,
"artifact-repository-assembly-load-context-" + deploymentId,
true);
_typeResolver = new ArtifactTypeResolver(this, parentTypeResolver);
Expand Down Expand Up @@ -93,6 +100,7 @@ protected override Supplier<Assembly> MaterializeAssemblySupplier(byte[] image)

public static AssemblyLoadContext CreateAssemblyLoadContext(
IArtifactRepository repository,
AssemblyResolver assemblyResolver,
string contextName,
bool isCollectable)
{
Expand All @@ -105,6 +113,10 @@ public static AssemblyLoadContext CreateAssemblyLoadContext(
var assemblyBaseName = assemblyName.Name;
var artifact = repositoryInstance.Resolve(assemblyBaseName);
var assembly = artifact?.Assembly;
if (assembly == null) {
assembly = assemblyResolver?.Invoke(assemblyName);
}
return assembly;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using com.espertech.esper.compat;
using com.espertech.esper.compat.collections;

#if NETCORE
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;
#endif

Expand Down Expand Up @@ -32,10 +32,10 @@ public static IArtifactRepositoryManager GetDefaultArtifactRepositoryManager(ICo
var baseTypeResolver = container.Has<TypeResolver>()
? container.Resolve<TypeResolver>()
: TypeResolverDefault.INSTANCE;
return new DefaultArtifactRepositoryManager(baseTypeResolver);
var assemblyResolver = container.Has<AssemblyResolver>()
? container.Resolve<AssemblyResolver>()
: null;
return new DefaultArtifactRepositoryManager(baseTypeResolver, assemblyResolver);
}

#if NETCORE
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

using Microsoft.CodeAnalysis;

#if NETCORE
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

using com.espertech.esper.compat;

#if NETCORE
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;
#endif

using com.espertech.esper.compat.collections;
using com.espertech.esper.compat.logging;
using com.espertech.esper.container;

namespace com.espertech.esper.common.client.artifact
{
Expand All @@ -21,14 +19,23 @@ public class DefaultArtifactRepositoryManager : IArtifactRepositoryManager, IDis

private readonly IDictionary<string, IArtifactRepository> _repositoryTable;
private readonly TypeResolver _parentTypeResolver;
private readonly AssemblyResolver _assemblyResolver;

#if NETCOREAPP3_0_OR_GREATER
public DefaultArtifactRepositoryManager(
TypeResolver parentTypeResolver,
AssemblyResolver assemblyResolver)
#else
public DefaultArtifactRepositoryManager(TypeResolver parentTypeResolver)
#endif
{
_parentTypeResolver = parentTypeResolver;
_assemblyResolver = assemblyResolver;
_repositoryTable = new Dictionary<string, IArtifactRepository>();

#if NETCORE
DefaultRepository = new ArtifactRepositoryAssemblyLoadContext(_parentTypeResolver);

#if NETCOREAPP3_0_OR_GREATER
DefaultRepository = new ArtifactRepositoryAssemblyLoadContext(
_parentTypeResolver, _assemblyResolver);
#else
DefaultRepository = new ArtifactRepositoryAppDomain(AppDomain.CurrentDomain);
#endif
Expand Down Expand Up @@ -66,8 +73,11 @@ public IArtifactRepository GetArtifactRepository(string deploymentId, bool creat
{
lock (_repositoryTable) {
if (!_repositoryTable.TryGetValue(deploymentId, out var artifactRepository) && createIfMissing) {
#if NETCORE
artifactRepository = new ArtifactRepositoryAssemblyLoadContext(deploymentId, _parentTypeResolver);
#if NETCOREAPP3_0_OR_GREATER
artifactRepository = new ArtifactRepositoryAssemblyLoadContext(
deploymentId,
_parentTypeResolver,
_assemblyResolver);
#else
artifactRepository = new ArtifactRepositoryAppDomain(AppDomain.CurrentDomain);
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;

using com.espertech.esper.common.@internal.util;
using com.espertech.esper.compat;
using com.espertech.esper.compat.collections;

#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;
#endif

using com.espertech.esper.container;

using Microsoft.CodeAnalysis;

namespace com.espertech.esper.common.client.artifact
{
public delegate IEnumerable<MetadataReference> MetadataReferenceProvider();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;

using com.espertech.esper.common.@internal.util;
using com.espertech.esper.compat;
using com.espertech.esper.compat.collections;

#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;
#endif

using com.espertech.esper.container;

using Microsoft.CodeAnalysis;

namespace com.espertech.esper.common.client.artifact
{
public static class MetadataReferenceProviderExtensions
{
public static MetadataReferenceProvider MetadataReferenceProvider(this IContainer container)
{
container.CheckContainer();

lock (container) {
if (container.DoesNotHave<MetadataReferenceProvider>()) {
container.Register<MetadataReferenceProvider>(Array.Empty<MetadataReference>, Lifespan.Singleton);
}
}

return container.Resolve<MetadataReferenceProvider>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Reflection;

using com.espertech.esper.common.@internal.util;
using com.espertech.esper.compat;
using com.espertech.esper.compat.collections;

#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;
#endif

using com.espertech.esper.container;

using Microsoft.CodeAnalysis;

namespace com.espertech.esper.common.client.artifact
{
public delegate MetadataReference MetadataReferenceResolver(Assembly assembly);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Reflection;

using com.espertech.esper.container;

using Microsoft.CodeAnalysis;

namespace com.espertech.esper.common.client.artifact
{
public static class MetadataReferenceResolverExtensions
{
/// <summary>
/// Gets a metadata reference from an assembly. This method provides no caching of the metadata
/// reference.
/// </summary>
/// <param name="assembly"></param>
/// <returns>a metadata reference for the requested assembly</returns>
public static MetadataReference GetMetadataReference(Assembly assembly)
{
return string.IsNullOrEmpty(assembly.Location) ? null : MetadataReference.CreateFromFile(assembly.Location);
}

/// <summary>
/// Retrieves an instance of the MetadataReferenceResolver. If none has been registered, this method
/// will return the default resolver.
/// </summary>
/// <param name="container"></param>
/// <returns></returns>
public static MetadataReferenceResolver MetadataReferenceResolver(this IContainer container)
{
container.CheckContainer();

lock (container) {
if (container.DoesNotHave<MetadataReferenceResolver>()) {
return GetMetadataReference;
}
}

return container.Resolve<MetadataReferenceResolver>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public ConfigurationCompiler()
/// <summary>
/// Returns true if the compiler should set optimization to debug.
/// </summary>
public bool IsDebugOptimization { get; private set; }
public bool IsDebugOptimization { get; set; }

/// <summary>
/// Returns the expression-related settings for compiler.
Expand Down
Loading

0 comments on commit 3d62d5e

Please sign in to comment.