Small adjustment to scoring
This commit is contained in:
parent
58450e6bc3
commit
eb8dc10330
@ -127,6 +127,13 @@ public class ReCodeItRemapper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tokens = DataProvider.Settings.AutoMapper.TokensToMatch;
|
||||||
|
|
||||||
|
if (tokens.Where(token => !tokens.Any(token => type.Name.StartsWith(token))).Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var nestedType in type.NestedTypes)
|
foreach (var nestedType in type.NestedTypes)
|
||||||
{
|
{
|
||||||
if (remap.SearchParams.IsNested is false) { return; }
|
if (remap.SearchParams.IsNested is false) { return; }
|
||||||
|
@ -22,7 +22,7 @@ internal static class Fields
|
|||||||
.Where(field => parms.IncludeFields.Contains(field.Name))
|
.Where(field => parms.IncludeFields.Contains(field.Name))
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
score.Score += matches;
|
score.Score += matches > 0 ? matches : -matches;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.FieldsInclude;
|
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.FieldsInclude;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ internal static class Fields
|
|||||||
.Where(field => parms.ExcludeFields.Contains(field.Name))
|
.Where(field => parms.ExcludeFields.Contains(field.Name))
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
score.Score -= matches;
|
score.Score += matches > 0 ? -matches : 1;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.FieldsExclude : EFailureReason.None;
|
score.FailureReason = matches > 0 ? EFailureReason.FieldsExclude : EFailureReason.None;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ internal static class Fields
|
|||||||
|
|
||||||
var match = type.Fields.Exactly((int)parms.FieldCount);
|
var match = type.Fields.Exactly((int)parms.FieldCount);
|
||||||
|
|
||||||
if (match) { score.Score++; }
|
score.Score += match ? (int)parms.FieldCount : -(int)parms.FieldCount;
|
||||||
|
|
||||||
score.FailureReason = match ? EFailureReason.None : EFailureReason.FieldsCount;
|
score.FailureReason = match ? EFailureReason.None : EFailureReason.FieldsCount;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ internal static class Methods
|
|||||||
.Where(method => parms.IncludeMethods.Any(include => method.Name.Contains(include)))
|
.Where(method => parms.IncludeMethods.Any(include => method.Name.Contains(include)))
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
score.Score += matches;
|
score.Score += matches > 0 ? matches : -matches;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.MethodsInclude;
|
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.MethodsInclude;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ internal static class Methods
|
|||||||
.Where(method => parms.ExcludeMethods.Contains(method.Name))
|
.Where(method => parms.ExcludeMethods.Contains(method.Name))
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
score.Score -= matches;
|
score.Score += matches > 0 ? -matches : 1;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.MethodsExclude : EFailureReason.None;
|
score.FailureReason = matches > 0 ? EFailureReason.MethodsExclude : EFailureReason.None;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ internal static class Methods
|
|||||||
var numMethods = type.Methods.Count - type.GetConstructors().Count();
|
var numMethods = type.Methods.Count - type.GetConstructors().Count();
|
||||||
bool match = numMethods == parms.MethodCount;
|
bool match = numMethods == parms.MethodCount;
|
||||||
|
|
||||||
if (match) { score.Score++; }
|
score.Score += match ? (int)parms.MethodCount : -(int)parms.MethodCount;
|
||||||
|
|
||||||
score.FailureReason = match ? EFailureReason.None : EFailureReason.MethodsCount;
|
score.FailureReason = match ? EFailureReason.None : EFailureReason.MethodsCount;
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ internal class NestedTypes
|
|||||||
var matches = type.NestedTypes
|
var matches = type.NestedTypes
|
||||||
.Where(nt => parms.IncludeNestedTypes.Contains(nt.Name))
|
.Where(nt => parms.IncludeNestedTypes.Contains(nt.Name))
|
||||||
.Count();
|
.Count();
|
||||||
score.Score += matches;
|
|
||||||
|
score.Score += matches > 0 ? matches : -matches;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.NestedTypeInclude;
|
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.NestedTypeInclude;
|
||||||
|
|
||||||
@ -31,9 +32,9 @@ internal class NestedTypes
|
|||||||
.Where(nt => parms.ExcludeNestedTypes.Contains(nt.Name))
|
.Where(nt => parms.ExcludeNestedTypes.Contains(nt.Name))
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
score.Score += matches;
|
score.Score += matches > 0 ? -matches : 1;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.NestedTypeExclude;
|
score.FailureReason = matches > 0 ? EFailureReason.NestedTypeExclude : EFailureReason.None;
|
||||||
|
|
||||||
return matches > 0
|
return matches > 0
|
||||||
? EMatchResult.NoMatch
|
? EMatchResult.NoMatch
|
||||||
@ -46,7 +47,7 @@ internal class NestedTypes
|
|||||||
|
|
||||||
var match = type.NestedTypes.Exactly((int)parms.NestedTypeCount);
|
var match = type.NestedTypes.Exactly((int)parms.NestedTypeCount);
|
||||||
|
|
||||||
if (match) { score.Score++; }
|
score.Score += match ? type.NestedTypes.Count : -type.NestedTypes.Count - 1;
|
||||||
|
|
||||||
score.FailureReason = match ? EFailureReason.None : EFailureReason.NestedTypeCount;
|
score.FailureReason = match ? EFailureReason.None : EFailureReason.NestedTypeCount;
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ namespace ReCodeIt.ReMapper.Search
|
|||||||
var matches = type.Properties
|
var matches = type.Properties
|
||||||
.Where(property => parms.IncludeProperties.Contains(property.Name))
|
.Where(property => parms.IncludeProperties.Contains(property.Name))
|
||||||
.Count();
|
.Count();
|
||||||
score.Score += matches;
|
|
||||||
|
score.Score += matches > 0 ? matches : -matches;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.PropertiesInclude;
|
score.FailureReason = matches > 0 ? EFailureReason.None : EFailureReason.PropertiesInclude;
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ namespace ReCodeIt.ReMapper.Search
|
|||||||
.Where(property => parms.ExcludeProperties.Contains(property.Name))
|
.Where(property => parms.ExcludeProperties.Contains(property.Name))
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
score.Score -= matches;
|
score.Score += matches > 0 ? -matches : 1;
|
||||||
|
|
||||||
score.FailureReason = matches > 0 ? EFailureReason.PropertiesExclude : EFailureReason.None;
|
score.FailureReason = matches > 0 ? EFailureReason.PropertiesExclude : EFailureReason.None;
|
||||||
|
|
||||||
@ -46,9 +47,7 @@ namespace ReCodeIt.ReMapper.Search
|
|||||||
|
|
||||||
var match = type.Properties.Exactly((int)parms.PropertyCount);
|
var match = type.Properties.Exactly((int)parms.PropertyCount);
|
||||||
|
|
||||||
if (match) { score.Score++; }
|
score.Score += match ? (int)parms.PropertyCount : -(int)parms.PropertyCount;
|
||||||
|
|
||||||
score.FailureReason = match ? EFailureReason.None : EFailureReason.PropertiesCount;
|
|
||||||
|
|
||||||
return match
|
return match
|
||||||
? EMatchResult.Match
|
? EMatchResult.Match
|
||||||
|
Loading…
x
Reference in New Issue
Block a user