From f766c17792555fa3d7ef26943764b019970677b1 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:48:18 +0300 Subject: [PATCH 1/6] Update CSharpRefiner.cs --- src/Kiota.Builder/Refiners/CSharpRefiner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kiota.Builder/Refiners/CSharpRefiner.cs b/src/Kiota.Builder/Refiners/CSharpRefiner.cs index 5e36de1890..2a78396e7d 100644 --- a/src/Kiota.Builder/Refiners/CSharpRefiner.cs +++ b/src/Kiota.Builder/Refiners/CSharpRefiner.cs @@ -171,7 +171,7 @@ protected static void MakeEnumPropertiesNullable(CodeElement currentElement) new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder), "System.Threading.Tasks", "Task"), new (static x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model, CodeClassKind.RequestBuilder), - "System.Linq", "Enumerable"), + ExtensionsNamespaceName, "Enumerable"), new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor) && method.Parameters.Any(y => y.IsOfKind(CodeParameterKind.BackingStore)), StoreNamespaceName, "IBackingStoreFactory", "IBackingStoreFactorySingleton"), From 23c5ddfeffc4e99216064dfd288b74b56040a937 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:48:51 +0300 Subject: [PATCH 2/6] Update CodeMethodWriter.cs --- src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index 796e6a91ac..655512761c 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -10,8 +10,8 @@ public class CodeMethodWriter : BaseElementWriter(){collectionMethod}"; else if (currentType.TypeDefinition is CodeEnum) From 9d8c9a7164b14303eeb1b20efe2743cdb1680ecb Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:44:44 +0300 Subject: [PATCH 3/6] Update dotnet.csproj --- it/csharp/dotnet.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/it/csharp/dotnet.csproj b/it/csharp/dotnet.csproj index 9c51f10874..a79f9605bd 100644 --- a/it/csharp/dotnet.csproj +++ b/it/csharp/dotnet.csproj @@ -10,7 +10,7 @@ - + @@ -21,4 +21,4 @@ - \ No newline at end of file + From 648449c4ac39c51c9cc83517ae436f1c1208ae68 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:45:47 +0300 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01068b4d5c..30ce596928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - TypeScript imports are now using ES6 imports with the .js extension. +- Remove LINQ usage in generated code. ## [1.15.0] - 2024-06-06 From 87a9f87c4ed597d68e500faa2f10983f34d79a01 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:23:10 +0300 Subject: [PATCH 5/6] Update tests --- .../Writers/CSharp/CodeMethodWriterTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs index 2fe8182ed3..17fb96c17a 100644 --- a/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs @@ -542,7 +542,7 @@ public void WritesRequestExecutorBodyForCollection() Assert.Contains("var errorMapping = new Dictionary>", result); Assert.Contains("{ \"4XX\", Error4XX.CreateFromDiscriminatorValue },", result); Assert.Contains("SendCollectionAsync", result); - Assert.Contains("return collectionResult?.ToList()", result); + Assert.Contains("return collectionResult?.AsList()", result); Assert.Contains($"{ReturnTypeName}.CreateFromDiscriminatorValue", result); AssertExtensions.CurlyBracesAreClosed(result, 1); } @@ -592,7 +592,7 @@ public void WritesModelFactoryBodyForUnionModels() Assert.Contains("ComplexType1Value = new ComplexType1()", result); Assert.Contains("else if(parseNode.GetStringValue() is string stringValueValue)", result); Assert.Contains("StringValue = stringValueValue", result); - Assert.Contains("parseNode.GetCollectionOfObjectValues(ComplexType2.CreateFromDiscriminatorValue)?.ToList() is List complexType2ValueValue", result); + Assert.Contains("parseNode.GetCollectionOfObjectValues(ComplexType2.CreateFromDiscriminatorValue)?.AsList() is List complexType2ValueValue", result); Assert.Contains("ComplexType2Value = complexType2ValueValue", result); Assert.Contains("return result", result); AssertExtensions.Before("GetStringValue() is string stringValueValue", "GetCollectionOfObjectValues", result); @@ -631,7 +631,7 @@ public void WritesModelFactoryBodyForIntersectionModels() Assert.DoesNotContain("if(\"#kiota.complexType1\".Equals(mappingValue, StringComparison.OrdinalIgnoreCase))", result); Assert.Contains("if(parseNode.GetStringValue() is string stringValueValue)", result); Assert.Contains("StringValue = stringValueValue", result); - Assert.Contains("parseNode.GetCollectionOfObjectValues(ComplexType2.CreateFromDiscriminatorValue)?.ToList() is List complexType2ValueValue", result); + Assert.Contains("parseNode.GetCollectionOfObjectValues(ComplexType2.CreateFromDiscriminatorValue)?.AsList() is List complexType2ValueValue", result); Assert.Contains("ComplexType2Value = complexType2ValueValue", result); Assert.Contains("ComplexType1Value = new ComplexType1()", result); Assert.Contains("return result", result); From 61dc4ef573d63fb595e2bbd1943aa2ed25d06bc8 Mon Sep 17 00:00:00 2001 From: kasperk81 <83082615+kasperk81@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:08:38 +0300 Subject: [PATCH 6/6] Update CodeMethodWriter.cs --- src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index 655512761c..ead9a4484b 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -407,7 +407,7 @@ protected void WriteRequestExecutorBody(CodeMethod codeElement, RequestParams re }; writer.WriteLine($"{prefix}await RequestAdapter.{GetSendRequestMethodName(isVoid, codeElement, codeElement.ReturnType)}(requestInfo{returnTypeFactory}, {errorMappingVarName}, cancellationToken).ConfigureAwait(false);"); if (codeElement.ReturnType.IsCollection) - writer.WriteLine("return collectionResult?.ToList();"); + writer.WriteLine("return collectionResult?.AsList();"); } private const string RequestInfoVarName = "requestInfo"; private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams requestParams, CodeClass currentClass, LanguageWriter writer)