Repository: microsoft/kiota (csharp)

Issue:
Incorrect parameter ordering for CancellationToken in generated RequestBuilder code
### What are you generating using Kiota, clients or plugins?

API Client/SDK

### In what context or format are you using Kiota?

Windows executable

### Client library/SDK language

Csharp

### Describe the bug

The generated API client code fails to compile with the following error:
```
Argument 3: cannot convert from 'System.Threading.CancellationToken' 
to 'System.Collections.Generic.Dictionary<string, 
Microsoft.Kiota.Abstractions.Serialization.ParsableFactory
<Microsoft.Kiota.Abstractions.Serialization.IParsable>>?'
```

### Expected behavior

The generated code should compile without errors.  Specifically, the 'cancellationToken' parameter should be preceded by 'null', as in:

```csharp
var requestInfo = ToDeleteRequestInformation(requestConfiguration);
return await RequestAdapter.SendAsync<UntypedNode>(requestInfo, default, **null**, cancellationToken).ConfigureAwait(false);
```


### How to reproduce

1. Create a new .NET class library project.
2. Generate the C# Api client.
3. Compile the project.

### Open API description file

_No response_

### Kiota Version

1.14.0

### Latest Kiota version known to work for scenario above?(Not required)

_No response_

### Known Workarounds

Manually edit the generated code.

### Configuration

Windows 11 x64

### Debug output

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


### Other information

_No response_

Pull request description:
Fixes https://github.com/microsoft/kiota/issues/4692

Fixes missing `UntypedNode.CreateFromDiscriminatorValue` parameter in method writer.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8898560629..a8523e155e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Fixes a bug where paths without operationIds would not be included in the generated plugins and ensured operationIds are cleaned up [#4642](https://github.com/microsoft/kiota/issues/4642)
 - Fixes a bug where models would be duplicated in some allOf scenarios [#4191](https://github.com/microsoft/kiota/issues/4191)
 - Fixes a bug where CLI Generation does not handle path parameters of type "string" and format "date", "date-time", "time", etc. [#4615](https://github.com/microsoft/kiota/issues/4615)
+- Fixes a bug where request executors would be missing Untyped parameters in dotnet [#4692](https://github.com/microsoft/kiota/issues/4692)
 
 ## [1.14.0] - 2024-05-02
 
diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs
index 889e348f43..66d29a759f 100644
--- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs
+++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs
@@ -394,7 +394,7 @@ protected void WriteRequestExecutorBody(CodeMethod codeElement, RequestParams re
             writer.CloseBlock("};");
         }
         var returnTypeCodeType = codeElement.ReturnType as CodeType;
-        var returnTypeFactory = returnTypeCodeType?.TypeDefinition is CodeClass
+        var returnTypeFactory = returnTypeCodeType?.TypeDefinition is CodeClass || (returnTypeCodeType != null && returnTypeCodeType.Name.Equals(KiotaBuilder.UntypedNodeName, StringComparison.OrdinalIgnoreCase))
                                 ? $", {returnTypeWithoutCollectionInformation}.CreateFromDiscriminatorValue"
                                 : null;
         var prefix = (isVoid, codeElement.ReturnType.IsCollection) switch


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs
index 06fdbf7d21..ae87bd46ba 100644
--- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs
+++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs
@@ -482,6 +482,32 @@ public void WritesRequestExecutorBody()
         AssertExtensions.CurlyBracesAreClosed(result, 1);
     }
     [Fact]
+    public void WritesRequestExecutorBodyWithUntypedReturnValue()
+    {
+        setup();
+        method.Kind = CodeMethodKind.RequestExecutor;
+        method.HttpMethod = HttpMethod.Get;
+        method.ReturnType = new CodeType { TypeDefinition = null, Name = KiotaBuilder.UntypedNodeName };
+        var errorXXX = root.AddClass(new CodeClass
+        {
+            Name = "ErrorXXX",
+        }).First();
+        method.AddErrorMapping("XXX", new CodeType { Name = "ErrorXXX", TypeDefinition = errorXXX });
+        AddRequestBodyParameters();
+        writer.Write(method);
+        var result = tw.ToString();
+        Assert.Contains("var requestInfo", result);
+        Assert.Contains("var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>", result);
+        Assert.Contains("<exception cref=", result);
+        Assert.Contains("{ \"XXX\", ErrorXXX.CreateFromDiscriminatorValue },", result);
+        Assert.Contains("SendAsync", result);
+        Assert.Contains("UntypedNode.CreateFromDiscriminatorValue", result);
+        Assert.Contains(AsyncKeyword, result);
+        Assert.Contains("await", result);
+        Assert.Contains("cancellationToken", result);
+        AssertExtensions.CurlyBracesAreClosed(result, 1);
+    }
+    [Fact]
     public void WritesRequestGeneratorBodyForMultipart()
     {
         setup();