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();
@@ -46,6 +46,8 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
System.Threading.Tasks.Task<string?> Method3Async();
void CreateInvokeHttpClient(int i = 5, string? appId = null);
@@ -105,6 +105,13 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
return result__57684656;
}
public void CreateInvokeHttpClient(int i = 5, string? appId = null)
{
int i_ = i;
string? appId_ = appId;
_Instance.CreateInvokeHttpClient(i_, appId_);
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace ProxyInterfaceSourceGeneratorTests.Source
@@ -67,5 +68,9 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
{
return Task.FromResult((string?)"");
}
public void CreateInvokeHttpClient(int i = 5, string? appId = null)
{
}
}
}