Method
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
// using AnyOfTypes;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ProxyInterfaceSourceGenerator.FileGenerators
|
||||
@@ -14,39 +14,122 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators
|
||||
_context = context;
|
||||
}
|
||||
|
||||
protected string GetPropertyType(IPropertySymbol property, out Dictionary<string, string> differs)
|
||||
{
|
||||
differs = new Dictionary<string, string>();
|
||||
//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 == 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 (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)
|
||||
{
|
||||
var propertyTypeAsString = property.Type.ToString();
|
||||
|
||||
var existing = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == propertyTypeAsString);
|
||||
if (existing is not null)
|
||||
{
|
||||
differs.Add(property.Type.ToString(), existing.InterfaceName);
|
||||
if (!_context.ReplacedTypes.ContainsKey(propertyTypeAsString))
|
||||
{
|
||||
_context.ReplacedTypes.Add(propertyTypeAsString, existing.InterfaceName);
|
||||
}
|
||||
|
||||
return existing.InterfaceName;
|
||||
}
|
||||
|
||||
if (property.Type is INamedTypeSymbol namedTypedSymbol)
|
||||
{
|
||||
var type = property.Type.ToString();
|
||||
var propertyTypeAsStringToBeModified = propertyTypeAsString;
|
||||
foreach (var typeArgument in namedTypedSymbol.TypeArguments)
|
||||
{
|
||||
var exist = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == typeArgument.ToString());
|
||||
|
||||
var typeArgumentAsString = typeArgument.ToString();
|
||||
var exist = _context.CandidateInterfaces.Values.FirstOrDefault(x => x.TypeName == typeArgumentAsString);
|
||||
if (exist is not null)
|
||||
{
|
||||
if (!differs.ContainsKey(typeArgument.ToString()))
|
||||
if (!_context.ReplacedTypes.ContainsKey(typeArgumentAsString))
|
||||
{
|
||||
differs.Add(typeArgument.ToString(), exist.InterfaceName);
|
||||
_context.ReplacedTypes.Add(typeArgumentAsString, exist.InterfaceName);
|
||||
}
|
||||
|
||||
type = type.Replace(typeArgument.ToString(), exist.InterfaceName);
|
||||
propertyTypeAsStringToBeModified = propertyTypeAsStringToBeModified.Replace(typeArgumentAsString, exist.InterfaceName);
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
return propertyTypeAsStringToBeModified;
|
||||
}
|
||||
|
||||
return property.Type.ToString();
|
||||
return propertyTypeAsString;
|
||||
}
|
||||
|
||||
protected string GetParameterType(IParameterSymbol property)
|
||||
{
|
||||
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 INamedTypeSymbol GetType(string name)
|
||||
|
||||
Reference in New Issue
Block a user