From 6e3b7d952194f39ccbae518103344744d5c061dc Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 3 Nov 2023 15:44:08 -0400 Subject: [PATCH 1/4] - draft code reduction for generator methods --- src/RequestInformation.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index 930f82b1..5b967d02 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; #if NET5_0_OR_GREATER @@ -21,6 +22,39 @@ namespace Microsoft.Kiota.Abstractions /// public class RequestInformation { + /// + /// Creates a new instance of . + /// + public RequestInformation() + { + + } + /// + /// Creates a new instance of with the given method and url template. + /// + /// + /// + /// + public RequestInformation(Method method, string urlTemplate, IDictionary pathParameters) + { + HttpMethod = method; + UrlTemplate = urlTemplate; + PathParameters = pathParameters; + } + /// + /// Configures the current request configuration headers, query parameters, and options base on the callback provided. + /// + /// Type for the query parameters + /// Callback to configure the request + public void Configure(Action>? requestConfiguration) where T : DefaultQueryParameters, new() + { + if(requestConfiguration == null) return; + var requestConfig = new RequestConfiguration(); + requestConfiguration(requestConfig); + AddQueryParameters(requestConfig.QueryParameters); + AddRequestOptions(requestConfig.Options); + AddHeaders(requestConfig.Headers); + } internal const string RawUrlKey = "request-raw-url"; private Uri? _rawUri; /// From 8bb3a5cfd9d6db8d9f2ca28b38ee5feec6b80b3b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 3 Nov 2023 15:44:57 -0400 Subject: [PATCH 2/4] Remove unused using statement in RequestInformation.cs Signed-off-by: Vincent Biret --- src/RequestInformation.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index 5b967d02..b4e108d3 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -8,7 +8,6 @@ using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; #if NET5_0_OR_GREATER From 27b7bbcf32c7ca96a0171b7768736eb17c35d03f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 7 Nov 2023 13:51:25 -0500 Subject: [PATCH 3/4] - relaxes generic type constraint Signed-off-by: Vincent Biret --- src/RequestInformation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index b4e108d3..10bfdeeb 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -45,7 +45,7 @@ public RequestInformation(Method method, string urlTemplate, IDictionary /// Type for the query parameters /// Callback to configure the request - public void Configure(Action>? requestConfiguration) where T : DefaultQueryParameters, new() + public void Configure(Action>? requestConfiguration) where T : class, new() { if(requestConfiguration == null) return; var requestConfig = new RequestConfiguration(); From b7f247aec7eac385e23fdab51475fba9cce5beea Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 7 Nov 2023 14:43:52 -0500 Subject: [PATCH 4/4] - bumps minor version --- CHANGELOG.md | 6 ++++++ src/Microsoft.Kiota.Abstractions.csproj | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cab8262..5a3fa5fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.7.0] - 2023-11-07 + +### Added + +- Added methods in request information to reduce the amount of code being generated. + ## [1.6.1] - 2023-11-02 ### Changed diff --git a/src/Microsoft.Kiota.Abstractions.csproj b/src/Microsoft.Kiota.Abstractions.csproj index 5593b156..8f7c77b6 100644 --- a/src/Microsoft.Kiota.Abstractions.csproj +++ b/src/Microsoft.Kiota.Abstractions.csproj @@ -14,7 +14,7 @@ https://aka.ms/kiota/docs true true - 1.6.1 + 1.7.0 true false