Fix for default parameter (default) (#33)
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user