eol to not have to setup certain parametres with null

This commit is contained in:
honzapatCZ 2024-10-14 22:50:30 +02:00
parent 501291c548
commit 0be24c0990

View File

@ -279,12 +279,12 @@ namespace AutoMapProperty
IMethodSymbol? customFromMethod = null;
bool customTo = false;
IMethodSymbol? customToMethod = null;
if (attr.ConstructorArguments.Count() >= 3)
if (attr.ConstructorArguments.Count() >= 3 && attr.ConstructorArguments[2].Value is not null)
{
customTo = true;
customToMethod = ProcessCustomAttribute(context, classSymbol, attr.ConstructorArguments[2]);
}
if (attr.ConstructorArguments.Count() >= 4)
if (attr.ConstructorArguments.Count() >= 4 && attr.ConstructorArguments[3].Value is not null)
{
customFrom = true;
customFromMethod = ProcessCustomAttribute(context, classSymbol, attr.ConstructorArguments[3]);
@ -599,7 +599,7 @@ namespace AutoMapProperty
return null;
StringBuilder sb = new StringBuilder();
sb.Append(Key).Append(" = (").Append(GetFullString(Value.ToType)).Append(@")").Append(GetFullMethodName(Value.CustomFromMethod)).Append(@"(providers, source, source").Append(prefix).Append(".").Append(Key).Append(")");
sb.Append(Key).Append(" = (").Append(GetFullString(Value.ToType)).Append(@")").Append(GetFullMethodName(Value.CustomFromMethod)).Append(@"(providers, source").Append(prefix).Append(", source").Append(prefix).Append(".").Append(Key).Append(")");
return sb.ToString();
}
}