-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
242de30
commit 4da294c
Showing
20 changed files
with
686 additions
and
252 deletions.
There are no files selected for viewing
18 changes: 10 additions & 8 deletions
18
...nerator/MapperGenerator.MapperGenerator/Mapper.FartingUnicorn.Benchmarks.UserProfile.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
...pper.FartingUnicorn.Tests.SingleField.BoolType.NonNullableNonOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
.../Mapper.FartingUnicorn.Tests.SingleField.BoolType.NonNullableOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
.../Mapper.FartingUnicorn.Tests.SingleField.BoolType.NullableNonOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
...tor/Mapper.FartingUnicorn.Tests.SingleField.BoolType.NullableOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...pper.FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
using static FartingUnicorn.MapperOptions; | ||
|
||
namespace FartingUnicorn.Generated; | ||
|
||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost> MapToFartingUnicorn_Tests_SingleField_EnumType_NonNullableNonOptional_Tests_BlogPost(JsonElement jsonElement, MapperOptions mapperOptions = null, string[] path = null) | ||
{ | ||
if (mapperOptions is null) | ||
{ | ||
mapperOptions = new MapperOptions(); | ||
} | ||
if (path is null) | ||
{ | ||
path = ["$"]; | ||
} | ||
if (jsonElement.ValueKind != JsonValueKind.Object) | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost>.Error(new ValueHasWrongTypeError(path, "Object", jsonElement.ValueKind.ToString())); | ||
} | ||
var obj = new FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost(); | ||
|
||
List<IError> errors = new(); | ||
var isStatusPropertyDefined = jsonElement.TryGetProperty("Status", out var jsonStatusProperty); | ||
if (isStatusPropertyDefined) | ||
{ | ||
// type = FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost.BlogPostStatus, isOption = False, isNullable = False | ||
if (jsonStatusProperty.ValueKind == JsonValueKind.Null) | ||
{ | ||
errors.Add(new RequiredValueMissingError([.. path, "Status"])); | ||
} | ||
if (mapperOptions.TryGetConverter(typeof(FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost.BlogPostStatus), out IConverter customConverter)) | ||
{ | ||
if (jsonStatusProperty.ValueKind != customConverter.ExpectedJsonValueKind) | ||
{ | ||
errors.Add(new ValueHasWrongTypeError(path, customConverter.ExpectedJsonValueKind.ToString(), jsonStatusProperty.ValueKind.ToString())); | ||
} | ||
var result = customConverter.Convert(typeof(FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost.BlogPostStatus), jsonStatusProperty, mapperOptions, path); | ||
if (result.Success) | ||
{ | ||
obj.Status = result.Map(x => (FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost.BlogPostStatus)x).Value; | ||
} | ||
else | ||
{ | ||
errors.AddRange(result.Errors.Select(x => new MappingError(path, x.Message)).ToArray()); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
errors.Add(new RequiredPropertyMissingError([.. path, "Status"])); | ||
} | ||
if(errors.Any()) | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost>.Error(errors); | ||
} | ||
if(false)/*check if is option*/ | ||
{ | ||
} | ||
else | ||
{ | ||
return Result<FartingUnicorn.Tests.SingleField.EnumType.NonNullableNonOptional_Tests.BlogPost>.Ok(obj); | ||
} | ||
throw new NotImplementedException(); | ||
} | ||
} |
18 changes: 10 additions & 8 deletions
18
...apper.FartingUnicorn.Tests.SingleField.IntType.NonNullableNonOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
...r/Mapper.FartingUnicorn.Tests.SingleField.IntType.NonNullableOptional_Tests.BlogPost.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.