From c986cb85f26db7523e4a7fe43fdf459e0f402c10 Mon Sep 17 00:00:00 2001 From: agracio Date: Fri, 22 Nov 2024 23:01:24 +0000 Subject: [PATCH] merging .NET Core dependency resolution fix from Edge.js --- .github/workflows/build-all.yml | 2 +- .github/workflows/build.yml | 6 +- .github/workflows/main.yml | 2 +- package-lock.json | 18 +- package.json | 4 +- .../Edge.js/dotnetcore/coreclrembedding.cs | 227 ++++++++++-------- 6 files changed, 143 insertions(+), 116 deletions(-) diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index d3e515f..bce2b7f 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -79,7 +79,7 @@ jobs: - name: Electron versions shell: bash id: electron-test-versions - run: echo "matrix={'include':[{'electron':'29.4.6', 'os':'windows-2022'},{'electron':'30.5.1', 'os':'windows-2022'},{'electron':'31.7.3', 'os':'windows-2022'},{'electron':'32.2.2', 'os':'windows-2022'},{'electron':'33.1.0', 'os':'windows-2022'}]}" >> $GITHUB_OUTPUT + run: echo "matrix={'include':[{'electron':'29.4.6', 'os':'windows-2022'},{'electron':'30.5.1', 'os':'windows-2022'},{'electron':'31.7.5', 'os':'windows-2022'},{'electron':'32.2.5', 'os':'windows-2022'},{'electron':'33.2.0', 'os':'windows-2022'}]}" >> $GITHUB_OUTPUT test: strategy: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d40717..73e1b77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,11 +54,11 @@ jobs: elif [[ ${{ inputs.build-version }} == '30' ]]; then echo "test-version=30.5.1" >> $GITHUB_OUTPUT elif [[ ${{ inputs.build-version }} == '31' ]]; then - echo "test-version=31.7.2" >> $GITHUB_OUTPUT + echo "test-version=31.7.5" >> $GITHUB_OUTPUT elif [[ ${{ inputs.build-version }} == '32' ]]; then - echo "test-version=32.2.2" >> $GITHUB_OUTPUT + echo "test-version=32.2.5" >> $GITHUB_OUTPUT elif [[ ${{ inputs.build-version }} == '33' ]]; then - echo "test-version=33.0.2" >> $GITHUB_OUTPUT + echo "test-version=33.2.0" >> $GITHUB_OUTPUT fi - name: Setup env diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72c7154..88726a5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,7 +84,7 @@ jobs: os: [macos-13, macos-14, ubuntu-22.04, windows-2022] # os: [ macos-14, ubuntu-22.04] # electron: [32.1.2] - electron: [29.4.6, 30.5.1, 31.7.3, 32.2.2, 33.1.0] + electron: [29.4.6, 30.5.1, 31.7.5, 32.2.5, 33.2.0] # electron: [31.6.0, 32.1.0] name: test-${{ matrix.os }}-v${{ matrix.electron }} diff --git a/package-lock.json b/package-lock.json index ed959bc..69d4be8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "electron-edge-js", - "version": "33.0.2", + "version": "33.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "electron-edge-js", - "version": "33.0.2", + "version": "33.0.3", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -14,7 +14,7 @@ "nan": "^2.22.0" }, "devDependencies": { - "electron": "^33.1.0", + "electron": "^33.2.0", "follow-redirects": "^1.15.9", "mocha": "10.8.2", "mochawesome": "^7.1.3", @@ -522,9 +522,9 @@ } }, "node_modules/electron": { - "version": "33.1.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-33.1.0.tgz", - "integrity": "sha512-7KiY6MtRo1fVFLPGyHS7Inh8yZfrbUTy43nNwUgMD2CBk729BgSwOC2WhmcptNJVlzHJpVxSWkiVi2hp9mH/bw==", + "version": "33.2.0", + "resolved": "https://registry.npmjs.org/electron/-/electron-33.2.0.tgz", + "integrity": "sha512-PVw1ICAQDPsnnsmpNFX/b1i/49h67pbSPxuIENd9K9WpGO1tsRaQt+K2bmXqTuoMJsbzIc75Ce8zqtuwBPqawA==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -2635,9 +2635,9 @@ "integrity": "sha512-sFwGCGmoa9JdODegeDFJL4IH6N8IgDobxbS31BiXaiOdf8bC7EyHigFp0WYRKhIgK72E9nLnNwiRJRMO/AYGdg==" }, "electron": { - "version": "33.1.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-33.1.0.tgz", - "integrity": "sha512-7KiY6MtRo1fVFLPGyHS7Inh8yZfrbUTy43nNwUgMD2CBk729BgSwOC2WhmcptNJVlzHJpVxSWkiVi2hp9mH/bw==", + "version": "33.2.0", + "resolved": "https://registry.npmjs.org/electron/-/electron-33.2.0.tgz", + "integrity": "sha512-PVw1ICAQDPsnnsmpNFX/b1i/49h67pbSPxuIENd9K9WpGO1tsRaQt+K2bmXqTuoMJsbzIc75Ce8zqtuwBPqawA==", "dev": true, "requires": { "@electron/get": "^2.0.0", diff --git a/package.json b/package.json index a5d4926..b17434e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "url": "http://tomasz.janczuk.org", "twitter": "tjanczuk" }, - "version": "33.0.2", + "version": "33.0.3", "description": "Edge.js: run .NET and Node.js in-process on Electron", "tags": [ "owin", @@ -45,7 +45,7 @@ "nan": "^2.22.0" }, "devDependencies": { - "electron": "^33.1.0", + "electron": "^33.2.0", "follow-redirects": "^1.15.9", "mocha": "10.8.2", "mochawesome": "^7.1.3", diff --git a/src/double/Edge.js/dotnetcore/coreclrembedding.cs b/src/double/Edge.js/dotnetcore/coreclrembedding.cs index ed6eb2f..b7cc41f 100644 --- a/src/double/Edge.js/dotnetcore/coreclrembedding.cs +++ b/src/double/Edge.js/dotnetcore/coreclrembedding.cs @@ -12,10 +12,11 @@ using System.Threading.Tasks; using System.IO; using Microsoft.Extensions.DependencyModel; + // ReSharper disable InconsistentNaming +// ReSharper disable once CheckNamespace [StructLayout(LayoutKind.Sequential)] -// ReSharper disable once CheckNamespace public struct V8ObjectData { public int propertiesCount; @@ -95,6 +96,10 @@ public EdgeRuntimeEnvironment(EdgeBootstrapperContext bootstrapperContext) RuntimePath = bootstrapperContext.RuntimeDirectory; DependencyManifestFile = bootstrapperContext.DependencyManifestFile; StandaloneApplication = Path.GetDirectoryName(RuntimePath) == ApplicationDirectory; + DebugMessage("EdgeRuntimeEnvironment::ctor (CLR) - ApplicationDirectory {0}", ApplicationDirectory); + DebugMessage("EdgeRuntimeEnvironment::ctor (CLR) - RuntimePath {0}", RuntimePath); + DebugMessage("EdgeRuntimeEnvironment::ctor (CLR) - DependencyManifestFile {0}", DependencyManifestFile); + DebugMessage("EdgeRuntimeEnvironment::ctor (CLR) - StandaloneApplication {0}", StandaloneApplication); } public string RuntimePath @@ -150,7 +155,7 @@ protected override Assembly Load(AssemblyName assemblyName) try { DebugMessage("EdgeAssemblyLoadContext::Load (CLR) - Trying to load from {0}", assemblyPath); - Assembly assembly = LoadFromAssemblyPath(assemblyPath); + Assembly assembly = Default.LoadFromAssemblyPath(assemblyPath); if (assembly != null) { @@ -244,7 +249,6 @@ private void AddDependencies(DependencyContext dependencyContext, bool standalon AddCompileDependencies(dependencyContext, standalone); - Dictionary supplementaryRuntimeLibraries = new Dictionary(); var runtimePath = Path.GetDirectoryName(RuntimeEnvironment.RuntimePath); foreach (RuntimeLibrary runtimeLibrary in dependencyContext.RuntimeLibraries) @@ -263,7 +267,6 @@ private void AddDependencies(DependencyContext dependencyContext, bool standalon AddSupplementaryRuntime(runtimeLibrary); continue; } - List assets = runtimeLibrary.RuntimeAssemblyGroups.GetRuntimeAssets(RuntimeInformation.RuntimeIdentifier).ToList(); @@ -286,6 +289,7 @@ private void AddDependencies(DependencyContext dependencyContext, bool standalon assemblyPath = Path.Combine(_packagesPath, runtimeLibrary.Name.ToLower(), runtimeLibrary.Version, assetPath.Replace('/', Path.DirectorySeparatorChar).ToLower()); if(!File.Exists(assemblyPath)) assemblyPath = Path.Combine(_packagesPath, runtimeLibrary.Name.ToLower(), runtimeLibrary.Version, assetPath.Replace('/', Path.DirectorySeparatorChar)); + } string libraryNameFromPath = Path.GetFileNameWithoutExtension(assemblyPath); @@ -300,71 +304,29 @@ private void AddDependencies(DependencyContext dependencyContext, bool standalon { _libraries[runtimeLibrary.Name] = assemblyPath; DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added runtime assembly {1} from {0}", assemblyPath, runtimeLibrary.Name); + CompileAssemblies.TryAdd(runtimeLibrary.Name, assemblyPath); + if (!string.Equals(runtimeLibrary.Name, libraryNameFromPath, StringComparison.CurrentCultureIgnoreCase)) + { + _libraries.TryAdd(libraryNameFromPath, assemblyPath); + CompileAssemblies.TryAdd(libraryNameFromPath, assemblyPath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added supplementary runtime assembly {1} from {0}", assemblyPath, libraryNameFromPath); + } } else { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not resolve runtime assembly {0}", - assemblyPath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not resolve runtime assembly {0}", assemblyPath); } } - else { DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Already present in the runtime assemblies list, skipping"); } - - if (runtimeLibrary.Name != libraryNameFromPath && !_libraries.ContainsKey(libraryNameFromPath)) - { - if (File.Exists(assemblyPath)) - { - supplementaryRuntimeLibraries[libraryNameFromPath] = assemblyPath; - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added supplementary runtime assembly {1} from {0}", assemblyPath, libraryNameFromPath); - } - else - { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not resolve supplementary runtime assembly {0}", - assemblyPath); - } - } - - if (!CompileAssemblies.ContainsKey(runtimeLibrary.Name)) - { - if (File.Exists(assemblyPath)) - { - CompileAssemblies[runtimeLibrary.Name] = assemblyPath; - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added compile assembly {1} from {0}", assemblyPath, runtimeLibrary.Name); - } - else - { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not resolve compile assembly {0}", assemblyPath); - } - } - - else - { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Already present in the compile assemblies list, skipping"); - } } else { DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - RuntimeAssemblyGroups does not have RuntimeAssets or DefaultAssets"); - if (!CompileAssemblies.ContainsKey(runtimeLibrary.Name)) AddCompileDependencyFromRuntime(runtimeLibrary); - } - - foreach (string libraryName in supplementaryRuntimeLibraries.Keys) - { - if (!_libraries.ContainsKey(libraryName)) - { - DebugMessage( - "EdgeAssemblyResolver::AddDependencies (CLR) - Filename in the dependency context did not match the package/project name, added additional resolver for {0}", - libraryName); - _libraries[libraryName] = supplementaryRuntimeLibraries[libraryName]; - } - - if (!CompileAssemblies.ContainsKey(libraryName)) - { - CompileAssemblies[libraryName] = supplementaryRuntimeLibraries[libraryName]; - } + if (!CompileAssemblies.ContainsKey(runtimeLibrary.Name) || !_libraries.ContainsKey(runtimeLibrary.Name)) AddDependencyFromRuntime(runtimeLibrary); + if (!CompileAssemblies.ContainsKey(runtimeLibrary.Name) || !_libraries.ContainsKey(runtimeLibrary.Name)) AddDependencyFromAppDirectory(runtimeLibrary); } AddNativeAssemblies(dependencyContext, runtimeLibrary); @@ -374,10 +336,11 @@ private void AddDependencies(DependencyContext dependencyContext, bool standalon private void AddSupplementaryRuntime(RuntimeLibrary runtimeLibrary) { var libraryNameFromPath = Path.GetFileNameWithoutExtension(_libraries[runtimeLibrary.Name]); - if (runtimeLibrary.Name != libraryNameFromPath) + if (!string.Equals(runtimeLibrary.Name, libraryNameFromPath, StringComparison.CurrentCultureIgnoreCase)) { _libraries.TryAdd(libraryNameFromPath, _libraries[runtimeLibrary.Name]); CompileAssemblies.TryAdd(libraryNameFromPath, _libraries[runtimeLibrary.Name]); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added supplementary runtime assembly {1} from {0}", _libraries[runtimeLibrary.Name], libraryNameFromPath); } } @@ -401,55 +364,108 @@ private void AddNativeAssemblies(DependencyContext dependencyContext, RuntimeLib if (File.Exists(nativeAssemblyPath)) { _nativeLibraries[Path.GetFileNameWithoutExtension(nativeAssembly)] = nativeAssemblyPath; - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Adding native assembly {0} at {1}", - Path.GetFileNameWithoutExtension(nativeAssembly), nativeAssemblyPath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Adding native assembly {0} at {1}", Path.GetFileNameWithoutExtension(nativeAssembly), nativeAssemblyPath); } else { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not resolve native assembly {0} at {1}", - Path.GetFileNameWithoutExtension(nativeAssembly), nativeAssemblyPath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not resolve native assembly {0} at {1}", Path.GetFileNameWithoutExtension(nativeAssembly), nativeAssemblyPath); } } } } - private void AddCompileDependencyFromRuntime(RuntimeLibrary runtimeLibrary) + private void AddDependencyFromRuntime(RuntimeLibrary runtimeLibrary) { + if (CompileAssemblies.ContainsKey(runtimeLibrary.Name) && _libraries.ContainsKey(runtimeLibrary.Name)) return; + var runtimePath = Path.GetDirectoryName(RuntimeEnvironment.RuntimePath); - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Processing compile dependency {1} {0} using runtime path {2}", runtimeLibrary.Name, runtimeLibrary.Type, runtimePath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Processing dependency {1} {0} using runtime path {2}", runtimeLibrary.Name, runtimeLibrary.Type, runtimePath); if (string.IsNullOrEmpty(runtimePath)) { DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - runtime path could not be resolved, skipping"); return; } + + var asset = runtimeLibrary.Name; + if (!asset.EndsWith(".dll") && !asset.EndsWith(".sni")) + { + asset += ".dll"; + } + + if (asset == "runtime.native.System.dll") + { + asset = "System.dll"; + } - if (!CompileAssemblies.ContainsKey(runtimeLibrary.Name)) + if (asset == "NETStandard.Library.dll") { - var asset = runtimeLibrary.Name; - if (!asset.EndsWith(".dll")) + asset = "netstandard.dll"; + } + + var assemblyPath = Path.Combine(runtimePath, Path.GetFileName(asset)); + if (File.Exists(assemblyPath)) + { + CompileAssemblies.TryAdd(runtimeLibrary.Name, assemblyPath); + _libraries.TryAdd(runtimeLibrary.Name, assemblyPath); + + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added dependency {1} from {0}", assemblyPath, runtimeLibrary.Name); + + var libraryNameFromPath = Path.GetFileNameWithoutExtension(assemblyPath); + if (!string.Equals(runtimeLibrary.Name, libraryNameFromPath, StringComparison.CurrentCultureIgnoreCase)) { - asset += ".dll"; + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added supplementary assembly {1} from {0}", assemblyPath, libraryNameFromPath); + CompileAssemblies.TryAdd(libraryNameFromPath, assemblyPath); + _libraries.TryAdd(libraryNameFromPath, assemblyPath); } + } + else + { + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not add dependency {0}", assemblyPath); + } - if (asset == "runtime.native.System.dll") - { - asset = "System.dll"; - } + } + + private void AddDependencyFromAppDirectory(RuntimeLibrary runtimeLibrary) + { + if (CompileAssemblies.ContainsKey(runtimeLibrary.Name) && _libraries.ContainsKey(runtimeLibrary.Name)) return; + + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Processing dependency {1} {0} using .nuget packages and ApplicationDirectory path.", runtimeLibrary.Name, runtimeLibrary.Type); - var assemblyPath = Path.Combine(runtimePath, Path.GetFileName(asset)); - if (File.Exists(assemblyPath)) - { - CompileAssemblies[runtimeLibrary.Name] = assemblyPath; - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added compile dependency {1} from {0}", assemblyPath, runtimeLibrary.Name); - } - else + var asset = runtimeLibrary.Name; + if (!asset.EndsWith(".dll") && !asset.EndsWith(".sni")) + { + asset += ".dll"; + } + + if (asset == "runtime.native.System.dll") + { + asset = "System.dll"; + } + + var assemblyPath = Path.Combine(_packagesPath, runtimeLibrary.Name.ToLower(), runtimeLibrary.Version, Path.GetFileName(asset)); + + if(!File.Exists(assemblyPath)) + { + assemblyPath = Path.Combine(RuntimeEnvironment.ApplicationDirectory, Path.GetFileName(asset)); + } + if (File.Exists(assemblyPath)) + { + CompileAssemblies.TryAdd(runtimeLibrary.Name, assemblyPath); + _libraries.TryAdd(runtimeLibrary.Name, assemblyPath); + + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added dependency {1} from {0}", assemblyPath, runtimeLibrary.Name); + + var libraryNameFromPath = Path.GetFileNameWithoutExtension(assemblyPath); + if (!string.Equals(runtimeLibrary.Name, libraryNameFromPath, StringComparison.CurrentCultureIgnoreCase)) { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not add compile dependency {0}", assemblyPath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added supplementary assembly {1} from {0}", assemblyPath, libraryNameFromPath); + CompileAssemblies.TryAdd(libraryNameFromPath, assemblyPath); + _libraries.TryAdd(libraryNameFromPath, assemblyPath); } } else { - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Already present in compile dependency list, skipping"); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not add dependency {0}", assemblyPath); } } @@ -463,26 +479,37 @@ private void AddCompileDependencies(DependencyContext dependencyContext, bool st continue; } - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Processing compile assembly {1} {0} {2}", compileLibrary.Name, compileLibrary.Type, compileLibrary.Assemblies[0]); - var assemblyPath = compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar); + var normalizedPath = compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar); + + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Processing compile assembly {1} {0} {2}", compileLibrary.Name, compileLibrary.Type, compileLibrary.Assemblies[0]); if (standalone) { - if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "refs", Path.GetFileName(compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar))))) + if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, Path.GetFileName(normalizedPath)))) + { + assemblyPath = Path.Combine(RuntimeEnvironment.ApplicationDirectory, Path.GetFileName(normalizedPath)); + } + else if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "refs", Path.GetFileName(normalizedPath)))) { - assemblyPath = Path.Combine(RuntimeEnvironment.ApplicationDirectory, "refs", Path.GetFileName(compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar))); + assemblyPath = Path.Combine(RuntimeEnvironment.ApplicationDirectory, "refs", Path.GetFileName(normalizedPath)); } - else if(!string.IsNullOrEmpty(runtimePath) && File.Exists(Path.Combine(runtimePath, Path.GetFileName(compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar))))) + else if(!string.IsNullOrEmpty(runtimePath) && File.Exists(Path.Combine(runtimePath, Path.GetFileName(normalizedPath)))) { - assemblyPath = Path.Combine(runtimePath, Path.GetFileName(compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar))); + assemblyPath = Path.Combine(runtimePath, Path.GetFileName(normalizedPath)); } } else { - assemblyPath = Path.Combine(_packagesPath, compileLibrary.Name.ToLower(), compileLibrary.Version, compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar).ToLower()); - if(!File.Exists(assemblyPath)) - assemblyPath = Path.Combine(_packagesPath, compileLibrary.Name.ToLower(), compileLibrary.Version, compileLibrary.Assemblies[0].Replace('/', Path.DirectorySeparatorChar)); + assemblyPath = Path.Combine(_packagesPath, compileLibrary.Name.ToLower(), compileLibrary.Version, normalizedPath.ToLower()); + if(!File.Exists(assemblyPath)) + { + assemblyPath = Path.Combine(_packagesPath, compileLibrary.Name.ToLower(), compileLibrary.Version, normalizedPath); + } + if(!File.Exists(assemblyPath) && File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, Path.GetFileName(normalizedPath)))) + { + assemblyPath = Path.Combine(RuntimeEnvironment.ApplicationDirectory, Path.GetFileName(normalizedPath)); + } } if (!File.Exists(assemblyPath) && !string.IsNullOrEmpty(runtimePath)) @@ -492,17 +519,22 @@ private void AddCompileDependencies(DependencyContext dependencyContext, bool st if (!CompileAssemblies.ContainsKey(compileLibrary.Name)) { + var libraryNameFromPath = Path.GetFileNameWithoutExtension(assemblyPath); if (File.Exists(assemblyPath)) { CompileAssemblies[compileLibrary.Name] = assemblyPath; - DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added compile assembly {0}", assemblyPath); + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added compile assembly {1} from {0}", assemblyPath, compileLibrary.Name); + if (!string.Equals(compileLibrary.Name, libraryNameFromPath, StringComparison.CurrentCultureIgnoreCase)) + { + DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Added supplementary compile assembly {1} from {0}", assemblyPath, libraryNameFromPath); + CompileAssemblies.TryAdd(libraryNameFromPath, assemblyPath); + } } else { DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Could not add compile assembly {0}", assemblyPath); } } - else { DebugMessage("EdgeAssemblyResolver::AddDependencies (CLR) - Already present in the compile assemblies list, skipping"); @@ -848,7 +880,7 @@ public static void CallFunc(IntPtr function, IntPtr payload, int payloadType, In Task functionTask = wrapperFunc(MarshalV8ToCLR(payload, (V8Type)payloadType)); - // Read the task status only once - you can't assume that an asychronous task's state won't change between reads + // Read the task status only once - you can't assume that an asynchronous task's state won't change between reads TaskStatus taskStatus = functionTask.Status; Marshal.WriteInt32(taskState, (int)taskStatus); @@ -893,9 +925,7 @@ public static void CallFunc(IntPtr function, IntPtr payload, int payloadType, In { DebugMessage("CoreCLREmbedding::CallFunc (CLR) - Exception was thrown: {0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace); - V8Type v8Type; - - Marshal.WriteIntPtr(result, MarshalCLRToV8(e, out v8Type)); + Marshal.WriteIntPtr(result, MarshalCLRToV8(e, out var v8Type)); Marshal.WriteInt32(resultType, (int)v8Type); Marshal.WriteInt32(taskState, (int)TaskStatus.Faulted); } @@ -1254,8 +1284,7 @@ public static IntPtr MarshalCLRToV8(object clrObject, out V8Type v8Type) foreach (object key in keys) { Marshal.WriteIntPtr(objectData.propertyNames, counter*PointerSize, Marshal.StringToCoTaskMemUTF8(key.ToString())); - V8Type propertyType; - Marshal.WriteIntPtr(objectData.propertyValues, counter*PointerSize, MarshalCLRToV8(getValue(key), out propertyType)); + Marshal.WriteIntPtr(objectData.propertyValues, counter*PointerSize, MarshalCLRToV8(getValue(key), out var propertyType)); Marshal.WriteInt32(objectData.propertyTypes, counter*sizeof (int), (int) propertyType); counter++; @@ -1277,9 +1306,7 @@ public static IntPtr MarshalCLRToV8(object clrObject, out V8Type v8Type) foreach (object item in (IEnumerable) clrObject) { - V8Type itemType; - - itemValues.Add(MarshalCLRToV8(item, out itemType)); + itemValues.Add(MarshalCLRToV8(item, out var itemType)); itemTypes.Add((int) itemType); }