lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [46/53] [abbrv] lucenenet git commit: Lucene.Net.TestFramework.Util.ApiScanTestBase.TestForMembersAcceptingOrReturningListOrDictionary: Added functionality to exclude members based on a regex match
Date Wed, 08 Feb 2017 14:32:25 GMT
Lucene.Net.TestFramework.Util.ApiScanTestBase.TestForMembersAcceptingOrReturningListOrDictionary:
Added functionality to exclude members based on a regex match


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/96dd76c0
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/96dd76c0
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/96dd76c0

Branch: refs/heads/api-work
Commit: 96dd76c02f660bb475ae7e08a649f2518d11c618
Parents: 1200b29
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Feb 8 17:40:26 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Feb 8 21:08:25 2017 +0700

----------------------------------------------------------------------
 .../Util/ApiScanTestBase.cs                     | 62 ++++++++++++++++----
 src/Lucene.Net.Tests/core/TestApiConsistency.cs |  2 +-
 2 files changed, 53 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96dd76c0/src/Lucene.Net.TestFramework/Util/ApiScanTestBase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/ApiScanTestBase.cs b/src/Lucene.Net.TestFramework/Util/ApiScanTestBase.cs
index 3bbdf7a..fc8b96b 100644
--- a/src/Lucene.Net.TestFramework/Util/ApiScanTestBase.cs
+++ b/src/Lucene.Net.TestFramework/Util/ApiScanTestBase.cs
@@ -332,7 +332,13 @@ namespace Lucene.Net.Util
         //[Test, LuceneNetSpecific]
         public virtual void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly)
         {
-            var names = GetMembersAcceptingOrReturningType(typeof(IEnumerable<>), typeFromTargetAssembly.Assembly,
false);
+            TestForMembersAcceptingOrReturningIEnumerable(typeFromTargetAssembly, null);
+        }
+
+        //[Test, LuceneNetSpecific]
+        public virtual void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly,
string exceptionRegex)
+        {
+            var names = GetMembersAcceptingOrReturningType(typeof(IEnumerable<>), typeFromTargetAssembly.Assembly,
false, exceptionRegex);
 
             //if (VERBOSE)
             //{
@@ -348,9 +354,15 @@ namespace Lucene.Net.Util
         //[Test, LuceneNetSpecific]
         public virtual void TestForMembersAcceptingOrReturningListOrDictionary(Type typeFromTargetAssembly)
         {
+            TestForMembersAcceptingOrReturningListOrDictionary(typeFromTargetAssembly, null);
+        }
+
+        //[Test, LuceneNetSpecific]
+        public virtual void TestForMembersAcceptingOrReturningListOrDictionary(Type typeFromTargetAssembly,
string exceptionRegex)
+        {
             var names = new List<string>();
-            names.AddRange(GetMembersAcceptingOrReturningType(typeof(List<>), typeFromTargetAssembly.Assembly,
true));
-            names.AddRange(GetMembersAcceptingOrReturningType(typeof(Dictionary<,>),
typeFromTargetAssembly.Assembly, true));
+            names.AddRange(GetMembersAcceptingOrReturningType(typeof(List<>), typeFromTargetAssembly.Assembly,
true, exceptionRegex));
+            names.AddRange(GetMembersAcceptingOrReturningType(typeof(Dictionary<,>),
typeFromTargetAssembly.Assembly, true, exceptionRegex));
 
             //if (VERBOSE)
             //{
@@ -389,8 +401,12 @@ namespace Lucene.Net.Util
                     if ((field.IsPrivate || field.IsAssembly) && !PrivateFieldName.IsMatch(field.Name)
&& field.DeclaringType.Equals(c.UnderlyingSystemType))
                     {
                         var name = string.Concat(c.FullName, ".", field.Name);
-                        bool hasExceptions = !string.IsNullOrWhiteSpace(exceptionRegex);
-                        if (!hasExceptions || (hasExceptions && !Regex.IsMatch(name,
exceptionRegex)))
+                        //bool hasExceptions = !string.IsNullOrWhiteSpace(exceptionRegex);
+                        //if (!hasExceptions || (hasExceptions && !Regex.IsMatch(name,
exceptionRegex)))
+                        //{
+                        //    result.Add(name);
+                        //}
+                        if (!IsException(name, exceptionRegex))
                         {
                             result.Add(name);
                         }
@@ -929,6 +945,12 @@ namespace Lucene.Net.Util
                 (setMethod != null && !setMethod.IsPrivate));
         }
 
+        private static bool IsException(string name, string exceptionRegex)
+        {
+            bool hasExceptions = !string.IsNullOrWhiteSpace(exceptionRegex);
+            return (hasExceptions && Regex.IsMatch(name, exceptionRegex));
+        }
+
         /// <summary>
         /// Some parameters were incorrectly changed from List to IEnumerable during the
port. This is
         /// to track down constructor and method parameters and property and method return
types
@@ -936,7 +958,7 @@ namespace Lucene.Net.Util
         /// </summary>
         /// <param name="assembly"></param>
         /// <returns></returns>
-        private static IEnumerable<string> GetMembersAcceptingOrReturningType(Type
lookFor, Assembly assembly, bool publiclyVisibleOnly)
+        private static IEnumerable<string> GetMembersAcceptingOrReturningType(Type
lookFor, Assembly assembly, bool publiclyVisibleOnly, string exceptionRegex)
         {
             var result = new List<string>();
 
@@ -966,7 +988,12 @@ namespace Lucene.Net.Util
                                     && method.ReturnParameter.ParameterType.IsGenericType
                                     && method.ReturnParameter.ParameterType.GetGenericTypeDefinition().IsAssignableFrom(lookFor))
                                 {
-                                    result.Add(string.Concat(t.FullName, ".", member.Name,
"()"));
+                                    var name = string.Concat(t.FullName, ".", member.Name,
"()");
+
+                                    if (!IsException(name, exceptionRegex))
+                                    {
+                                        result.Add(name);
+                                    }
                                 }
 
                                 var parameters = method.GetParameters();
@@ -977,7 +1004,12 @@ namespace Lucene.Net.Util
                                         && parameter.ParameterType.GetGenericTypeDefinition().IsAssignableFrom(lookFor)
                                         && member.DeclaringType.Equals(t.UnderlyingSystemType))
                                     {
-                                        result.Add(string.Concat(t.FullName, ".", member.Name,
"()", " -parameter- ", parameter.Name));
+                                        var name = string.Concat(t.FullName, ".", member.Name,
"()", " -parameter- ", parameter.Name);
+
+                                        if (!IsException(name, exceptionRegex))
+                                        {
+                                            result.Add(name);
+                                        }
                                     }
                                 }
                             }
@@ -996,7 +1028,12 @@ namespace Lucene.Net.Util
                                         && parameter.ParameterType.GetGenericTypeDefinition().IsAssignableFrom(lookFor)
                                         && member.DeclaringType.Equals(t.UnderlyingSystemType))
                                     {
-                                        result.Add(string.Concat(t.FullName, ".", member.Name,
"()", " -parameter- ", parameter.Name));
+                                        var name = string.Concat(t.FullName, ".", member.Name,
"()", " -parameter- ", parameter.Name);
+
+                                        if (!IsException(name, exceptionRegex))
+                                        {
+                                            result.Add(name);
+                                        }
                                     }
                                 }
                             }
@@ -1006,7 +1043,12 @@ namespace Lucene.Net.Util
                             && ((PropertyInfo)member).PropertyType.GetGenericTypeDefinition().IsAssignableFrom(lookFor)
                             && (!publiclyVisibleOnly || IsNonPrivateProperty((PropertyInfo)member)))
                         {
-                            result.Add(string.Concat(t.FullName, ".", member.Name));
+                            var name = string.Concat(string.Concat(t.FullName, ".", member.Name));
+
+                            if (!IsException(name, exceptionRegex))
+                            {
+                                result.Add(name);
+                            }
                         }
                         //else if (member.MemberType == MemberTypes.Field
                         //    && ((FieldInfo)member).FieldType.IsGenericType

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/96dd76c0/src/Lucene.Net.Tests/core/TestApiConsistency.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/TestApiConsistency.cs b/src/Lucene.Net.Tests/core/TestApiConsistency.cs
index ed6c3e1..f0dde4a 100644
--- a/src/Lucene.Net.Tests/core/TestApiConsistency.cs
+++ b/src/Lucene.Net.Tests/core/TestApiConsistency.cs
@@ -121,7 +121,7 @@ namespace Lucene.Net
         [TestCase(typeof(Lucene.Net.Analysis.Analyzer))]
         public override void TestForMembersAcceptingOrReturningListOrDictionary(Type typeFromTargetAssembly)
         {
-            base.TestForMembersAcceptingOrReturningListOrDictionary(typeFromTargetAssembly);
+            base.TestForMembersAcceptingOrReturningListOrDictionary(typeFromTargetAssembly,
@"Support\.Arrays\.AsList");
         }
     }
 }


Mime
View raw message