Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Commit 82c7cb6

Browse files
authored
Merge pull request #257 from microsoft/bugfix/hard-version
bugfix: version range for abstractions
2 parents 0fcb638 + 58127f9 commit 82c7cb6

File tree

4 files changed

+40
-27
lines changed

4 files changed

+40
-27
lines changed

CHANGELOG.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.4.2] - 2024-05-21
11+
1012
### Added
1113

1214
- Added an optional parameter to kiota middleware factory so options can be configured directly. [#233](https://github.com/microsoft/kiota-http-dotnet/issues/233)
1315
- `GetDefaultHandlerTypes` added to `KiotaClientFactory` if you're creating your own `HttpClient` and still want to use the default handlers.
1416

17+
### Changed
18+
19+
- Fixed an issue where fixed versions of abstractions would result in restore failures. [#256](https://github.com/microsoft/kiota-http-dotnet/issues/256)
20+
1521
## [1.4.1] - 2024-05-07
1622

1723
## Changed
@@ -26,20 +32,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2632

2733
## [1.3.12] - 2024-04-22
2834

29-
- UriReplacementHandler improvements to be added to middleware pipeline by default and respects options set in the HttpRequestMessage (https://github.com/microsoft/kiota-http-dotnet/issues/242)
30-
- Adds `ConfigureAwait(false)` calls to async calls (https://github.com/microsoft/kiota-http-dotnet/issues/240).
35+
- UriReplacementHandler improvements to be added to middleware pipeline by default and respects options set in the HttpRequestMessage [#242](https://github.com/microsoft/kiota-http-dotnet/issues/242)
36+
- Adds `ConfigureAwait(false)` calls to async calls [#240](https://github.com/microsoft/kiota-http-dotnet/issues/240).
3137

3238
## [1.3.11] - 2024-04-19
3339

3440
## Changed
3541

36-
- Fixes default handler for NET framework to unlock HTTP/2 scenarios (https://github.com/microsoft/kiota-http-dotnet/issues/237)
42+
- Fixes default handler for NET framework to unlock HTTP/2 scenarios [#237](https://github.com/microsoft/kiota-http-dotnet/issues/237)
3743

3844
## [1.3.10] - 2024-04-19
3945

4046
## Changed
4147

42-
- Have made System.* dependencies only be included on Net Standard's TFM & net 5 (https://github.com/microsoft/kiota-http-dotnet/issues/230)
48+
- Have made System.* dependencies only be included on Net Standard's TFM & net 5 [#230](https://github.com/microsoft/kiota-http-dotnet/issues/230)
4349

4450
## [1.3.9] - 2024-04-17
4551

@@ -92,7 +98,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9298

9399
### Added
94100

95-
- Fixes multiple initialization of `ActivitySource` instances on each request send(https://github.com/microsoft/kiota-http-dotnet/issues/161).
101+
- Fixes multiple initialization of `ActivitySource` instances on each request send [#161](https://github.com/microsoft/kiota-http-dotnet/issues/161).
96102

97103
## [1.3.0] - 2023-11-02
98104

Microsoft.Kiota.Http.HttpClientLibrary.Tests/RequestAdapterTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ public async Task SendReturnsObjectOnContent(HttpStatusCode statusCode)
364364
var mockParseNode = new Mock<IParseNode>();
365365
mockParseNode.Setup<IParsable>(x => x.GetObjectValue(It.IsAny<ParsableFactory<MockEntity>>()))
366366
.Returns(new MockEntity());
367-
var mockParseNodeFactory = new Mock<IParseNodeFactory>();
368-
mockParseNodeFactory.Setup<IParseNode>(x => x.GetRootParseNode(It.IsAny<string>(), It.IsAny<Stream>()))
369-
.Returns(mockParseNode.Object);
367+
var mockParseNodeFactory = new Mock<IAsyncParseNodeFactory>();
368+
mockParseNodeFactory.Setup(x => x.GetRootParseNodeAsync(It.IsAny<string>(), It.IsAny<Stream>(), It.IsAny<CancellationToken>()))
369+
.Returns(Task.FromResult(mockParseNode.Object));
370370
var adapter = new HttpClientRequestAdapter(_authenticationProvider, httpClient: client, parseNodeFactory: mockParseNodeFactory.Object);
371371
var requestInfo = new RequestInformation
372372
{
@@ -393,7 +393,7 @@ public async Task RetriesOnCAEResponse()
393393
StatusCode = methodCalled ? HttpStatusCode.OK : HttpStatusCode.Unauthorized,
394394
Content = new StreamContent(new MemoryStream(Encoding.UTF8.GetBytes("Test")))
395395
};
396-
if (!methodCalled)
396+
if(!methodCalled)
397397
response.Headers.WwwAuthenticate.Add(new("Bearer", "realm=\"\", authorization_uri=\"https://login.microsoftonline.com/common/oauth2/authorize\", client_id=\"00000003-0000-0000-c000-000000000000\", error=\"insufficient_claims\", claims=\"eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTY1MjgxMzUwOCJ9fX0=\""));
398398
methodCalled = true;
399399
return Task.FromResult(response);
@@ -440,7 +440,7 @@ public async Task SetsTheApiExceptionStatusCode(HttpStatusCode statusCode)
440440
var response = await adapter.SendPrimitiveAsync<Stream>(requestInfo);
441441
Assert.Fail("Expected an ApiException to be thrown");
442442
}
443-
catch (ApiException e)
443+
catch(ApiException e)
444444
{
445445
Assert.Equal((int)statusCode, e.ResponseStatusCode);
446446
Assert.True(e.ResponseHeaders.ContainsKey("request-id"));
@@ -467,9 +467,9 @@ public async Task SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusC
467467
var mockParseNode = new Mock<IParseNode>();
468468
mockParseNode.Setup<IParsable>(x => x.GetObjectValue(It.IsAny<ParsableFactory<IParsable>>()))
469469
.Returns(new MockError("A general error occured"));
470-
var mockParseNodeFactory = new Mock<IParseNodeFactory>();
471-
mockParseNodeFactory.Setup<IParseNode>(x => x.GetRootParseNode(It.IsAny<string>(), It.IsAny<Stream>()))
472-
.Returns(mockParseNode.Object);
470+
var mockParseNodeFactory = new Mock<IAsyncParseNodeFactory>();
471+
mockParseNodeFactory.Setup(x => x.GetRootParseNodeAsync(It.IsAny<string>(), It.IsAny<Stream>(), It.IsAny<CancellationToken>()))
472+
.Returns(Task.FromResult(mockParseNode.Object));
473473
var adapter = new HttpClientRequestAdapter(_authenticationProvider, mockParseNodeFactory.Object, httpClient: client);
474474
var requestInfo = new RequestInformation
475475
{
@@ -485,7 +485,7 @@ public async Task SelectsTheXXXErrorMappingClassCorrectly(HttpStatusCode statusC
485485
var response = await adapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping);
486486
Assert.Fail("Expected an ApiException to be thrown");
487487
}
488-
catch (MockError mockError)
488+
catch(MockError mockError)
489489
{
490490
Assert.Equal((int)statusCode, mockError.ResponseStatusCode);
491491
Assert.Equal("A general error occured", mockError.Message);
@@ -511,9 +511,9 @@ public async Task ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode)
511511
var mockParseNode = new Mock<IParseNode>();
512512
mockParseNode.Setup<IParsable>(x => x.GetObjectValue(It.IsAny<ParsableFactory<IParsable>>()))
513513
.Returns(new MockError("A general error occured: " + statusCode.ToString()));
514-
var mockParseNodeFactory = new Mock<IParseNodeFactory>();
515-
mockParseNodeFactory.Setup<IParseNode>(x => x.GetRootParseNode(It.IsAny<string>(), It.IsAny<Stream>()))
516-
.Returns(mockParseNode.Object);
514+
var mockParseNodeFactory = new Mock<IAsyncParseNodeFactory>();
515+
mockParseNodeFactory.Setup(x => x.GetRootParseNodeAsync(It.IsAny<string>(), It.IsAny<Stream>(), It.IsAny<CancellationToken>()))
516+
.Returns(Task.FromResult(mockParseNode.Object));
517517
var adapter = new HttpClientRequestAdapter(_authenticationProvider, mockParseNodeFactory.Object, httpClient: client);
518518
var requestInfo = new RequestInformation
519519
{
@@ -529,7 +529,7 @@ public async Task ThrowsApiExceptionOnMissingMapping(HttpStatusCode statusCode)
529529
var response = await adapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping);
530530
Assert.Fail("Expected an ApiException to be thrown");
531531
}
532-
catch (ApiException apiException)
532+
catch(ApiException apiException)
533533
{
534534
Assert.Equal((int)statusCode, apiException.ResponseStatusCode);
535535
Assert.Contains("The server returned an unexpected status code and no error factory is registered for this code", apiException.Message);

src/HttpClientRequestAdapter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,11 @@ private async Task ThrowIfFailedResponse(HttpResponseMessage response, Dictionar
441441
using var contentStream = await (response.Content?.ReadAsStreamAsync() ?? Task.FromResult(Stream.Null)).ConfigureAwait(false);
442442
#endif
443443
if(contentStream == Stream.Null || (contentStream.CanSeek && contentStream.Length == 0))
444-
return null;// ensure a usefule stream is passed to the factory
445-
var rootNode = pNodeFactory.GetRootParseNode(responseContentType!, contentStream);
444+
return null;// ensure a useful stream is passed to the factory
445+
#pragma warning disable CS0618 // Type or member is obsolete
446+
//TODO remove with v2
447+
var rootNode = pNodeFactory is IAsyncParseNodeFactory asyncParseNodeFactory ? await asyncParseNodeFactory.GetRootParseNodeAsync(responseContentType!, contentStream, cancellationToken).ConfigureAwait(false) : pNodeFactory.GetRootParseNode(responseContentType!, contentStream);
448+
#pragma warning restore CS0618 // Type or member is obsolete
446449
return rootNode;
447450
}
448451
private const string ClaimsKey = "claims";
@@ -538,7 +541,7 @@ private HttpRequestMessage GetRequestMessageFromRequestInformation(RequestInform
538541
{
539542
Method = new HttpMethod(requestInfo.HttpMethod.ToString().ToUpperInvariant()),
540543
RequestUri = requestUri,
541-
Version=new Version(2,0)
544+
Version = new Version(2, 0)
542545
};
543546

544547
if(requestInfo.RequestOptions.Any())

src/Microsoft.Kiota.Http.HttpClientLibrary.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,32 @@
3535
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
3636
<NoWarn>$(NoWarn);NU5048;NETSDK1138</NoWarn>
3737
</PropertyGroup>
38-
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net5.0'))">
38+
<PropertyGroup
39+
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net5.0'))">
3940
<IsTrimmable>true</IsTrimmable>
4041
</PropertyGroup>
41-
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net8.0'))">
42+
<PropertyGroup
43+
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net8.0'))">
4244
<IsAotCompatible>true</IsAotCompatible>
4345
</PropertyGroup>
4446

4547
<ItemGroup>
4648
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
47-
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.8.3" />
49+
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="[1.9.1, 2.0.0)" />
4850
</ItemGroup>
4951

5052
<!-- NET 5 target to be removed on next major version-->
51-
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)'== 'netStandard2.0' or '$(TargetFramework)' == 'netStandard2.1' or '$(TargetFramework)' == 'net462'">
53+
<ItemGroup
54+
Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)'== 'netStandard2.0' or '$(TargetFramework)' == 'netStandard2.1' or '$(TargetFramework)' == 'net462'">
5255
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="[6.0,9.0)" />
5356
<PackageReference Include="System.Text.Json" Version="[6.0,9.0)" />
5457
</ItemGroup>
5558
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
5659
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="[6.0,9.0)" />
5760
</ItemGroup>
5861
<ItemGroup>
59-
<ProjectReference Include="..\Kiota.Generated\KiotaGenerated.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
62+
<ProjectReference Include="..\Kiota.Generated\KiotaGenerated.csproj" OutputItemType="Analyzer"
63+
ReferenceOutputAssembly="false" />
6064
</ItemGroup>
6165

6266
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
@@ -69,4 +73,4 @@
6973
<PackagePath></PackagePath>
7074
</None>
7175
</ItemGroup>
72-
</Project>
76+
</Project>

0 commit comments

Comments
 (0)