refactor some code

This commit is contained in:
Stef Heyenrath
2021-07-26 15:09:07 +00:00
parent d7cb238cb9
commit 5d48b67ba3
2 changed files with 77 additions and 173 deletions
@@ -14,125 +14,14 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
_context = context;
}
//protected string GetReplacedType(AnyOf<IPropertySymbol, IParameterSymbol> x)
//{
// ITypeSymbol ts = x.IsFirst ? x.First.Type : x.Second.Type;
// var propertyTypeAsString = ts.ToString();
// var existing = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == propertyTypeAsString);
// if (existing is not null)
// {
// if (!_context.ReplacedTypes.ContainsKey(propertyTypeAsString))
// {
// _context.ReplacedTypes.Add(propertyTypeAsString, existing.InterfaceName);
// }
// return existing.InterfaceName;
// }
// if (ts is INamedTypeSymbol namedTypedSymbol)
// {
// var propertyTypeAsStringToBeModified = propertyTypeAsString;
// foreach (var typeArgument in namedTypedSymbol.TypeArguments)
// {
// var typeArgumentAsString = typeArgument.ToString();
// var exist = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == typeArgumentAsString);
// if (exist is not null)
// {
// if (!_context.ReplacedTypes.ContainsKey(typeArgumentAsString))
// {
// _context.ReplacedTypes.Add(typeArgumentAsString, exist.InterfaceName);
// }
// propertyTypeAsStringToBeModified = propertyTypeAsStringToBeModified.Replace(typeArgumentAsString, exist.InterfaceName);
// }
// }
// return propertyTypeAsStringToBeModified;
// }
// return propertyTypeAsString;
//}
protected string GetPropertyType(IPropertySymbol property, out bool isReplaced)
{
return GetReplacedType(property.Type, out isReplaced);
//var propertyTypeAsString = property.Type.ToString();
//var existing = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == propertyTypeAsString);
//if (existing is not null)
//{
// if (!_context.ReplacedTypes.ContainsKey(propertyTypeAsString))
// {
// _context.ReplacedTypes.Add(propertyTypeAsString, existing.InterfaceName);
// }
// return existing.InterfaceName;
//}
//if (property.Type is INamedTypeSymbol namedTypedSymbol)
//{
// var propertyTypeAsStringToBeModified = propertyTypeAsString;
// foreach (var typeArgument in namedTypedSymbol.TypeArguments)
// {
// var typeArgumentAsString = typeArgument.ToString();
// var exist = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == typeArgumentAsString);
// if (exist is not null)
// {
// if (!_context.ReplacedTypes.ContainsKey(typeArgumentAsString))
// {
// _context.ReplacedTypes.Add(typeArgumentAsString, exist.InterfaceName);
// }
// propertyTypeAsStringToBeModified = propertyTypeAsStringToBeModified.Replace(typeArgumentAsString, exist.InterfaceName);
// }
// }
// return propertyTypeAsStringToBeModified;
//}
//return propertyTypeAsString;
}
protected string GetParameterType(IParameterSymbol property, out bool isReplaced)
{
return GetReplacedType(property.Type, out isReplaced);
//var propertyTypeAsString = property.Type.ToString();
//var existing = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == propertyTypeAsString);
//if (existing is not null)
//{
// if (!_context.ReplacedTypes.ContainsKey(propertyTypeAsString))
// {
// _context.ReplacedTypes.Add(propertyTypeAsString, existing.InterfaceName);
// }
// return existing.InterfaceName;
//}
//if (property.Type is INamedTypeSymbol namedTypedSymbol)
//{
// var propertyTypeAsStringToBeModified = propertyTypeAsString;
// foreach (var typeArgument in namedTypedSymbol.TypeArguments)
// {
// var typeArgumentAsString = typeArgument.ToString();
// var exist = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == typeArgumentAsString);
// if (exist is not null)
// {
// if (!_context.ReplacedTypes.ContainsKey(typeArgumentAsString))
// {
// _context.ReplacedTypes.Add(typeArgumentAsString, exist.InterfaceName);
// }
// propertyTypeAsStringToBeModified = propertyTypeAsStringToBeModified.Replace(typeArgumentAsString, exist.InterfaceName);
// }
// }
// return propertyTypeAsStringToBeModified;
//}
//return propertyTypeAsString;
}
protected string GetReplacedType(ITypeSymbol property, out bool isReplaced)