internal static MethodInfo[] CollectExportedMethodsWithMissingTests(DecompilerType decompilerType, Type sourceType, Assembly testAssembly) { if (sourceType == null) { throw new ArgumentNullException(nameof(sourceType)); } if (testAssembly == null) { throw new ArgumentNullException(nameof(testAssembly)); } var sourceTypes = new[] { sourceType }; var testTypes = testAssembly.ExportedTypes.ToArray(); var testTypeMethods = TypeAndMethodAndParameterHelper.GetTypeMethodsWithTestAttributes(testTypes); switch (decompilerType) { case DecompilerType.AbstractSyntaxTree: var decompiler = AbstractSyntaxTree.DecompilerHelper.GetDecompiler(testAssembly); var testMethodsWithDecompiled = AbstractSyntaxTree.DecompilerHelper.GetTestMethodsWithDecompiled(decompiler, testTypeMethods); return(AbstractSyntaxTree.AnalyzerHelper.GetSourceMethodsWithMissingTest(sourceTypes.ToArray(), testMethodsWithDecompiled, DebugLimitData)); case DecompilerType.MonoReflection: var usedSourceMethods = MonoReflection.AnalyzerHelper.GetUsedSourceMethods(sourceTypes, testTypeMethods); return(MonoReflection.AnalyzerHelper.GetSourceMethodsWithMissingTest(sourceTypes, usedSourceMethods, DebugLimitData)); default: throw new ArgumentOutOfRangeException(nameof(decompilerType), decompilerType, message: null); } }
internal static MethodInfo[] CollectExportedMethodsWithMissingTests(DecompilerType decompilerType, Assembly sourceAssembly, Assembly testAssembly, List <Type>?excludeSourceTypes) { if (sourceAssembly == null) { throw new ArgumentNullException(nameof(sourceAssembly)); } if (testAssembly == null) { throw new ArgumentNullException(nameof(testAssembly)); } var sourceTypes = sourceAssembly.ExportedTypes .Where(x => !x.IsInterface && !x.IsNested && !(x.IsAbstract && !x.IsSealed) && !x.IsDelegate() && !x.HasExcludeFromCodeCoverageAttribute()) .OrderBy(x => x.Name) .ToArray(); if (excludeSourceTypes != null && excludeSourceTypes.Count > 0) { sourceTypes = sourceTypes .Where(sourceType => excludeSourceTypes.FirstOrDefault(x => x.BeautifyName(true, false, true) == sourceType.BeautifyName(true, false, true)) == null) .OrderBy(x => x.Name) .ToArray(); } var testTypes = testAssembly.ExportedTypes.ToArray(); var testTypeMethods = TypeAndMethodAndParameterHelper.GetTypeMethodsWithTestAttributes(testTypes); switch (decompilerType) { case DecompilerType.AbstractSyntaxTree: var decompiler = AbstractSyntaxTree.DecompilerHelper.GetDecompiler(testAssembly); var testMethodsWithDecompiled = AbstractSyntaxTree.DecompilerHelper.GetTestMethodsWithDecompiled(decompiler, testTypeMethods); return(AbstractSyntaxTree.AnalyzerHelper.GetSourceMethodsWithMissingTest(sourceTypes, testMethodsWithDecompiled, DebugLimitData)); case DecompilerType.MonoReflection: var usedSourceMethods = MonoReflection.AnalyzerHelper.GetUsedSourceMethods(sourceAssembly.ExportedTypes.ToArray(), testTypeMethods); return(MonoReflection.AnalyzerHelper.GetSourceMethodsWithMissingTest(sourceTypes, usedSourceMethods, DebugLimitData)); default: throw new ArgumentOutOfRangeException(nameof(decompilerType), decompilerType, null); } }