From fc856b4d8808b6a63856b192d17dfa9632403638 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 21 Jul 2023 14:28:04 -0400 Subject: [PATCH] - reverts change on multipart request adapter so consumer doesn't have to set it --- .../RequestInformationTests.cs | 5 ++++- src/MultipartBody.cs | 11 +++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index 172d608b..6766359d 100644 --- a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs +++ b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs @@ -347,7 +347,10 @@ public void SetsBoundaryOnMultipartBody() serializationWriterFactoryMock.Setup(x => x.GetSerializationWriter(It.IsAny())).Returns(serializationWriterMock.Object); requestAdapterMock.SetupGet(x => x.SerializationWriterFactory).Returns(serializationWriterFactoryMock.Object); // Given - var multipartBody = new MultipartBody(requestAdapterMock.Object); + var multipartBody = new MultipartBody + { + RequestAdapter = requestAdapterMock.Object + }; // When testRequest.SetContentFromParsable(requestAdapterMock.Object, "multipart/form-data", multipartBody); diff --git a/src/MultipartBody.cs b/src/MultipartBody.cs index a080bd2e..fab9faff 100644 --- a/src/MultipartBody.cs +++ b/src/MultipartBody.cs @@ -22,14 +22,9 @@ public class MultipartBody : IParsable /// public string Boundary => _boundary.Value; /// - /// Creates a new instance of with the specified request adapter. + /// The request adapter to use for serialization. /// - /// The request adapter to use. - public MultipartBody(IRequestAdapter requestAdapter) - { - RequestAdapter = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); - } - private readonly IRequestAdapter RequestAdapter; + public IRequestAdapter? RequestAdapter { get; set; } /// /// Adds or replaces a part to the multipart body. /// @@ -98,7 +93,7 @@ public void Serialize(ISerializationWriter writer) { throw new ArgumentNullException(nameof(writer)); } - if(RequestAdapter.SerializationWriterFactory == null) + if(RequestAdapter?.SerializationWriterFactory == null) { throw new InvalidOperationException(nameof(RequestAdapter.SerializationWriterFactory)); }