Add support for parameter attributes (#48)

* 1

* 2

* 3

* .

* x
This commit is contained in:
Stef Heyenrath
2022-12-17 11:28:16 +01:00
committed by GitHub
parent 02c0c7f4d2
commit a1a283c8bb
17 changed files with 136 additions and 65 deletions
@@ -0,0 +1,25 @@
using System.Text;
using Microsoft.CodeAnalysis;
using ProxyInterfaceSourceGenerator.Extensions;
namespace ProxyInterfaceSourceGenerator.Builders;
internal static class MethodParameterBuilder
{
public static string Build(IParameterSymbol parameterSymbol, string? type)
{
var stringBuilder = new StringBuilder();
if (type is { })
{
stringBuilder.Append(parameterSymbol.GetAttributesPrefix()); // "" or [NotNullWhen(true)]
stringBuilder.Append(parameterSymbol.GetParamsPrefix()); // "" or "params "
stringBuilder.Append(parameterSymbol.GetRefPrefix()); // "" or "out "
stringBuilder.AppendFormat("{0} ", type); // string or another type
}
stringBuilder.Append(parameterSymbol.GetSanitizedName()); // "s" or "i" or ...
stringBuilder.Append(parameterSymbol.GetDefaultValue()); // "" or the value
return stringBuilder.ToString();
}
}