Repository: microsoft/kiota (csharp)

Issue:
User update throws with "AdditionalData can not be null" after migration from 5.47.0 to 5.51.0
### Describe the bug

I am trying to [update the settings](https://learn.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=http) of a user. It was working fine up to now, but after the migration to 5.51.0 it crashes out with "AdditionalData can not be null". 

### Expected behavior

Users can be updated without the sdk crashing. Might relate to the user update endpoint not returning any body but just a 204.

### How to reproduce

Just try to update any user with version 5.51.0
```csharp
const string userId = "user-id";
var user = await _client.Users[userId].GetAsync(cancellationToken: cancellationToken);
user.City += "a";
await _client.Users[userId].PatchAsync(user, cancellationToken: cancellationToken);
```

### SDK Version

5.51.0

### Latest version known to work for scenario above?

5.47.0

### Known Workarounds

_No response_

### Debug output

<details><summary>Click to expand log</summary>
```

<Log output here>

```
</details>


### Configuration

_No response_

### Other information

_No response_

Pull request:
This PR is a follow up to https://github.com/microsoft/kiota/pull/4514

It changes the default of the retrieval of the `addtionalData` from `backingstore` to return an empty dictionary rather than throwing an error in the event the value is null. This is because of the scenario where the `addtionalData` property is unchanged the backingstore will return a null value to signal the propet is not among the change values. 

Fixes https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2471

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9aba71fd3e..3386f8429c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,9 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 
-- Aligns naming of sliced OpenAPI description generated by `plugin add` should be named `<plugin-name>-openapi.json|yml`
+- Aligns naming of sliced OpenAPI description generated by `plugin add` should be named `<plugin-name>-openapi.json|yml` [#4595](https://github.com/microsoft/kiota/issues/4595)
 - Fixed RPC server to respect the `KIOTA_CONFIG_PREVIEW` flag.
 - Fixed handling of nested arrays to be handled as `UntypedNode` instances [#4549](https://github.com/microsoft/kiota/issues/4549)
+- Fixed `InvalidOperationException` thrown when serializing IBacked models with no changes present in the additional data in dotnet [microsoftgraph/msgraph-sdk-dotnet#2471](https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2471). 
 
 ## [1.14.0] - 2024-05-02
 
diff --git a/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs
index 4b0baaf35c..4920ea7360 100644
--- a/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs
+++ b/src/Kiota.Builder/Writers/CSharp/CodePropertyWriter.cs
@@ -50,11 +50,11 @@ private void WritePropertyInternal(CodeProperty codeElement, LanguageWriter writ
             case CodePropertyKind.AdditionalData when backingStoreProperty != null:
             case CodePropertyKind.Custom when backingStoreProperty != null:
                 var backingStoreKey = codeElement.WireName;
-                var nullableOp = !codeElement.IsOfKind(CodePropertyKind.AdditionalData) ? "?" : string.Empty;
-                var nullableEx = codeElement.IsOfKind(CodePropertyKind.AdditionalData) ? " ?? throw new InvalidOperationException(\"AdditionalData can not be null\")" : string.Empty;
+                var nullableOp = !codeElement.IsOfKind(CodePropertyKind.AdditionalData) ? "?" : string.Empty;
+                var defaultPropertyValue = codeElement.IsOfKind(CodePropertyKind.AdditionalData) ? " ?? new Dictionary<string, object>()" : string.Empty;
                 writer.WriteLine($"{conventions.GetAccessModifier(codeElement.Access)} {propertyType} {codeElement.Name.ToFirstCharacterUpperCase()} {{");
                 writer.IncreaseIndent();
-                writer.WriteLine($"get {{ return {backingStoreProperty.Name.ToFirstCharacterUpperCase()}{nullableOp}.Get<{propertyType}>(\"{backingStoreKey}\"){nullableEx}; }}");
+                writer.WriteLine($"get {{ return {backingStoreProperty.Name.ToFirstCharacterUpperCase()}{nullableOp}.Get<{propertyType}>(\"{backingStoreKey}\"){defaultPropertyValue}; }}");
                 writer.WriteLine($"set {{ {backingStoreProperty.Name.ToFirstCharacterUpperCase()}{nullableOp}.Set(\"{backingStoreKey}\", value); }}");
                 writer.DecreaseIndent();
                 writer.WriteLine("}");


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodePropertyWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodePropertyWriterTests.cs
index a1d78fd859..a12cd43520 100644
--- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodePropertyWriterTests.cs
+++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodePropertyWriterTests.cs
@@ -113,7 +113,7 @@ public void MapsAdditionalDataPropertiesToBackingStore()
         property.Kind = CodePropertyKind.AdditionalData;
         writer.Write(property);
         var result = tw.ToString();
-        Assert.Contains("get { return BackingStore.Get<SomeCustomClass>(\"propertyName\") ?? throw new InvalidOperationException(\"AdditionalData can not be null\"); }", result);
+        Assert.Contains("get { return BackingStore.Get<SomeCustomClass>(\"propertyName\") ?? new Dictionary<string, object>(); }", result);
         Assert.Contains("set { BackingStore.Set(\"propertyName\", value);", result);
     }
     [Fact]