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 20b0e372d74451518f94046e2264b7469d9d3458 Author: Shad Storhaug <[email protected]> AuthorDate: Fri Sep 11 10:55:10 2020 +0700 Directory.Build.targets: Added FEATURE_TYPE_GETMETHOD__BINDINGFLAGS_PARAMS and implemented throughout solution --- Directory.Build.targets | 1 + src/Lucene.Net/Util/VirtualMethod.cs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 274f6e8..40ee749 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -69,6 +69,7 @@ <DefineConstants>$(DefineConstants);FEATURE_THREAD_PRIORITY</DefineConstants> <DefineConstants>$(DefineConstants);FEATURE_THREAD_YIELD</DefineConstants> <DefineConstants>$(DefineConstants);FEATURE_THREADPOOL_UNSAFEQUEUEWORKITEM</DefineConstants> + <DefineConstants>$(DefineConstants);FEATURE_TYPE_GETMETHOD__BINDINGFLAGS_PARAMS</DefineConstants> <DefineConstants>$(DefineConstants);FEATURE_XSLT</DefineConstants> <!-- NOTE: Microsoft's recommendation is not to use the ICloneable interface. diff --git a/src/Lucene.Net/Util/VirtualMethod.cs b/src/Lucene.Net/Util/VirtualMethod.cs index 58d7c9d..4448b48 100644 --- a/src/Lucene.Net/Util/VirtualMethod.cs +++ b/src/Lucene.Net/Util/VirtualMethod.cs @@ -2,7 +2,7 @@ using Lucene.Net.Support; using System; using System.Collections.Generic; using System.Globalization; -#if NETSTANDARD1_6 +#if !FEATURE_TYPE_GETMETHOD__BINDINGFLAGS_PARAMS using System.Linq; #endif using System.Reflection; @@ -207,7 +207,9 @@ namespace Lucene.Net.Util private MethodInfo GetMethod(Type clazz, string methodName, BindingFlags bindingFlags, Type[] methodParameters) { -#if NETSTANDARD1_6 +#if FEATURE_TYPE_GETMETHOD__BINDINGFLAGS_PARAMS + return clazz.GetMethod(methodName, bindingFlags, null, methodParameters, null); +#else var methods = clazz.GetTypeInfo().GetMethods(bindingFlags).Where(x => { return x.Name.Equals(methodName, StringComparison.Ordinal) && x.GetParameters().Select(y => y.ParameterType).SequenceEqual(methodParameters); @@ -226,8 +228,6 @@ namespace Lucene.Net.Util var formatted = string.Format("Found more than one match for type {0}, methodName {1}, bindingFlags {2}, parameters {3}", clazz, methodName, bindingFlags, methodParameters); throw new AmbiguousMatchException(formatted); } -#else - return clazz.GetMethod(methodName, bindingFlags, null, methodParameters, null); #endif } }
