Fix for Explicit DefaultValue is not defined (#31)

* Fix for Explicit DefaultValue is not defined

* .
This commit is contained in:
Stef Heyenrath
2022-05-06 23:57:26 +02:00
committed by GitHub
parent 5bd0f7c3c6
commit 55043701db
4 changed files with 24 additions and 2 deletions
@@ -26,8 +26,16 @@ internal static class ParameterSymbolExtensions
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 string GetDefaultValue(this IParameterSymbol ps)
{
if (!ps.HasExplicitDefaultValue)
{
return string.Empty;
}
var defaultValue = ps.ExplicitDefaultValue ?? "null";
return $" = {defaultValue}";
}
public static TypeEnum GetTypeEnum(this IParameterSymbol p) =>
p.Type.GetTypeEnum();