Fix Default value (#19)

This commit is contained in:
Stef Heyenrath
2021-07-31 20:10:46 +02:00
committed by GitHub
parent 0802766c66
commit a1d23422dc
9 changed files with 137 additions and 113 deletions
@@ -0,0 +1,35 @@
using Microsoft.CodeAnalysis;
using ProxyInterfaceSourceGenerator.Enums;
namespace ProxyInterfaceSourceGenerator.Extensions
{
internal static class ParameterSymbolExtensions
{
public static string GetRefPrefix(this IParameterSymbol ps)
{
switch (ps.RefKind)
{
case RefKind.In:
return "in ";
case RefKind.Out:
return "out ";
case RefKind.Ref:
return "ref ";
default:
return string.Empty;
}
}
public static string GetParamsPrefix(this IParameterSymbol ps) =>
ps.IsParams ? "params " : string.Empty;
public static string GetDefaultValue(this IParameterSymbol ps) =>
ps.HasExplicitDefaultValue ? $" = {ps.ExplicitDefaultValue}" : string.Empty;
public static TypeEnum GetTypeEnum(this IParameterSymbol p) =>
p.Type.GetTypeEnum();
}
}