0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-12 15:10:44 -05:00

Start of a small project wide refactor to address issues. 28 failing remaps currently.

This commit is contained in:
Cj 2025-01-09 11:46:46 -05:00
parent 7c54b8542c
commit 4fc850cbb8
11 changed files with 166 additions and 146 deletions

View File

@ -11075,7 +11075,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": false
},
"Methods": {
@ -11116,7 +11116,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true
"IsPublic": false
},
"Methods": {
"ConstructorParameterCount": -1,
@ -11156,7 +11156,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsAbstract": true
},
"Methods": {
@ -11249,7 +11249,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsSealed": true
},
"Methods": {
@ -11295,7 +11295,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsAbstract": false
},
"Methods": {
@ -11427,7 +11427,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true
"IsPublic": false
},
"Methods": {
"ConstructorParameterCount": -1,
@ -11516,7 +11516,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsAbstract": true
},
"Methods": {
@ -11852,7 +11852,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsSealed": false
},
"Methods": {
@ -11899,7 +11899,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsSealed": true
},
"Methods": {
@ -12040,7 +12040,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsInterface": true
},
"Methods": {
@ -12083,7 +12083,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsInterface": true
},
"Methods": {
@ -12127,7 +12127,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsInterface": true
},
"Methods": {
@ -13234,7 +13234,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsAbstract": false,
"IsInterface": false,
"IsStruct": false,
@ -14982,7 +14982,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsAbstract": true
},
"Methods": {
@ -15251,7 +15251,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsInterface": true
},
"Methods": {
@ -15298,7 +15298,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -15347,7 +15347,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -15397,7 +15397,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -15448,7 +15448,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -16790,7 +16790,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsStruct": true
},
"Methods": {
@ -16837,7 +16837,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsStruct": true
},
"Methods": {
@ -16926,7 +16926,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -16976,7 +16976,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -17023,7 +17023,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true,
"IsPublic": false,
"IsDerived": true
},
"Methods": {
@ -17245,7 +17245,7 @@
"UseForceRename": false,
"SearchParams": {
"GenericParams": {
"IsPublic": true
"IsPublic": false
},
"Methods": {
"ConstructorParameterCount": -1,

View File

@ -5,6 +5,7 @@ public enum ENoMatchReason
AmbiguousWithPreviousMatch,
AmbiguousNewTypeNames,
IsPublic,
IsAbstract,
IsEnum,
IsNested,
IsSealed,
@ -26,6 +27,7 @@ public enum ENoMatchReason
NestedTypeInclude,
NestedTypeExclude,
NestedTypeCount,
NestedVisibility,
EventsInclude,
EventsExclude
}

View File

@ -56,7 +56,6 @@ public class SearchParams
public class GenericParams
{
public bool IsPublic { get; set; } = true;
public bool? IsAbstract { get; set; } = null;
public bool? IsInterface { get; set; } = null;
public bool? IsStruct { get; set; } = null;
@ -97,6 +96,12 @@ public class PropertyParams
public class NestedTypeParams
{
public bool IsNested { get; set; }
public bool IsNestedAssembly { get; set; }
public bool IsNestedFamily { get; set; }
public bool IsNestedPrivate { get; set; }
public bool IsNestedPublic { get; set; }
public bool IsNestedFamilyAndAssembly { get; set; }
public bool IsNestedFamilyOrAssembly { get; set; }
/// <summary>
/// Name of the nested types parent

View File

@ -22,12 +22,9 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
out var module);
Module = module;
CandidateTypes = Module.GetTypes()
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
.ToList();
var targetTypeDef = FindTargetType(oldTypeName);
if (targetTypeDef is null)
{
Logger.LogSync($"Could not target type: {oldTypeName}", ConsoleColor.Red);
@ -36,9 +33,24 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
Logger.LogSync($"Found target type: {targetTypeDef!.FullName}", ConsoleColor.Green);
var remapModel = new RemapModel();
remapModel.NewTypeName = newTypeName;
remapModel.AutoGenerated = true;
if (targetTypeDef.IsNested)
{
CandidateTypes = targetTypeDef.DeclaringType.NestedTypes
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
.ToList();
}
else
{
CandidateTypes = Module.Types
.Where(t => TypesToMatch.Any(token => t.Name.StartsWith(token)))
.ToList();
}
var remapModel = new RemapModel()
{
NewTypeName = newTypeName,
AutoGenerated = true
};
StartFilter(targetTypeDef, remapModel, assemblyPath);
}
@ -57,36 +69,42 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
{
if (!PassesGeneralChecks(target, candidate, remapModel.SearchParams.GenericParams))
{
Logger.LogSync($"Candidate: {candidate.Name} filtered out after general checks", ConsoleColor.Yellow);
CandidateTypes!.Remove(candidate);
continue;
}
if (!ContainsTargetMethods(target, candidate, remapModel.SearchParams.Methods))
{
Logger.LogSync($"Candidate: {candidate.Name} filtered out after method checks", ConsoleColor.Yellow);
CandidateTypes!.Remove(candidate);
continue;
}
if (!ContainsTargetFields(target, candidate, remapModel.SearchParams.Fields))
{
Logger.LogSync($"Candidate: {candidate.Name} filtered out after field checks", ConsoleColor.Yellow);
CandidateTypes!.Remove(candidate);
continue;
}
if (!ContainsTargetProperties(target, candidate, remapModel.SearchParams.Properties))
{
Logger.LogSync($"Candidate: {candidate.Name} filtered out after property checks", ConsoleColor.Yellow);
CandidateTypes!.Remove(candidate);
continue;
}
if (!ContainsTargetNestedTypes(target, candidate, remapModel.SearchParams.NestedTypes))
{
Logger.LogSync($"Candidate: {candidate.Name} filtered out after nested checks", ConsoleColor.Yellow);
CandidateTypes!.Remove(candidate);
continue;
}
if (!ContainsTargetEvents(target, candidate, remapModel.SearchParams.Events))
{
Logger.LogSync($"Candidate: {candidate.Name} filtered out after event checks", ConsoleColor.Yellow);
CandidateTypes!.Remove(candidate);
}
}
@ -102,8 +120,10 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
new ReMapper().InitializeRemap(tmpList, assemblyPath, validate: true);
ProcessEndQuestions(remapModel, assemblyPath);
return;
if (remapModel.Succeeded)
{
ProcessEndQuestions(remapModel, assemblyPath);
}
}
Logger.LogSync("Could not find a match... :(", ConsoleColor.Red);
@ -183,7 +203,8 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
methods.ConstructorParameterCount = target.Methods.First(m => m.IsConstructor && m.Parameters.Count > 0).Parameters.Count - 1;
}
return commonMethods.Any();
// True if we have common methods, or all methods are constructors
return commonMethods.Any() || target.Methods.All(m => m.IsConstructor);
}
private bool ContainsTargetFields(TypeDef target, TypeDef candidate, FieldParams fields)
@ -294,13 +315,19 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
nt.NestedTypeCount = target.NestedTypes.Count;
nt.IsNested = target.IsNested;
nt.IsNestedAssembly = target.IsNestedAssembly;
nt.IsNestedFamily = target.IsNestedFamily;
nt.IsNestedPrivate = target.IsNestedPrivate;
nt.IsNestedPublic = target.IsNestedPublic;
nt.IsNestedFamilyAndAssembly = target.IsNestedFamilyAndAssembly;
nt.IsNestedFamilyOrAssembly = target.IsNestedFamilyOrAssembly;
if (target.DeclaringType is not null)
{
nt.NestedTypeParentName = target.DeclaringType.Name.String;
}
return commonNts.Any() || !target.IsNested;
return commonNts.Any() || target.NestedTypes.Count == 0;
}
private bool ContainsTargetEvents(TypeDef target, TypeDef candidate, EventParams events)

View File

@ -1,5 +1,6 @@
using dnlib.DotNet;
using ReCodeItLib.Models;
using ReCodeItLib.Utils;
namespace ReCodeItLib.ReMapper.Filters;
@ -14,50 +15,9 @@ internal static class GenericTypeFilters
/// <returns>Filtered list</returns>
public static IEnumerable<TypeDef> FilterPublic(IEnumerable<TypeDef> types, SearchParams parms)
{
// REQUIRED PROPERTY
if (parms.GenericParams.IsPublic)
{
if (parms.NestedTypes.IsNested is true)
{
types = types.Where(t => t.IsNestedPublic);
types = FilterNestedByName(types, parms);
}
else
{
types = types.Where(t => t.IsPublic);
}
}
else
{
if (parms.NestedTypes.IsNested is true)
{
types = types.Where(t => t.IsNestedPrivate
|| t.IsNestedFamily
|| t.IsNestedFamilyAndAssembly
|| t.IsNestedAssembly);
types = FilterNestedByName(types, parms);
}
else
{
types = types.Where(t => t.IsNotPublic);
}
}
return types;
return types.Where(t => t.IsPublic == parms.GenericParams.IsPublic);
}
private static IEnumerable<TypeDef> FilterNestedByName(IEnumerable<TypeDef> types, SearchParams parms)
{
if (parms.NestedTypes.NestedTypeParentName is not "")
{
types = types.Where(t => t.DeclaringType.Name.String == parms.NestedTypes.NestedTypeParentName);
}
return types;
}
/// <summary>
/// Filters based on IsAbstract
/// </summary>

View File

@ -71,4 +71,32 @@ internal static class NestedTypeFilters
return types;
}
public static IEnumerable<TypeDef> FilterByNestedVisibility(IEnumerable<TypeDef> types, SearchParams parms)
{
types = FilterNestedByName(types, parms);
var ntp = parms.NestedTypes;
types = types.Where(t =>
t.IsNestedAssembly == ntp.IsNestedAssembly
&& t.IsNestedFamily == ntp.IsNestedFamily
&& t.IsNestedPrivate == ntp.IsNestedPrivate
&& t.IsNestedPublic == ntp.IsNestedPublic
&& t.IsNestedFamilyAndAssembly == ntp.IsNestedFamilyAndAssembly
&& t.IsNestedFamilyOrAssembly == ntp.IsNestedFamilyOrAssembly
);
return types;
}
private static IEnumerable<TypeDef> FilterNestedByName(IEnumerable<TypeDef> types, SearchParams parms)
{
if (parms.NestedTypes.NestedTypeParentName is not "")
{
types = types.Where(t => t.DeclaringType.Name.String == parms.NestedTypes.NestedTypeParentName);
}
return types;
}
}

View File

@ -9,7 +9,7 @@ internal class Publicizer
{
var types = definition.GetTypes();
var publicizeTasks = new List<Task>();
var publicizeTasks = new List<Task>(types.Count(t => !t.IsNested));
foreach (var type in types)
{
if (type.IsNested) continue; // Nested types are handled when publicizing the parent type
@ -25,7 +25,7 @@ internal class Publicizer
// TODO: This is broken. No idea why.
while (!publicizeTasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
{
Logger.DrawProgressBar(publicizeTasks.Where(t => t.IsCompleted)!.Count() + 1, publicizeTasks.Count, 50);
Logger.DrawProgressBar(publicizeTasks.Count(t => t.IsCompleted), publicizeTasks.Count, 50);
}
Task.WaitAll(publicizeTasks.ToArray());

View File

@ -173,15 +173,9 @@ public class ReMapper
}
// Filter down nested objects
if (mapping.SearchParams.NestedTypes.IsNested is false)
{
types = types.Where(type => tokens!.Any(token => type.Name.StartsWith(token)));
}
if (mapping.SearchParams.NestedTypes.NestedTypeParentName != string.Empty)
{
types = types.Where(t => t.DeclaringType != null && t.DeclaringType.Name == mapping.SearchParams.NestedTypes.NestedTypeParentName);
}
types = !mapping.SearchParams.NestedTypes.IsNested
? types.Where(type => tokens!.Any(token => type.Name.StartsWith(token)))
: types.Where(t => t.DeclaringType != null && t.DeclaringType.Name == mapping.SearchParams.NestedTypes.NestedTypeParentName);
// Run through a series of filters and report an error if all types are filtered out.
var filters = new TypeFilters();

View File

@ -16,11 +16,7 @@ internal class Renamer
/// <param name="direct"></param>
public void RenameAll(IEnumerable<TypeDef> types, RemapModel remap)
{
if (remap.TypePrimeCandidate is null)
{
Logger.Log($"Unable to rename {remap.NewTypeName} as TypePrimeCandidate value is null/empty, skipping", ConsoleColor.Red);
return;
}
if (remap.TypePrimeCandidate is null) return;
// Rename all fields and properties first
RenameAllFields(

View File

@ -53,27 +53,31 @@ public class Statistics(
foreach (var remap in remapModels)
{
if (remap.Succeeded is false && remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch))
switch (remap.Succeeded)
{
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
Logger.Log("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
Logger.Log($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
Logger.Log($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
}
else if (remap.Succeeded is false)
{
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
Logger.Log($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
foreach (var reason in remap.NoMatchReasons)
case false when remap.NoMatchReasons.Contains(ENoMatchReason.AmbiguousWithPreviousMatch):
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
Logger.Log("Ambiguous match with a previous match during matching. Skipping remap.", ConsoleColor.Red);
Logger.Log($"New Type Name: {remap.NewTypeName}", ConsoleColor.Red);
Logger.Log($"{remap.AmbiguousTypeMatch} already assigned to a previous match.", ConsoleColor.Red);
Logger.Log("----------------------------------------------------------------------", ConsoleColor.Red);
failures++;
break;
case false:
{
Logger.Log($"Reason: {reason}", ConsoleColor.Red);
}
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
Logger.Log($"Renaming {remap.NewTypeName} failed with reason(s)", ConsoleColor.Red);
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
failures++;
continue;
foreach (var reason in remap.NoMatchReasons)
{
Logger.Log($"Reason: {reason}", ConsoleColor.Red);
}
Logger.Log("-----------------------------------------------", ConsoleColor.Red);
failures++;
continue;
}
}
if (validate && remap.Succeeded)

View File

@ -26,7 +26,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsPublic);
AddNoMatchReason(mapping, ENoMatchReason.IsPublic);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -35,7 +35,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsPublic);
AddNoMatchReason(mapping, ENoMatchReason.IsAbstract);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -44,7 +44,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsSealed);
AddNoMatchReason(mapping, ENoMatchReason.IsSealed);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -53,7 +53,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsInterface);
AddNoMatchReason(mapping, ENoMatchReason.IsInterface);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -62,7 +62,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsStruct);
AddNoMatchReason(mapping, ENoMatchReason.IsStruct);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -71,7 +71,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsEnum);
AddNoMatchReason(mapping, ENoMatchReason.IsEnum);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -80,7 +80,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.HasAttribute);
AddNoMatchReason(mapping, ENoMatchReason.HasAttribute);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -89,7 +89,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.IsDerived);
AddNoMatchReason(mapping, ENoMatchReason.IsDerived);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -98,7 +98,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.HasGenericParameters);
AddNoMatchReason(mapping, ENoMatchReason.HasGenericParameters);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -112,7 +112,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.MethodsInclude);
AddNoMatchReason(mapping, ENoMatchReason.MethodsInclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -121,7 +121,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.MethodsExclude);
AddNoMatchReason(mapping, ENoMatchReason.MethodsExclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -130,7 +130,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.MethodsCount);
AddNoMatchReason(mapping, ENoMatchReason.MethodsCount);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -139,7 +139,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.ConstructorParameterCount);
AddNoMatchReason(mapping, ENoMatchReason.ConstructorParameterCount);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -153,7 +153,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.FieldsInclude);
AddNoMatchReason(mapping, ENoMatchReason.FieldsInclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -162,7 +162,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.FieldsExclude);
AddNoMatchReason(mapping, ENoMatchReason.FieldsExclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -171,7 +171,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.FieldsCount);
AddNoMatchReason(mapping, ENoMatchReason.FieldsCount);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -185,7 +185,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.PropertiesInclude);
AddNoMatchReason(mapping, ENoMatchReason.PropertiesInclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -194,7 +194,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.PropertiesExclude);
AddNoMatchReason(mapping, ENoMatchReason.PropertiesExclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -203,7 +203,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.PropertiesCount);
AddNoMatchReason(mapping, ENoMatchReason.PropertiesCount);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -217,7 +217,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.NestedTypeInclude);
AddNoMatchReason(mapping, ENoMatchReason.NestedTypeInclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -226,7 +226,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.NestedTypeExclude);
AddNoMatchReason(mapping, ENoMatchReason.NestedTypeExclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -235,7 +235,16 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.NestedTypeCount);
AddNoMatchReason(mapping, ENoMatchReason.NestedTypeCount);
mapping.TypeCandidates.UnionWith(types);
return false;
}
types = NestedTypeFilters.FilterByNestedVisibility(types, mapping.SearchParams);
if (!types.Any())
{
AddNoMatchReason(mapping, ENoMatchReason.NestedVisibility);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -249,7 +258,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.EventsInclude);
AddNoMatchReason(mapping, ENoMatchReason.EventsInclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -258,7 +267,7 @@ public class TypeFilters
if (!types.Any())
{
AllTypesFilteredOutFor(mapping, ENoMatchReason.EventsExclude);
AddNoMatchReason(mapping, ENoMatchReason.EventsExclude);
mapping.TypeCandidates.UnionWith(types);
return false;
}
@ -266,13 +275,8 @@ public class TypeFilters
return true;
}
/// <summary>
/// This is used to log that all types for a given remap were filtered out.
/// </summary>
/// <param name="remap">remap model that failed</param>
/// <param name="noMatchReason">Reason for filtering</param>
private static void AllTypesFilteredOutFor(RemapModel remap, ENoMatchReason noMatchReason)
private static void AddNoMatchReason(RemapModel remap, ENoMatchReason noMatchReason)
{
Logger.Log($"All types filtered out after `{noMatchReason}` filter for: `{remap.NewTypeName}`", ConsoleColor.Red);
remap.NoMatchReasons.Add(noMatchReason);
}
}