Skip to content

Commit

Permalink
Fix bug copying nullable. Fixes #99. (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejball authored Nov 13, 2024
1 parent 7cff5c5 commit b2e5385
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Facility.CodeGen.CSharp/CSharpGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,8 @@ private CodeGenFile GenerateHttpMapping(HttpServiceInfo httpServiceInfo, Context
foreach (var field in httpMethodInfo.RequestNormalFields)
{
var fieldName = context.GetFieldPropertyName(field.ServiceField);
code.WriteLine($"{fieldName} = (({requestTypeName}?) body)?.{fieldName},");
var fieldType = context.GetFieldType(field.ServiceField);
code.WriteLine($"{fieldName} = (({requestTypeName}?) body)?.{fieldName}{(fieldType.Kind == ServiceTypeKind.Nullable ? " ?? default" : "")},");
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tools/EdgeCases.fsd
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,14 @@ service EdgeCases
foo: ExternalData;
bar: ExternalEnum;
}

method misc
{
[http(from: "query")]
q: string;

f: nullable<string>;
}:
{
}
}
3 changes: 3 additions & 0 deletions tools/EdgeCases/DelegatingEdgeCases.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tools/EdgeCases/EdgeCasesJsonSerializerContext.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tools/EdgeCases/EdgeCasesMethods.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tools/EdgeCases/Http/EdgeCasesHttpHandler.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions tools/EdgeCases/Http/EdgeCasesHttpMapping.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tools/EdgeCases/Http/HttpClientEdgeCases.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tools/EdgeCases/IEdgeCases.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions tools/EdgeCases/MiscRequestDto.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions tools/EdgeCases/MiscResponseDto.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b2e5385

Please sign in to comment.