Skip to content

Commit

Permalink
Merge branch 'release/5.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Sep 21, 2024
2 parents 494b6f0 + c85168e commit 48f8734
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 38 deletions.
4 changes: 2 additions & 2 deletions deployment/cake/lib-msbuild.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#addin "nuget:?package=Cake.Issues&version=4.10.0"
#addin "nuget:?package=Cake.Issues.MsBuild&version=4.10.0"
#addin "nuget:?package=Cake.Issues&version=4.10.1"
#addin "nuget:?package=Cake.Issues.MsBuild&version=4.10.1"
#addin "nuget:?package=System.Configuration.ConfigurationManager&version=8.0.0"

#tool "nuget:?package=MSBuild.Extension.Pack&version=1.9.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="Catel.MVVM" Version="6.0.3" />
<PackageReference Include="Catel.Fody" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all">
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="ModuleInit.Fody" Version="2.1.1" PrivateAssets="all" />
Expand Down
11 changes: 11 additions & 0 deletions src/Orc.Extensibility.Example.ExtensionA/FodyWeavers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
<Catel />
<Costura>
<IncludeAssemblies>
Azure.* <!-- required for Microsoft.Data.SqlClient -->
EntityFramework
EntityFramework.SqlServer
Microsoft.Identity.Client*
Microsoft.SqlServer.*
Newtonsoft.Json
Orc.Metadata
Orc.Search
Orc.Search.Xaml
YamlDotNet
</IncludeAssemblies>
<IncludeRuntimeAssemblies>
Microsoft.Data.SqlClient
Microsoft.Data.SqlClient.SNI
System.Data.SqlClient
sni
</IncludeRuntimeAssemblies>
</Costura>
<LoadAssembliesOnStartup>
<IncludeAssemblies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
<ItemGroup>
<PackageReference Include="Catel.MVVM" Version="6.0.3" />
<PackageReference Include="Catel.Fody" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all">
<PackageReference Include="Costura.Fody" Version="6.0.0-alpha0384" PrivateAssets="all" />
<PackageReference Include="EntityFramework" Version="6.5.1" />
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="LoadAssembliesOnStartup.Fody" Version="4.6.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" PrivateAssets="all" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.1" PrivateAssets="all" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" PrivateAssets="all" />
<PackageReference Include="Orc.Controls" Version="5.0.5" />
<PackageReference Include="Orc.Search.Xaml" Version="5.0.0" />
<PackageReference Include="Orchestra.Core" Version="7.0.1" />
<PackageReference Include="YamlDotNet" Version="16.0.0" PrivateAssets="all" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="YamlDotNet" Version="16.1.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 20 additions & 0 deletions src/Orc.Extensibility.Example.ExtensionA/Plugins/PluginA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ public async Task InitializeAsync()
var value = _languageService.GetRequiredString("TestResource");

Log.Info($"{typeof(YamlDotNet.Core.AnchorName).FullName}");
Log.Info($"{typeof(System.Data.SqlClient.SqlClientFactory).FullName}");
Log.Info($"{typeof(Microsoft.Data.SqlClient.SqlClientFactory).FullName}");
Log.Info($"{typeof(Microsoft.Data.SqlClient.SqlConnection).FullName}");

try
{
var connectionString = ".\\SQLExpress";

System.Data.Entity.Database.Exists(connectionString);

//using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
//{
// await connection.OpenAsync();
//}
}
catch
{
// Ignore
Log.Error("Failed to open database connection");
}

await _messageService.ShowAsync($"Plugin A has been loaded, setting color to red. Resource value: '{value}'");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<ItemGroup>
<PackageReference Include="Catel.MVVM" Version="6.0.3" />
<PackageReference Include="Catel.Fody" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all">
<PackageReference Include="Costura.Fody" Version="6.0.0-alpha0384" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="LoadAssembliesOnStartup.Fody" Version="4.6.0" PrivateAssets="all" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Catel.MVVM" Version="6.0.3" />
<PackageReference Include="Catel.Fody" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all">
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="LoadAssembliesOnStartup.Fody" Version="4.6.0" PrivateAssets="all" />
Expand Down
11 changes: 6 additions & 5 deletions src/Orc.Extensibility.Tests/Orc.Extensibility.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@

<ItemGroup>
<PackageReference Include="Catel.Fody" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all">
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.1" PrivateAssets="all" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.1.0" PrivateAssets="all" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="4.2.2" PrivateAssets="all" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" PrivateAssets="all" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" PrivateAssets="all" />
<PackageReference Include="Verify.NUnit" Version="26.2.0" />
<PackageReference Include="Verify.NUnit" Version="26.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ namespace Orc.Extensibility
public class RuntimeAssemblyResolverService : Orc.Extensibility.IRuntimeAssemblyResolverService
{
public RuntimeAssemblyResolverService(Orc.FileSystem.IFileService fileService, Orc.FileSystem.IDirectoryService directoryService, Orc.Extensibility.IAssemblyReflectionService assemblyReflectionService, Catel.Services.IAppDataService appDataService) { }
protected virtual System.Threading.Tasks.Task<System.Collections.Generic.List<Orc.Extensibility.ICosturaRuntimeAssembly>?> FindEmbeddedAssembliesViaMetadataAsync(System.Collections.Generic.IEnumerable<Orc.Extensibility.EmbeddedResource> resources) { }
protected virtual System.Threading.Tasks.Task<System.Collections.Generic.List<Orc.Extensibility.ICosturaRuntimeAssembly>?> FindEmbeddedAssembliesViaCosturaMetadataAsync(System.Collections.Generic.IEnumerable<Orc.Extensibility.EmbeddedResource> resources) { }
protected System.Threading.Tasks.Task<System.Collections.Generic.List<Orc.Extensibility.EmbeddedResource>> FindEmbeddedResourcesAsync(System.Reflection.PortableExecutable.PEReader peReader, Orc.Extensibility.IRuntimeAssembly containerAssembly) { }
public Orc.Extensibility.IPluginLoadContext[] GetPluginLoadContexts() { }
protected virtual System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Orc.Extensibility.IRuntimeAssembly>> IndexCosturaEmbeddedAssembliesAsync(Orc.Extensibility.IPluginLoadContext pluginLoadContext, Orc.Extensibility.IRuntimeAssembly? originatingAssembly, Orc.Extensibility.IRuntimeAssembly runtimeAssembly) { }
protected virtual System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Orc.Extensibility.IRuntimeAssembly>> IndexCosturaClassicEmbeddedAssembliesAsync(Orc.Extensibility.IPluginLoadContext pluginLoadContext, Orc.Extensibility.IRuntimeAssembly? originatingAssembly, Orc.Extensibility.IRuntimeAssembly runtimeAssembly) { }
public System.Threading.Tasks.Task RegisterAssemblyAsync(Orc.Extensibility.IRuntimeAssembly runtimeAssembly) { }
protected System.Threading.Tasks.Task RegisterAssemblyAsync(Orc.Extensibility.IPluginLoadContext pluginLoadContext, Orc.Extensibility.IRuntimeAssembly? originatingAssembly, Orc.Extensibility.IRuntimeAssembly runtimeAssembly) { }
protected virtual bool ShouldIgnoreAssemblyForCosturaExtracting(Orc.Extensibility.IPluginLoadContext pluginLoadContext, Orc.Extensibility.IRuntimeAssembly? originatingAssembly, Orc.Extensibility.IRuntimeAssembly runtimeAssembly) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ static PlatformInformation()
NativeLibraryPrefixes = new[] { string.Empty };
NativeLibraryExtensions = new[] { ".dll" };

// For now we only care about windows
runtimeIdentifiers.Add($"win-{RuntimeInformation.OSArchitecture.ToString().ToLower()}");
var runtimeIdentifier = RuntimeInformation.RuntimeIdentifier;
var osArchitecture = RuntimeInformation.OSArchitecture.ToString();

Log.Debug($"OS Architecture: {osArchitecture}");
Log.Debug($"Runtime identifier: {runtimeIdentifier}");

// Note that we need to respect the process, not the OS
runtimeIdentifiers.Add(runtimeIdentifier);
//runtimeIdentifiers.Add($"win-{osArchitecture.ToLower()}");
runtimeIdentifiers.Add("win");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Expand All @@ -55,4 +62,4 @@ static PlatformInformation()

RuntimeIdentifiers = runtimeIdentifiers.ToArray();
}
}
}
6 changes: 3 additions & 3 deletions src/Orc.Extensibility/Orc.Extensibility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Catel.Fody" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all">
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="MethodTimer.Fody" Version="3.2.2" PrivateAssets="all" />
Expand All @@ -28,11 +28,11 @@
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0')) ">
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="6.0.*" />
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('net8.0')) ">
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.*" />
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
</ItemGroup>

<Import Project="$(MSBuildProjectDirectory)\..\Directory.build.nullable.props" Condition="Exists('$(MSBuildProjectDirectory)\..\Directory.build.nullable.props')" />
Expand Down
29 changes: 13 additions & 16 deletions src/Orc.Extensibility/Services/RuntimeAssemblyResolverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@

using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Reflection;
using Catel.Logging;
using Orc.FileSystem;
using Catel.Services;
using System.Reflection.Metadata;
using Catel;
using MethodTimer;
using Catel.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

public partial class RuntimeAssemblyResolverService : IRuntimeAssemblyResolverService
{
Expand Down Expand Up @@ -86,12 +81,12 @@ public async Task UnregisterAssemblyAsync(IRuntimeAssembly runtimeAssembly)

protected async Task RegisterAssemblyAsync(IPluginLoadContext pluginLoadContext, IRuntimeAssembly? originatingAssembly, IRuntimeAssembly runtimeAssembly)
{
var assemblies = await IndexCosturaEmbeddedAssembliesAsync(pluginLoadContext, originatingAssembly, runtimeAssembly);
var assemblies = await IndexCosturaClassicEmbeddedAssembliesAsync(pluginLoadContext, originatingAssembly, runtimeAssembly);
pluginLoadContext.RuntimeAssemblies.AddRange(assemblies);
}

[Time("{runtimeAssembly}")]
protected virtual async Task<IEnumerable<IRuntimeAssembly>> IndexCosturaEmbeddedAssembliesAsync(IPluginLoadContext pluginLoadContext, IRuntimeAssembly? originatingAssembly, IRuntimeAssembly runtimeAssembly)
protected virtual async Task<IEnumerable<IRuntimeAssembly>> IndexCosturaClassicEmbeddedAssembliesAsync(IPluginLoadContext pluginLoadContext, IRuntimeAssembly? originatingAssembly, IRuntimeAssembly runtimeAssembly)
{
// Ignore specific assemblies
if (ShouldIgnoreAssemblyForCosturaExtracting(pluginLoadContext, originatingAssembly, runtimeAssembly))
Expand Down Expand Up @@ -119,7 +114,7 @@ protected virtual async Task<IEnumerable<IRuntimeAssembly>> IndexCosturaEmbedded
var embeddedResources = await FindEmbeddedResourcesAsync(peReader, runtimeAssembly);
if (embeddedResources.Count > 0)
{
var costuraEmbeddedAssembliesFromMetadata = await FindEmbeddedAssembliesViaMetadataAsync(embeddedResources);
var costuraEmbeddedAssembliesFromMetadata = await FindEmbeddedAssembliesViaCosturaMetadataAsync(embeddedResources);
if (costuraEmbeddedAssembliesFromMetadata is null)
{
Log.Error($"Files are embedded with an older version of Costura (< 5.x). It's required to update so metadata is embedded by Costura");
Expand All @@ -132,6 +127,8 @@ protected virtual async Task<IEnumerable<IRuntimeAssembly>> IndexCosturaEmbedded
if (costuraEmbeddedAssembly.IsRuntime)
{
// Check if correct platform
//RuntimeInformation.RuntimeIdentifier

if (!PlatformInformation.RuntimeIdentifiers.Any(x => costuraEmbeddedAssembly.RelativeFileName.ContainsIgnoreCase($"/{x}/")))
{
Log.Debug($"Ignoring '{costuraEmbeddedAssembly}' since it's not applicable to the current platform");
Expand Down Expand Up @@ -167,7 +164,7 @@ protected virtual async Task<IEnumerable<IRuntimeAssembly>> IndexCosturaEmbedded
indexedCosturaAssemblies.Add(costuraEmbeddedAssembly);

// Recursive indexing
var recursiveRuntimeAssemblies = await IndexCosturaEmbeddedAssembliesAsync(pluginLoadContext, originatingAssembly, costuraEmbeddedAssembly);
var recursiveRuntimeAssemblies = await IndexCosturaClassicEmbeddedAssembliesAsync(pluginLoadContext, originatingAssembly, costuraEmbeddedAssembly);
if (recursiveRuntimeAssemblies.Any())
{
indexedCosturaAssemblies.AddRange(recursiveRuntimeAssemblies);
Expand Down Expand Up @@ -288,11 +285,11 @@ protected async Task<List<EmbeddedResource>> FindEmbeddedResourcesAsync(PEReader
return embeddedResources;
}

protected virtual async Task<List<ICosturaRuntimeAssembly>?> FindEmbeddedAssembliesViaMetadataAsync(IEnumerable<EmbeddedResource> resources)
protected virtual async Task<List<ICosturaRuntimeAssembly>?> FindEmbeddedAssembliesViaCosturaMetadataAsync(IEnumerable<EmbeddedResource> resources)
{
var metadataResource = (from x in resources
where x.Name.EqualsIgnoreCase("costura.metadata")
select x).FirstOrDefault();
where x.Name.EqualsIgnoreCase("costura.metadata")
select x).FirstOrDefault();
if (metadataResource is null)
{
// Not found, return null
Expand All @@ -319,8 +316,8 @@ where x.Name.EqualsIgnoreCase("costura.metadata")
var costuraEmbeddedResource = new CosturaRuntimeAssembly(line);

var embeddedResource = (from x in resources
where x.Name == costuraEmbeddedResource.ResourceName
select x).FirstOrDefault();
where x.Name == costuraEmbeddedResource.ResourceName
select x).FirstOrDefault();
if (embeddedResource is null)
{
Log.Error($"Expected to find Costura embedded resource '{costuraEmbeddedResource.ResourceName}', but could not find it");
Expand All @@ -337,4 +334,4 @@ where x.Name.EqualsIgnoreCase("costura.metadata")

return embeddedResources;
}
}
}

0 comments on commit 48f8734

Please sign in to comment.