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
|
||||
{
|
||||
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
|
||||
|
||||
System.Threading.Tasks.Task<string?> Method3Async();
|
||||
|
||||
void CreateInvokeHttpClient(int i = 5, string? appId = null);
|
||||
void CreateInvokeHttpClient(int i = 5, string? appId = null, System.Threading.CancellationToken token = default);
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -105,11 +105,12 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
|
||||
return result__57684656;
|
||||
}
|
||||
|
||||
public void CreateInvokeHttpClient(int i = 5, string? appId = null)
|
||||
public void CreateInvokeHttpClient(int i = 5, string? appId = null, System.Threading.CancellationToken token = default)
|
||||
{
|
||||
int i_ = i;
|
||||
string? appId_ = appId;
|
||||
_Instance.CreateInvokeHttpClient(i_, appId_);
|
||||
System.Threading.CancellationToken token_ = token;
|
||||
_Instance.CreateInvokeHttpClient(i_, appId_, token_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source
|
||||
@@ -69,7 +70,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
|
||||
return Task.FromResult((string?)"");
|
||||
}
|
||||
|
||||
public void CreateInvokeHttpClient(int i = 5, string? appId = null)
|
||||
public void CreateInvokeHttpClient(int i = 5, string? appId = null, CancellationToken token = default)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user