Skip to content

Commit

Permalink
Merge pull request #719 from microsoftgraph/andrueastman/fixProperties
Browse files Browse the repository at this point in the history
Fixes incomplete uploads due to properties mismatch
  • Loading branch information
andrueastman authored Sep 1, 2023
2 parents 68b63b9 + 571520c commit d08fa46
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<VersionPrefix>3.0.10</VersionPrefix>
<VersionPrefix>3.0.11</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageReleaseNotes>
- Fixes a bug where BatchRequestContentCollection.NewBatchWithFailedRequests would fail when more than 20 requests had been sent.
- Fixes a bug where large file uploads would not complete due to different cased properties.
</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Graph.Core/Models/UploadSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

Expand Down Expand Up @@ -39,7 +39,7 @@ internal class UploadSession : IUploadSession
/// </summary>
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
return new Dictionary<string, Action<IParseNode>> (StringComparer.OrdinalIgnoreCase)
{
{"expirationDateTime", (n) => { ExpirationDateTime = n.GetDateTimeOffsetValue(); } },
{"nextExpectedRanges", (n) => { NextExpectedRanges = n.GetCollectionOfPrimitiveValues<string>().ToList(); } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,30 @@ public void SerializeUploadSessionValues()
// Expect the string to be ISO 8601-1:2019 format
Assert.Equal(expectedString, serializedJsonString);
}

[Fact]
public void DeserializeUploadSessionValues()
{
// Act 1
const string camelCasedPayload = @"{""expirationDateTime"":""2016-11-20T18:23:45.9356913+00:00"",""nextExpectedRanges"":[""0 - 1000""],""uploadUrl"":""http://localhost""}";
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(camelCasedPayload));
var parseNode = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
var uploadSession = parseNode.GetObjectValue(UploadSession.CreateFromDiscriminatorValue);
Assert.NotNull(uploadSession);
Assert.NotNull(uploadSession.ExpirationDateTime);
Assert.NotNull(uploadSession.NextExpectedRanges);
Assert.Single(uploadSession.NextExpectedRanges);

// Act 1
const string pascalCasedPayload = @"{""ExpirationDateTime"":""2016-11-20T18:23:45.9356913+00:00"",""NextExpectedRanges"":[""0 - 1000""],""uploadUrl"":""http://localhost""}";
var memoryStream2 = new MemoryStream(Encoding.UTF8.GetBytes(pascalCasedPayload));
var parseNode2 = this.parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream2);
var uploadSession2 = parseNode2.GetObjectValue(UploadSession.CreateFromDiscriminatorValue);
Assert.NotNull(uploadSession2);
Assert.NotNull(uploadSession2.ExpirationDateTime);
Assert.NotNull(uploadSession2.NextExpectedRanges);
Assert.Single(uploadSession2.NextExpectedRanges);
}

[Fact]
public void SerializeServiceExceptionValues()
Expand Down

0 comments on commit d08fa46

Please sign in to comment.