Method
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using ProxyInterfaceSourceGenerator.Enums;
|
||||
|
||||
namespace ProxyInterfaceSourceGenerator.Extensions
|
||||
@@ -12,7 +11,22 @@ namespace ProxyInterfaceSourceGenerator.Extensions
|
||||
{
|
||||
return TypeEnum.ValueTypeOrString;
|
||||
}
|
||||
|
||||
|
||||
if (p.Type.TypeKind == TypeKind.Interface)
|
||||
{
|
||||
return TypeEnum.Interface;
|
||||
}
|
||||
|
||||
return TypeEnum.Complex;
|
||||
}
|
||||
|
||||
public static TypeEnum GetTypeEnum(this IParameterSymbol p)
|
||||
{
|
||||
if (p.Type.IsValueType || p.Type.ToString() == "string")
|
||||
{
|
||||
return TypeEnum.ValueTypeOrString;
|
||||
}
|
||||
|
||||
if (p.Type.TypeKind == TypeKind.Interface)
|
||||
{
|
||||
return TypeEnum.Interface;
|
||||
@@ -46,36 +60,5 @@ namespace ProxyInterfaceSourceGenerator.Extensions
|
||||
|
||||
return $"{overrideType} {property.Name} {{ {get}{set}}}";
|
||||
}
|
||||
|
||||
//public static string ToPropertyTextForClass(this IPropertySymbol property, string overrideType, string className)
|
||||
//{
|
||||
// var classNameProxy = $"{className}Proxy";
|
||||
// var get = property.GetMethod != null ? $"get => new {classNameProxy}(_Instance.{property.Name}); " : string.Empty;
|
||||
// var set = property.SetMethod != null ? $"set => _Instance.{property.Name} = (({classNameProxy}) value)._Instance; " : string.Empty;
|
||||
|
||||
// return $"{overrideType} {property.Name} {{ {get}{set}}}";
|
||||
//}
|
||||
|
||||
public static string ToMethodText(this IMethodSymbol method)
|
||||
{
|
||||
var parameters = new List<string>();
|
||||
foreach (var ps in method.Parameters)
|
||||
{
|
||||
parameters.Add($"{ps.Type} {ps.Name}");
|
||||
}
|
||||
|
||||
return $"{method.ReturnType} {method.Name}({string.Join(", ", parameters)})";
|
||||
}
|
||||
|
||||
public static string ToMethodTextForClass(this IMethodSymbol method)
|
||||
{
|
||||
var parameters = new List<string>();
|
||||
foreach (var ps in method.Parameters)
|
||||
{
|
||||
parameters.Add($"{ps.Name}");
|
||||
}
|
||||
|
||||
return $"{method.ToMethodText()} => _Instance.{method.Name}({string.Join(", ", parameters)});";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user