Fix for default parameter (default) (#33)

This commit is contained in:
Stef Heyenrath
2022-05-08 10:17:48 +02:00
committed by GitHub
parent 63bcad4c26
commit cab6a1ea77
5 changed files with 21 additions and 15 deletions
@@ -5,6 +5,9 @@ namespace ProxyInterfaceSourceGenerator.Extensions;
internal static class ParameterSymbolExtensions
{
private const string ParameterValueDefault = "default";
private const string ParameterValueNull = "null";
public static string GetRefPrefix(this IParameterSymbol ps)
{
switch (ps.RefKind)
@@ -33,7 +36,18 @@ internal static class ParameterSymbolExtensions
return string.Empty;
}
var defaultValue = ps.ExplicitDefaultValue ?? "null";
string defaultValue;
if (ps.ExplicitDefaultValue is null)
{
defaultValue = ps.NullableAnnotation == NullableAnnotation.Annotated
? ParameterValueNull
: ParameterValueDefault;
}
else
{
defaultValue = ps.ExplicitDefaultValue.ToString();
}
return $" = {defaultValue}";
}
@@ -1,10 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using ProxyInterfaceSourceGenerator.Models;
namespace ProxyInterfaceSourceGenerator.Extensions;
internal static class TypeParameterSymbolExtensions
{
}