提交 0f7ebd12 编写于 作者: C Cyrus Najmabadi

Simplify further

上级 7a80c18a
......@@ -377,19 +377,11 @@ private static bool IsValidAttributeParameterType(ITypeSymbol type)
var argument = arguments[i];
var attributeArgument = attributeArguments != null ? attributeArguments.Value[i] : null;
// See if there's a matching field or property we can use. First test in a case sensitive
// manner, then case insensitively.
if (!TryFindMatchingMember(
ref parameterName, parameterType, argument, attributeArgument,
parameterToExistingMemberMap, parameterToNewFieldMap, parameterToNewPropertyMap,
cancellationToken))
{
// If no matching field was found, use the fieldNamingRule to create suitable name
var bestNameForParameter = parameterName.BestNameForParameter;
var nameBasedOnArgument = parameterName.NameBasedOnArgument;
parameterToNewFieldMap[bestNameForParameter] = _fieldNamingRule.NamingStyle.MakeCompliant(nameBasedOnArgument).First();
parameterToNewPropertyMap[bestNameForParameter] = _propertyNamingRule.NamingStyle.MakeCompliant(nameBasedOnArgument).First();
}
// See if there's a matching field or property we can use, or create a new member otherwise.
FindExistingOrCreateNewMember(
ref parameterName, parameterType, argument, attributeArgument,
parameterToExistingMemberMap, parameterToNewFieldMap, parameterToNewPropertyMap,
cancellationToken);
parameters.Add(CodeGenerationSymbolFactory.CreateParameterSymbol(
attributes: default,
......@@ -405,7 +397,7 @@ private static bool IsValidAttributeParameterType(ITypeSymbol type)
ParameterToNewPropertyMap = parameterToNewPropertyMap.ToImmutable();
}
private bool TryFindMatchingMember(
private void FindExistingOrCreateNewMember(
ref ParameterName parameterName,
ITypeSymbol parameterType,
TArgumentSyntax argument,
......@@ -478,11 +470,15 @@ private static bool IsValidAttributeParameterType(ITypeSymbol type)
}
}
return true;
return;
}
}
return false;
// If no matching field was found, use the fieldNamingRule to create suitable name
var bestNameForParameter = parameterName.BestNameForParameter;
var nameBasedOnArgument = parameterName.NameBasedOnArgument;
parameterToNewFieldMap[bestNameForParameter] = _fieldNamingRule.NamingStyle.MakeCompliant(nameBasedOnArgument).First();
parameterToNewPropertyMap[bestNameForParameter] = _propertyNamingRule.NamingStyle.MakeCompliant(nameBasedOnArgument).First();
}
private IEnumerable<string> GetUnavailableMemberNames()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册