Skip to content

Commit cd91a82

Browse files
authored
Merge branch 'main' into feature/public-api-surface-validation
2 parents 3919bd3 + d0ec0c0 commit cd91a82

File tree

6 files changed

+55
-78
lines changed

6 files changed

+55
-78
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "5.56.0"
2+
".": "5.56.1"
33
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project does adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [5.56.1](https://github.com/microsoftgraph/msgraph-sdk-dotnet/compare/v5.56.0...5.56.1) (2024-08-27)
9+
10+
11+
### Bug Fixes
12+
13+
* update to use non obsolete constructors and methods ([b764551](https://github.com/microsoftgraph/msgraph-sdk-dotnet/commit/b7645515c66ec94889b26e0e1c5085ce870fd92b))
14+
815
## [5.56.0] - 2024-06-06
916

1017
- Latest metadata updates from 4th June 2024.

src/Microsoft.Graph/GraphServiceClient.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace Microsoft.Graph
1212
using Microsoft.Graph.Requests;
1313
using Microsoft.Graph.Core.Requests;
1414
using Microsoft.Kiota.Abstractions.Authentication;
15-
using Microsoft.Kiota.Authentication.Azure;
1615
using Microsoft.Kiota.Abstractions;
1716
using Azure.Core;
1817

@@ -48,7 +47,7 @@ public GraphServiceClient(
4847
TokenCredential tokenCredential,
4948
IEnumerable<string> scopes = null,
5049
string baseUrl = null
51-
):this(new Microsoft.Graph.Authentication.AzureIdentityAuthenticationProvider(tokenCredential, null, null,scopes?.ToArray() ?? Array.Empty<string>()), baseUrl)
50+
):this(new Microsoft.Graph.Authentication.AzureIdentityAuthenticationProvider(tokenCredential, null, null,true,scopes?.ToArray() ?? []), baseUrl)
5251
{
5352
}
5453

@@ -64,7 +63,7 @@ public GraphServiceClient(
6463
TokenCredential tokenCredential,
6564
IEnumerable<string> scopes = null,
6665
string baseUrl = null
67-
):this(httpClient, new Microsoft.Graph.Authentication.AzureIdentityAuthenticationProvider(tokenCredential, null, null, scopes?.ToArray() ?? Array.Empty<string>()), baseUrl)
66+
):this(httpClient, new Microsoft.Graph.Authentication.AzureIdentityAuthenticationProvider(tokenCredential, null, null,true, scopes?.ToArray() ?? []), baseUrl)
6867
{
6968
}
7069

src/Microsoft.Graph/Microsoft.Graph.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
2424
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
2525
<!-- x-release-please-start-version -->
26-
<VersionPrefix>5.56.0</VersionPrefix>
26+
<VersionPrefix>5.56.1</VersionPrefix>
2727
<!-- x-release-please-end -->
2828
<!-- VersionPrefix minor version should not be set when the change comes from the generator. It will be updated automatically. -->
2929
<!-- VersionPrefix minor version must be manually set when making manual changes to code. -->

tests/Microsoft.Graph.DotnetCore.Test/Models/ModelSerializationTests.cs

Lines changed: 40 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
namespace Microsoft.Graph.DotnetCore.Test.Models
66
{
77
using System;
8+
using System.Collections.Generic;
9+
using System.Threading;
10+
using System.Threading.Tasks;
811
using Xunit;
912
using Microsoft.Graph.Models;
1013
using Microsoft.Kiota.Abstractions;
14+
using Microsoft.Kiota.Abstractions.Serialization;
1115
using Microsoft.Kiota.Serialization.Json;
12-
using System.Collections.Generic;
13-
using System.IO;
14-
using System.Text;
1516

1617
public class ModelSerializationTests
1718
{
18-
private readonly JsonParseNodeFactory parseNodeFactory;
19-
2019
public ModelSerializationTests()
2120
{
22-
this.parseNodeFactory = new JsonParseNodeFactory();
21+
SerializationWriterFactoryRegistry.DefaultInstance.ContentTypeAssociatedFactories["application/json"] = new JsonSerializationWriterFactory();
22+
ParseNodeFactoryRegistry.DefaultInstance.ContentTypeAssociatedFactories["application/json"] = new JsonParseNodeFactory();
2323
}
2424

2525
[Fact]
26-
public void DeserializeDerivedType()
26+
public async Task DeserializeDerivedType()
2727
{
2828
var userId = "userId";
2929
var givenName = "name";
@@ -33,18 +33,15 @@ public void DeserializeDerivedType()
3333
userId,
3434
givenName);
3535

36-
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(stringToDeserialize));
37-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
38-
var user = parseNode.GetObjectValue<User>(User.CreateFromDiscriminatorValue);
39-
36+
var user = await KiotaJsonSerializer.DeserializeAsync<User>(stringToDeserialize);
37+
4038
Assert.NotNull(user);
4139
Assert.Equal(userId, user.Id);
4240
Assert.Equal(givenName, user.GivenName);
43-
//Assert.Null(user.GetEtag());
4441
}
4542

4643
[Fact]
47-
public void DeserializeInvalidODataType()
44+
public async Task DeserializeInvalidODataType()
4845
{
4946
var directoryObjectId = "directoryObjectId";
5047
var givenName = "name";
@@ -54,18 +51,16 @@ public void DeserializeInvalidODataType()
5451
directoryObjectId,
5552
givenName);
5653

57-
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(stringToDeserialize));
58-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
59-
var directoryObject = parseNode.GetObjectValue<DirectoryObject>(DirectoryObject.CreateFromDiscriminatorValue);
60-
54+
var directoryObject = await KiotaJsonSerializer.DeserializeAsync<DirectoryObject>(stringToDeserialize);
55+
6156
Assert.NotNull(directoryObject);
6257
Assert.Equal(directoryObjectId, directoryObject.Id);
6358
Assert.NotNull(directoryObject.AdditionalData);
6459
Assert.Equal(givenName, directoryObject.AdditionalData["givenName"].ToString());
6560
}
6661

67-
[Fact(Skip = "TODO fix pending enum handling bug")]
68-
public void DeserializeUnknownEnumValue()
62+
[Fact]
63+
public async Task DeserializeUnknownEnumValue()
6964
{
7065
var enumValue = "newValue";
7166
var bodyContent = "bodyContent";
@@ -75,35 +70,30 @@ public void DeserializeUnknownEnumValue()
7570
bodyContent,
7671
enumValue);
7772

78-
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(stringToDeserialize));
79-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
80-
var itemBody = parseNode.GetObjectValue<ItemBody>(ItemBody.CreateFromDiscriminatorValue);
73+
var itemBody = await KiotaJsonSerializer.DeserializeAsync<ItemBody>(stringToDeserialize);
8174

8275
Assert.NotNull(itemBody);
8376
Assert.Equal(bodyContent, itemBody.Content);
8477
Assert.Null(itemBody.ContentType);
8578
Assert.NotNull(itemBody.AdditionalData);
86-
Assert.Equal(enumValue, itemBody.AdditionalData["contentType"].ToString());
8779
}
8880

8981
[Fact]
90-
public void DeserializeDateValue()
82+
public async Task DeserializeDateValue()
9183
{
9284
var now = DateTimeOffset.UtcNow;
9385

9486
var stringToDeserialize = string.Format("{{\"startDate\":\"{0}\"}}", now.ToString("yyyy-MM-dd"));
9587

96-
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(stringToDeserialize));
97-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
98-
var recurrenceRange = parseNode.GetObjectValue<RecurrenceRange>(RecurrenceRange.CreateFromDiscriminatorValue);
99-
88+
var recurrenceRange = await KiotaJsonSerializer.DeserializeAsync<RecurrenceRange>(stringToDeserialize);
89+
10090
Assert.Equal(now.Year, recurrenceRange.StartDate.Value.Year);
10191
Assert.Equal(now.Month, recurrenceRange.StartDate.Value.Month);
10292
Assert.Equal(now.Day, recurrenceRange.StartDate.Value.Day);
10393
}
10494

10595
[Fact]
106-
public void NewAbstractEntityDerivedClassInstance()
96+
public async Task NewAbstractEntityDerivedClassInstance()
10797
{
10898
var entityId = "entityId";
10999
var additionalKey = "key";
@@ -115,18 +105,16 @@ public void NewAbstractEntityDerivedClassInstance()
115105
additionalKey,
116106
additionalValue);
117107

118-
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(stringToDeserialize));
119-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
120-
var entity = parseNode.GetObjectValue<Entity>(Entity.CreateFromDiscriminatorValue);
108+
var entity = await KiotaJsonSerializer.DeserializeAsync<Entity>(stringToDeserialize);
121109

122110
Assert.NotNull(entity);
123111
Assert.Equal(entityId, entity.Id);
124112
Assert.NotNull(entity.AdditionalData);
125113
Assert.Equal(additionalValue, entity.AdditionalData[additionalKey].ToString());
126114
}
127115

128-
[Fact(Skip = "TODO fix pending enum handling bug")]
129-
public void SerializeAndDeserializeKnownEnumValue()
116+
[Fact]
117+
public async Task SerializeAndDeserializeKnownEnumValue()
130118
{
131119
var itemBody = new ItemBody
132120
{
@@ -140,28 +128,23 @@ public void SerializeAndDeserializeKnownEnumValue()
140128
itemBody.Content,
141129
"text");
142130

143-
// Serialize
144-
using var jsonSerializerWriter = new JsonSerializationWriter();
145-
jsonSerializerWriter.WriteObjectValue(string.Empty, itemBody);
146-
var serializedStream = jsonSerializerWriter.GetSerializedContent();
131+
// Serialize=
132+
var serializedString = await KiotaJsonSerializer.SerializeAsStringAsync(itemBody, CancellationToken.None);
147133

148134
//Assert
149-
var streamReader = new StreamReader(serializedStream);
150-
Assert.Equal(expectedSerializedStream, streamReader.ReadToEnd());
135+
Assert.Equal(expectedSerializedStream, serializedString);
151136

152137
// De serialize
153-
serializedStream.Position = 0; //reset the stream to be read again
154-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, serializedStream);
155-
var newItemBody = parseNode.GetObjectValue<ItemBody>(ItemBody.CreateFromDiscriminatorValue);
138+
var newItemBody = await KiotaJsonSerializer.DeserializeAsync<ItemBody>(serializedString);
156139

157140
Assert.NotNull(newItemBody);
158141
Assert.Equal(itemBody.Content, itemBody.Content);
159142
Assert.Equal(BodyType.Text, itemBody.ContentType);
160-
Assert.Null(itemBody.AdditionalData);
143+
Assert.NotNull(itemBody.AdditionalData);
161144
}
162145

163146
[Fact]
164-
public void SerializeDateValue()
147+
public async Task SerializeDateValue()
165148
{
166149
var now = DateTimeOffset.UtcNow;
167150

@@ -172,16 +155,13 @@ public void SerializeDateValue()
172155
StartDate = new Date(now.Year, now.Month, now.Day),
173156
};
174157

175-
using var jsonSerializerWriter = new JsonSerializationWriter();
176-
jsonSerializerWriter.WriteObjectValue(string.Empty, recurrence);
177-
var serializedStream = jsonSerializerWriter.GetSerializedContent();
158+
var serializedString = await KiotaJsonSerializer.SerializeAsStringAsync(recurrence, CancellationToken.None);
178159

179160
// Assert
180-
var streamReader = new StreamReader(serializedStream);
181-
Assert.Equal(expectedSerializedString, streamReader.ReadToEnd());
161+
Assert.Equal(expectedSerializedString, serializedString);
182162
}
183163
[Fact]
184-
public void TestEtagHelper()
164+
public async Task TestEtagHelper()
185165
{
186166
var userId = "userId";
187167
var testEtag = "testEtag";
@@ -191,16 +171,14 @@ public void TestEtagHelper()
191171
userId,
192172
testEtag);
193173

194-
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(stringToDeserialize));
195-
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
196-
var user = parseNode.GetObjectValue<Entity>(Entity.CreateFromDiscriminatorValue);
197-
174+
var user = await KiotaJsonSerializer.DeserializeAsync<Entity>(stringToDeserialize);
175+
198176
Assert.NotNull(user);
199177
Assert.Equal(userId, user.Id);
200178
//Assert.Equal(testEtag, user.GetEtag());
201179
}
202180
[Fact]
203-
public void TestPlannerAssigmentSerialization()
181+
public async Task TestPlannerAssigmentSerialization()
204182
{
205183
var planTask = new PlannerTask
206184
{
@@ -217,17 +195,14 @@ public void TestPlannerAssigmentSerialization()
217195
};
218196

219197
string expectedSerializedString = "{\"assignments\":{\"USER_ID\":{\"@odata.type\":\"#microsoft.graph.plannerAssignment\",\"orderHint\":\"!\"}},\"bucketId\":\"BUCKET_ID\",\"planId\":\"PLAN_ID\",\"title\":\"My Planner Task\"}";
220-
using var jsonSerializerWriter = new JsonSerializationWriter();
221-
jsonSerializerWriter.WriteObjectValue(string.Empty, planTask);
222-
var serializedStream = jsonSerializerWriter.GetSerializedContent();
223198

224199
// Assert
225-
var streamReader = new StreamReader(serializedStream);
226-
Assert.Equal(expectedSerializedString, streamReader.ReadToEnd());
200+
var serializedString = await KiotaJsonSerializer.SerializeAsStringAsync(planTask, CancellationToken.None);
201+
Assert.Equal(expectedSerializedString, serializedString);
227202
}
228203

229204
[Fact]
230-
public void TestChangeNoticationCollectionDeserialization()
205+
public async Task TestChangeNoticationCollectionDeserialization()
231206
{
232207
var json = @"{
233208
""value"": [
@@ -251,11 +226,9 @@ public void TestChangeNoticationCollectionDeserialization()
251226
""eyJ0eXAiOiJKV1...""
252227
]
253228
}";
254-
255-
using var memStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json));
256-
var parseNode = new JsonParseNodeFactory().GetRootParseNode("application/json", memStream);
257-
var changeNotifications = parseNode.GetObjectValue(ChangeNotificationCollection.CreateFromDiscriminatorValue);
258-
229+
230+
var changeNotifications = await KiotaJsonSerializer.DeserializeAsync<ChangeNotificationCollection>(json, CancellationToken.None);
231+
259232
Assert.NotNull(changeNotifications.Value);
260233
Assert.Single(changeNotifications.Value);
261234
Assert.NotNull(changeNotifications.ValidationTokens);

tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneNoteTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ namespace Microsoft.Graph.DotnetCore.Test.Requests.Functional
88
using System.IO;
99
using System.Net.Http;
1010
using System.Text;
11+
using System.Threading;
1112
using System.Threading.Tasks;
1213
using Xunit;
1314
using System.Collections.Generic;
1415
using System.Net.Http.Headers;
1516
using Microsoft.Graph.DotnetCore.Test.Requests.Functional.Resources;
1617
using Microsoft.Graph.Models.ODataErrors;
18+
using Microsoft.Kiota.Abstractions.Serialization;
1719

1820
public class OneNoteTests : GraphTestBase
1921
{
@@ -357,9 +359,7 @@ public async Task OneNoteAddPageHtmlWorkaround()
357359
{
358360
// Deserialize into OneNotePage object.
359361
var content = await response.Content.ReadAsStreamAsync();
360-
var parseNodeFactory = new JsonParseNodeFactory();
361-
var parseNode = parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, content);
362-
testPage = parseNode.GetObjectValue<OnenotePage>(OnenotePage.CreateFromDiscriminatorValue);
362+
testPage = await KiotaJsonSerializer.DeserializeAsync<OnenotePage>(content, CancellationToken.None);
363363

364364
Assert.NotNull(testPage);
365365
Assert.Contains(testPage.Title, title);
@@ -413,9 +413,7 @@ public async Task OneNoteAddPageHtmlWithStreamWorkaround()
413413
// Deserialize into OneNotePage object.
414414
// Send the request and get the response.
415415
var content = await graphClient.RequestAdapter.SendPrimitiveAsync<Stream>(requestInformation);
416-
var parseNodeFactory = new JsonParseNodeFactory();
417-
var parseNode = parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, content);
418-
testPage = parseNode.GetObjectValue<OnenotePage>(OnenotePage.CreateFromDiscriminatorValue);
416+
testPage = await KiotaJsonSerializer.DeserializeAsync<OnenotePage>(content, CancellationToken.None);
419417

420418
Assert.NotNull(testPage);
421419
Assert.Contains(testPage.Title, title);

0 commit comments

Comments
 (0)