Fixed multi-dimension argument / return type (#55)

* Fixed multi dimension array arguments

* .

* .

* .

* ,
This commit is contained in:
Stef Heyenrath
2023-02-21 19:10:03 +01:00
committed by GitHub
parent 196db037ab
commit 65d1d801ce
8 changed files with 36 additions and 8 deletions
@@ -11,6 +11,8 @@ namespace ProxyInterfaceSourceGenerator.FileGenerators;
internal abstract class BaseGenerator
{
private const string Star = "*";
protected readonly Context Context;
protected readonly bool SupportsNullable;
@@ -150,7 +152,7 @@ internal abstract class BaseGenerator
}
isReplaced = true;
return existing.FullInterfaceName;
return FixType(existing.FullInterfaceName);
}
ITypeSymbol[] typeArguments;
@@ -164,7 +166,7 @@ internal abstract class BaseGenerator
}
else
{
return typeSymbolAsString;
return FixType(typeSymbolAsString);
}
var propertyTypeAsStringToBeModified = typeSymbolAsString;
@@ -185,7 +187,7 @@ internal abstract class BaseGenerator
}
}
return propertyTypeAsStringToBeModified;
return FixType(propertyTypeAsStringToBeModified);
}
protected bool TryGetNamedTypeSymbolByFullName(TypeKind kind, string name, IEnumerable<string> usings, [NotNullWhen(true)] out ClassSymbol? classSymbol)
@@ -258,4 +260,13 @@ internal abstract class BaseGenerator
}
return extendsProxyClasses;
}
/// <summary>
/// Issue 54
/// double[*,*] --> double[,]
/// </summary>
protected static string FixType(string type)
{
return type.Replace(Star, string.Empty);
}
}
@@ -235,6 +235,7 @@ using System;
str.AppendLine(" {");
foreach (var ps in method.Parameters)
{
var type = FixType(ps.Type.ToString());
string normalOrMap = $" = {ps.GetSanitizedName()}";
if (ps.RefKind == RefKind.Out)
{
@@ -245,11 +246,11 @@ using System;
_ = GetParameterType(ps, out var isReplaced); // TODO : response is not used?
if (isReplaced)
{
normalOrMap = $" = Mapster.TypeAdapter.Adapt<{ps.Type}>({ps.GetSanitizedName()})";
normalOrMap = $" = Mapster.TypeAdapter.Adapt<{type}>({ps.GetSanitizedName()})";
}
}
str.AppendLine($" {ps.Type} {ps.GetSanitizedName()}_{normalOrMap};");
str.AppendLine($" {type} {ps.GetSanitizedName()}_{normalOrMap};");
}
var methodName = method.GetMethodNameWithOptionalTypeParameters();