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

bugfix: version range for abstractions #231

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.2] - 2024-05-23

### Changed

- Fixed an issue where fixed versions of abstractions would result in restore failures. [microsoft/kiota-http-dotnet#256](https://github.com/microsoft/kiota-http-dotnet/issues/258)

## [1.3.1] - 2024-05-20

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Kiota.Serialization.Json.Tests.Mocks;
using Xunit;

Expand All @@ -11,11 +12,11 @@ public class IntersectionWrapperParseTests {
private readonly JsonSerializationWriterFactory _serializationWriterFactory = new();
private const string contentType = "application/json";
[Fact]
public void ParsesIntersectionTypeComplexProperty1()
public async Task ParsesIntersectionTypeComplexProperty1()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("{\"displayName\":\"McGill\",\"officeLocation\":\"Montreal\", \"id\": \"opaque\"}"));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<IntersectionTypeMock>(IntersectionTypeMock.CreateFromDiscriminator);
Expand All @@ -30,11 +31,11 @@ public void ParsesIntersectionTypeComplexProperty1()
Assert.Equal("McGill", result.ComposedType2.DisplayName);
}
[Fact]
public void ParsesIntersectionTypeComplexProperty2()
public async Task ParsesIntersectionTypeComplexProperty2()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("{\"displayName\":\"McGill\",\"officeLocation\":\"Montreal\", \"id\": 10}"));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<IntersectionTypeMock>(IntersectionTypeMock.CreateFromDiscriminator);
Expand All @@ -50,11 +51,11 @@ public void ParsesIntersectionTypeComplexProperty2()
Assert.Equal("McGill", result.ComposedType2.DisplayName);
}
[Fact]
public void ParsesIntersectionTypeComplexProperty3()
public async Task ParsesIntersectionTypeComplexProperty3()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("[{\"@odata.type\":\"#microsoft.graph.TestEntity\",\"officeLocation\":\"Ottawa\", \"id\": \"11\"}, {\"@odata.type\":\"#microsoft.graph.TestEntity\",\"officeLocation\":\"Montreal\", \"id\": \"10\"}]"));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<IntersectionTypeMock>(IntersectionTypeMock.CreateFromDiscriminator);
Expand All @@ -69,11 +70,11 @@ public void ParsesIntersectionTypeComplexProperty3()
Assert.Equal("Ottawa", result.ComposedType3.First().OfficeLocation);
}
[Fact]
public void ParsesIntersectionTypeStringValue()
public async Task ParsesIntersectionTypeStringValue()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("\"officeLocation\""));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<IntersectionTypeMock>(IntersectionTypeMock.CreateFromDiscriminator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.Kiota.Serialization.Json.Tests
Expand All @@ -16,22 +17,22 @@ public JsonParseNodeFactoryTests()
}

[Fact]
public void GetsWriterForJsonContentType()
public async Task GetsWriterForJsonContentType()
{
using var jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(TestJsonString));
var jsonWriter = _jsonParseNodeFactory.GetRootParseNode(_jsonParseNodeFactory.ValidContentType,jsonStream);
var jsonWriter = await _jsonParseNodeFactory.GetRootParseNodeAsync(_jsonParseNodeFactory.ValidContentType,jsonStream);

// Assert
Assert.NotNull(jsonWriter);
Assert.IsAssignableFrom<JsonParseNode>(jsonWriter);
}

[Fact]
public void ThrowsArgumentOutOfRangeExceptionForInvalidContentType()
public async Task ThrowsArgumentOutOfRangeExceptionForInvalidContentType()
{
var streamContentType = "application/octet-stream";
using var jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(TestJsonString));
var exception = Assert.Throws<ArgumentOutOfRangeException>(() => _jsonParseNodeFactory.GetRootParseNode(streamContentType,jsonStream));
var exception = await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await _jsonParseNodeFactory.GetRootParseNodeAsync(streamContentType,jsonStream));

// Assert
Assert.NotNull(exception);
Expand All @@ -41,10 +42,10 @@ public void ThrowsArgumentOutOfRangeExceptionForInvalidContentType()
[Theory]
[InlineData(null)]
[InlineData("")]
public void ThrowsArgumentNullExceptionForNoContentType(string contentType)
public async Task ThrowsArgumentNullExceptionForNoContentType(string contentType)
{
using var jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(TestJsonString));
var exception = Assert.Throws<ArgumentNullException>(() => _jsonParseNodeFactory.GetRootParseNode(contentType,jsonStream));
var exception = await Assert.ThrowsAsync<ArgumentNullException>(async () => await _jsonParseNodeFactory.GetRootParseNodeAsync(contentType,jsonStream));

// Assert
Assert.NotNull(exception);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Kiota.Serialization.Json.Tests.Mocks;
using Xunit;

Expand All @@ -11,11 +12,11 @@ public class UnionWrapperParseTests {
private readonly JsonSerializationWriterFactory _serializationWriterFactory = new();
private const string contentType = "application/json";
[Fact]
public void ParsesUnionTypeComplexProperty1()
public async Task ParsesUnionTypeComplexProperty1()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("{\"@odata.type\":\"#microsoft.graph.testEntity\",\"officeLocation\":\"Montreal\", \"id\": \"opaque\"}"));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<UnionTypeMock>(UnionTypeMock.CreateFromDiscriminator);
Expand All @@ -29,11 +30,11 @@ public void ParsesUnionTypeComplexProperty1()
Assert.Equal("opaque", result.ComposedType1.Id);
}
[Fact]
public void ParsesUnionTypeComplexProperty2()
public async Task ParsesUnionTypeComplexProperty2()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("{\"@odata.type\":\"#microsoft.graph.secondTestEntity\",\"officeLocation\":\"Montreal\", \"id\": 10}"));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<UnionTypeMock>(UnionTypeMock.CreateFromDiscriminator);
Expand All @@ -47,11 +48,11 @@ public void ParsesUnionTypeComplexProperty2()
Assert.Equal(10, result.ComposedType2.Id);
}
[Fact]
public void ParsesUnionTypeComplexProperty3()
public async Task ParsesUnionTypeComplexProperty3()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("[{\"@odata.type\":\"#microsoft.graph.TestEntity\",\"officeLocation\":\"Ottawa\", \"id\": \"11\"}, {\"@odata.type\":\"#microsoft.graph.TestEntity\",\"officeLocation\":\"Montreal\", \"id\": \"10\"}]"));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<UnionTypeMock>(UnionTypeMock.CreateFromDiscriminator);
Expand All @@ -63,14 +64,14 @@ public void ParsesUnionTypeComplexProperty3()
Assert.Null(result.ComposedType1);
Assert.Null(result.StringValue);
Assert.Equal(2, result.ComposedType3.Count);
Assert.Equal("11", result.ComposedType3.First().Id);
Assert.Equal("11", result.ComposedType3[0].Id);
}
[Fact]
public void ParsesUnionTypeStringValue()
public async Task ParsesUnionTypeStringValue()
{
// Given
using var payload = new MemoryStream(Encoding.UTF8.GetBytes("\"officeLocation\""));
var parseNode = _parseNodeFactory.GetRootParseNode(contentType, payload);
var parseNode = await _parseNodeFactory.GetRootParseNodeAsync(contentType, payload);

// When
var result = parseNode.GetObjectValue<UnionTypeMock>(UnionTypeMock.CreateFromDiscriminator);
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Kiota.Serialization.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.3.1</VersionPrefix>
<VersionPrefix>1.3.2</VersionPrefix>
<VersionSuffix></VersionSuffix>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down Expand Up @@ -44,7 +44,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.1" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="[1.9.1, 2.0.0)" />
</ItemGroup>

<!-- NET 5 target to be removed on next major version-->
Expand Down