This commit is contained in:
Stef Heyenrath
2021-07-23 22:10:08 +02:00
parent d129f52441
commit 36fdd645b1
12 changed files with 112 additions and 69 deletions
@@ -1,12 +1,11 @@
using System.Collections.Generic;
using System.Text;
using Microsoft.CodeAnalysis;
namespace ProxyInterfaceSourceGenerator.Extensions
{
internal static class SymbolExtensions
{
public static string ToCode(this IPropertySymbol property)
public static string ToPropertyTextForInterface(this IPropertySymbol property)
{
string get = property.GetMethod != null ? "get; " : string.Empty;
string set = property.SetMethod != null ? "set; " : string.Empty;
@@ -14,7 +13,7 @@ namespace ProxyInterfaceSourceGenerator.Extensions
return $"{property.Type} {property.Name} {{ {get}{set}}}";
}
public static string ToProxyCode(this IPropertySymbol property)
public static string ToPropertyTextForClass(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;
@@ -22,7 +21,7 @@ namespace ProxyInterfaceSourceGenerator.Extensions
return $"{property.Type} {property.Name} {{ {get}{set}}}";
}
public static string ToCode(this IMethodSymbol method)
public static string ToMethodTextForInterface(this IMethodSymbol method)
{
var parameters = new List<string>();
foreach (var ps in method.Parameters)
@@ -33,7 +32,7 @@ namespace ProxyInterfaceSourceGenerator.Extensions
return $"{method.ReturnType} {method.Name}({string.Join(", ", parameters)})";
}
public static string ToProxyCode(this IMethodSymbol method)
public static string ToMethodTextForClass(this IMethodSymbol method)
{
var parameters = new List<string>();
foreach (var ps in method.Parameters)
@@ -41,7 +40,7 @@ namespace ProxyInterfaceSourceGenerator.Extensions
parameters.Add($"{ps.Name}");
}
return $"{method.ToCode()} => _instance.{method.Name}({string.Join(", ", parameters)});";
return $"{method.ToMethodTextForInterface()} => _instance.{method.Name}({string.Join(", ", parameters)});";
}
}
}