add methods
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ProxyInterfaceSourceGenerator.Extensions
|
||||
@@ -13,6 +14,14 @@ namespace ProxyInterfaceSourceGenerator.Extensions
|
||||
return $"{property.Type} {property.Name} {{ {get}{set}}}";
|
||||
}
|
||||
|
||||
public static string ToProxyCode(this IPropertySymbol property)
|
||||
{
|
||||
string get = property.GetMethod != null ? $"get => _instance.{property.Name}; " : string.Empty;
|
||||
string set = property.SetMethod != null ? $"set => _instance.{property.Name} = value; " : string.Empty;
|
||||
|
||||
return $"{property.Type} {property.Name} {{ {get}{set}}}";
|
||||
}
|
||||
|
||||
public static string ToCode(this IMethodSymbol method)
|
||||
{
|
||||
var parameters = new List<string>();
|
||||
@@ -21,7 +30,18 @@ namespace ProxyInterfaceSourceGenerator.Extensions
|
||||
parameters.Add($"{ps.Type} {ps.Name}");
|
||||
}
|
||||
|
||||
return $"{method.ReturnType} {method.Name}({string.Join(", ", parameters)});";
|
||||
return $"{method.ReturnType} {method.Name}({string.Join(", ", parameters)})";
|
||||
}
|
||||
|
||||
public static string ToProxyCode(this IMethodSymbol method)
|
||||
{
|
||||
var parameters = new List<string>();
|
||||
foreach (var ps in method.Parameters)
|
||||
{
|
||||
parameters.Add($"{ps.Name}");
|
||||
}
|
||||
|
||||
return $"{method.ToCode()} => _instance.{method.Name}({string.Join(", ", parameters)});";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user