Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasnordqvist committed Nov 10, 2024
1 parent 1b9daf3 commit d00de3f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ public static partial class Mappers
var isIsDraftPropertyDefined = jsonElement.TryGetProperty("IsDraft", out var jsonIsDraftProperty);
if (isIsDraftPropertyDefined)
{
// type = Nullable, isOption = False, isNullable = True
// type = Boolean, isOption = False, isNullable = True
if (jsonIsDraftProperty.ValueKind == JsonValueKind.Null)
{
errors.Add(new RequiredValueMissingError([.. path, "IsDraft"]));
}
else if (jsonIsDraftProperty.ValueKind == JsonValueKind.True || jsonIsDraftProperty.ValueKind == JsonValueKind.False)
{
obj.IsDraft = jsonIsDraftProperty.GetBoolean();
}
else
{
errors.Add(new ValueHasWrongTypeError([.. path, "IsDraft"], "Boolean", jsonIsDraftProperty.ValueKind.ToString()));
}
}
else
{
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 4 additions & 1 deletion MapperGenerator/MapperGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ static bool IsSyntaxTargetForGeneration(SyntaxNode node)
: ((INamedTypeSymbol)p.Type).TypeArguments.First().Name;

var isNullable = t.IsNullable();

if (t.IsNullableValueType())
{
tName = ((INamedTypeSymbol)p.Type).TypeArguments.First().Name;
}
properties.Add(new PropertyToGenerateMapperFor(p.Name, tName, isOptions, isNullable));
}
}
Expand Down

0 comments on commit d00de3f

Please sign in to comment.