Esempio n. 1
0
        internal static Tuple <MethodInfo, MethodDeclaration>[]? DebugFilterMethod(DebugLimitData debugLimitData, MethodInfo method, Tuple <MethodInfo, MethodDeclaration>[] testMethodsWithDeclaration)
        {
            if (!debugLimitData.HasClassNames)
            {
                return(testMethodsWithDeclaration);
            }

            var list = new List <Tuple <MethodInfo, MethodDeclaration> >();

            // ReSharper disable once UseDeconstruction
            foreach (var classMethodsNames in debugLimitData.ClassMethodNames)
            {
                foreach (var testMethodWithDeclaration in testMethodsWithDeclaration)
                {
                    if (!testMethodWithDeclaration.Item1.DeclaringType !.BeautifyName(false, false, true).StartsWith(classMethodsNames.Item1, StringComparison.Ordinal))
                    {
                        continue;
                    }

                    if (classMethodsNames.Item2 == null)
                    {
                        list.Add(testMethodWithDeclaration);
                    }
                    else
                    {
                        // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
                        foreach (var methodName in classMethodsNames.Item2)
                        {
                            if (!methodName.Equals(method.Name, StringComparison.Ordinal))
                            {
                                continue;
                            }

                            var astNodeForMethod = GetAstNodeForMethod(testMethodWithDeclaration.Item2.Body, methodName);

                            // ReSharper disable once InvertIf
                            if (astNodeForMethod != null)
                            {
                                list.Add(testMethodWithDeclaration);
                            }
                        }
                    }
                }
            }

            return(list.Count == 0
                ? null
                : list.ToArray());
        }
        internal static Type[] DebugFilterTypeNames(DebugLimitData debugLimitData, Type[] sourceTypes)
        {
            if (!debugLimitData.HasClassNames)
            {
                return(sourceTypes);
            }

            return((from sourceType
                    in sourceTypes
                    from classMethodNames
                    in debugLimitData.ClassMethodNames
                    where sourceType.BeautifyName().Equals(classMethodNames.Item1, StringComparison.Ordinal)
                    select sourceType)
                   .OrderBy(x => x.Name)
                   .ToArray());
        }
Esempio n. 3
0
        private static MethodInfo[] DebugFilterTypeNames(DebugLimitData debugLimitData, MethodInfo[] usedSourceMethods)
        {
            if (!debugLimitData.HasClassNames)
            {
                return(usedSourceMethods);
            }

            var list = new List <MethodInfo>();

            foreach (var usedSourceMethod in usedSourceMethods)
            {
                // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
                // ReSharper disable once UseDeconstruction
                foreach (var classMethodNames in debugLimitData.ClassMethodNames)
                {
                    if (!usedSourceMethod.DeclaringType !.BeautifyName(false, false, true).Equals(classMethodNames.Item1, StringComparison.Ordinal))
                    {
                        continue;
                    }

                    if (classMethodNames.Item2 == null)
                    {
                        list.Add(usedSourceMethod);
                    }
                    else
                    {
                        // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
                        foreach (var methodName in classMethodNames.Item2)
                        {
                            if (usedSourceMethod.BeautifyName().Equals(methodName, StringComparison.Ordinal))
                            {
                                list.Add(usedSourceMethod);
                            }
                        }
                    }
                }
            }

            return(list.ToArray());
        }