From a7962dbdbe6b643a8328159a6ca69f6d61991efe Mon Sep 17 00:00:00 2001 From: Ed Ball Date: Thu, 3 Oct 2024 10:12:20 -0700 Subject: [PATCH 1/2] Handle null body in CreateRequest. --- .../CSharpGenerator.cs | 2 +- .../Http/ConformanceApiHttpMapping.g.cs | 20 +++++++++---------- .../EdgeCases/Http/EdgeCasesHttpMapping.g.cs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Facility.CodeGen.CSharp/CSharpGenerator.cs b/src/Facility.CodeGen.CSharp/CSharpGenerator.cs index fd2f230..0610e73 100644 --- a/src/Facility.CodeGen.CSharp/CSharpGenerator.cs +++ b/src/Facility.CodeGen.CSharp/CSharpGenerator.cs @@ -910,7 +910,7 @@ private CodeGenFile GenerateHttpMapping(HttpServiceInfo httpServiceInfo, Context foreach (var field in httpMethodInfo.RequestNormalFields) { var fieldName = context.GetFieldPropertyName(field.ServiceField); - code.WriteLine($"{fieldName} = (({requestTypeName}) body{NullableReferenceBang}).{fieldName},"); + code.WriteLine($"{fieldName} = (({requestTypeName}?) body)?.{fieldName},"); } } } diff --git a/src/Facility.ConformanceApi/Http/ConformanceApiHttpMapping.g.cs b/src/Facility.ConformanceApi/Http/ConformanceApiHttpMapping.g.cs index f10e6bd..76c18eb 100644 --- a/src/Facility.ConformanceApi/Http/ConformanceApiHttpMapping.g.cs +++ b/src/Facility.ConformanceApi/Http/ConformanceApiHttpMapping.g.cs @@ -516,7 +516,7 @@ public static partial class ConformanceApiHttpMapping CreateRequest = body => new MixedRequestDto { - Normal = ((MixedRequestDto) body!).Normal, + Normal = ((MixedRequestDto?) body)?.Normal, }, ResponseMappings = { @@ -596,15 +596,15 @@ public static partial class ConformanceApiHttpMapping CreateRequest = body => new RequiredRequestDto { - Normal = ((RequiredRequestDto) body!).Normal, - Widget = ((RequiredRequestDto) body!).Widget, - Widgets = ((RequiredRequestDto) body!).Widgets, - WidgetMatrix = ((RequiredRequestDto) body!).WidgetMatrix, - WidgetResult = ((RequiredRequestDto) body!).WidgetResult, - WidgetResults = ((RequiredRequestDto) body!).WidgetResults, - WidgetMap = ((RequiredRequestDto) body!).WidgetMap, - HasWidget = ((RequiredRequestDto) body!).HasWidget, - Point = ((RequiredRequestDto) body!).Point, + Normal = ((RequiredRequestDto?) body)?.Normal, + Widget = ((RequiredRequestDto?) body)?.Widget, + Widgets = ((RequiredRequestDto?) body)?.Widgets, + WidgetMatrix = ((RequiredRequestDto?) body)?.WidgetMatrix, + WidgetResult = ((RequiredRequestDto?) body)?.WidgetResult, + WidgetResults = ((RequiredRequestDto?) body)?.WidgetResults, + WidgetMap = ((RequiredRequestDto?) body)?.WidgetMap, + HasWidget = ((RequiredRequestDto?) body)?.HasWidget, + Point = ((RequiredRequestDto?) body)?.Point, }, ResponseMappings = { diff --git a/tools/EdgeCases/Http/EdgeCasesHttpMapping.g.cs b/tools/EdgeCases/Http/EdgeCasesHttpMapping.g.cs index f848dda..e4546f1 100644 --- a/tools/EdgeCases/Http/EdgeCasesHttpMapping.g.cs +++ b/tools/EdgeCases/Http/EdgeCasesHttpMapping.g.cs @@ -53,7 +53,7 @@ public static partial class EdgeCasesHttpMapping CreateRequest = body => new CustomHttpRequestDto { - Value = ((CustomHttpRequestDto) body!).Value, + Value = ((CustomHttpRequestDto?) body)?.Value, }, ResponseMappings = { From 668c1bce98ffca6566150669d8e40c4d014d5f37 Mon Sep 17 00:00:00 2001 From: Ed Ball Date: Thu, 3 Oct 2024 10:17:25 -0700 Subject: [PATCH 2/2] Publish 2.29.3. --- Directory.Build.props | 4 ++-- ReleaseNotes.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index cae926f..e1fe308 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - 2.29.2 - 2.29.1 + 2.29.3 + 2.29.2 12.0 enable enable diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 0763803..9eeb626 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,6 +1,6 @@ # Release Notes -## 2.29.2 +## 2.29.3 * Allow missing or empty HTTP content to be treated as an empty DTO for backward compatibility with method bodies that previously had no fields.