This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit c39e7931cba07771bf8eb6923124e7c8d9fb3ed2 Author: Shad Storhaug <[email protected]> AuthorDate: Fri Sep 11 11:27:57 2020 +0700 Directory.Build.targets: Added FEATURE_APPDOMAIN_GETASSEMBLIES and implemented throughout solution --- Directory.Build.targets | 1 + src/Lucene.Net/Support/AssemblyUtils.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 47a5599..53ac6ed 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -58,6 +58,7 @@ <PropertyGroup Condition=" $(TargetFramework.StartsWith('net4')) Or $(TargetFramework.StartsWith('netstandard2.')) Or $(TargetFramework.StartsWith('netcoreapp2.')) Or $(TargetFramework.StartsWith('netcoreapp3.')) "> <DefineConstants>$(DefineConstants);FEATURE_APPDOMAIN_BASEDIRECTORY</DefineConstants> + <DefineConstants>$(DefineConstants);FEATURE_APPDOMAIN_GETASSEMBLIES</DefineConstants> <DefineConstants>$(DefineConstants);FEATURE_APPDOMAIN_ISFULLYTRUSTED</DefineConstants> <DefineConstants>$(DefineConstants);FEATURE_ASSEMBLY_GETCALLINGASSEMBLY</DefineConstants> <DefineConstants>$(DefineConstants);FEATURE_CONCURRENTMERGESCHEDULER</DefineConstants> diff --git a/src/Lucene.Net/Support/AssemblyUtils.cs b/src/Lucene.Net/Support/AssemblyUtils.cs index 917df0d..e77b616 100644 --- a/src/Lucene.Net/Support/AssemblyUtils.cs +++ b/src/Lucene.Net/Support/AssemblyUtils.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Reflection; -#if NETSTANDARD1_6 +#if !FEATURE_APPDOMAIN_GETASSEMBLIES using Microsoft.Extensions.DependencyModel; #endif using JCG = J2N.Collections.Generic; @@ -45,15 +45,15 @@ namespace Lucene.Net.Support // hoping would be loaded hasn't been loaded yet into the app domain, // it is unavailable. So we go to the next level on each and check each referenced // assembly. -#if NETSTANDARD1_6 +#if FEATURE_APPDOMAIN_GETASSEMBLIES + var assembliesLoaded = AppDomain.CurrentDomain.GetAssemblies(); +#else var dependencyContext = DependencyContext.Default; var assemblyNames = dependencyContext.RuntimeLibraries .SelectMany(lib => lib.GetDefaultAssemblyNames(dependencyContext)) .Where(x => !DotNetFrameworkFilter.IsFrameworkAssembly(x)) .Distinct(); var assembliesLoaded = LoadAssemblyFromName(assemblyNames); -#else - var assembliesLoaded = AppDomain.CurrentDomain.GetAssemblies(); #endif assembliesLoaded = assembliesLoaded.Where(x => !DotNetFrameworkFilter.IsFrameworkAssembly(x)).ToArray(); @@ -71,10 +71,12 @@ namespace Lucene.Net.Support return assembliesLoaded.Concat(referencedAssemblies).Distinct().ToList(); } +#if !FEATURE_APPDOMAIN_GETASSEMBLIES private static IEnumerable<Assembly> LoadAssemblyFromName(IEnumerable<AssemblyName> assemblyNames) { return assemblyNames.Select(x => LoadAssemblyFromName(x)).Where(x => x != null); } +#endif private static Assembly LoadAssemblyFromName(AssemblyName assemblyName) {
