Fix issue #4 (string?) (#15)

* #4

* Only replace if required

* fix

* private readonly IMapper _mapper;

* CRLF
This commit is contained in:
Stef Heyenrath
2021-07-26 16:24:30 +02:00
committed by GitHub
parent 6f9a29a4b7
commit 86ef9ede98
9 changed files with 396 additions and 354 deletions
@@ -7,17 +7,7 @@ namespace ProxyInterfaceSourceGenerator.Extensions
{
public static TypeEnum GetTypeEnum(this IPropertySymbol p)
{
if (p.Type.IsValueType || p.Type.ToString() == "string")
{
return TypeEnum.ValueTypeOrString;
}
if (p.Type.TypeKind == TypeKind.Interface)
{
return TypeEnum.Interface;
}
return TypeEnum.Complex;
return GetTypeEnum(p.Type);
}
public static TypeEnum GetTypeEnum(this IParameterSymbol p)
@@ -27,7 +17,7 @@ namespace ProxyInterfaceSourceGenerator.Extensions
public static TypeEnum GetTypeEnum(this ITypeSymbol ts)
{
if (ts.IsValueType || ts.ToString() == "string")
if (ts.IsValueType || ts.IsString())
{
return TypeEnum.ValueTypeOrString;
}
@@ -40,6 +30,11 @@ namespace ProxyInterfaceSourceGenerator.Extensions
return TypeEnum.Complex;
}
public static bool IsString(this ITypeSymbol ts)
{
return ts.ToString() == "string" || ts.ToString() == "string?";
}
public static string ToPropertyText(this IPropertySymbol property, string? overrideType = null)
{
var get = property.GetMethod != null ? "get; " : string.Empty;