Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Kiota packages for GetFieldDeserializers optimization #403

Merged
merged 1 commit into from
Apr 6, 2022
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
15 changes: 7 additions & 8 deletions src/Microsoft.Graph.Core/Exceptions/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ public class Error: IParsable, IAdditionalDataHolder
/// <summary>
/// Gets the field deserializers for the class
/// </summary>
/// <typeparam name="T">The type of the class</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"code", (o,n) => { (o as Error).Code = n.GetStringValue(); } },
{"message", (o,n) => {(o as Error).Message = n.GetStringValue(); }},
{"target", (o,n) => {(o as Error).Target = n.GetStringValue(); }},
{"details", (o,n) => {(o as Error).Details = n.GetCollectionOfObjectValues<ErrorDetail>(ErrorDetail.CreateFromDiscriminatorValue).ToList(); }},
{"innerError", (o,n) => {(o as Error).InnerError = n.GetObjectValue<Error>(Error.CreateFromDiscriminatorValue); }}
{"code", (n) => { Code = n.GetStringValue(); } },
{"message", (n) => {Message = n.GetStringValue(); }},
{"target", (n) => {Target = n.GetStringValue(); }},
{"details", (n) => {Details = n.GetCollectionOfObjectValues<ErrorDetail>(ErrorDetail.CreateFromDiscriminatorValue).ToList(); }},
{"innerError", (n) => {InnerError = n.GetObjectValue<Error>(Error.CreateFromDiscriminatorValue); }}
};
}

Expand Down
11 changes: 5 additions & 6 deletions src/Microsoft.Graph.Core/Exceptions/ErrorDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ public class ErrorDetail : IParsable, IAdditionalDataHolder
/// <summary>
/// Gets the field deserializers for the class
/// </summary>
/// <typeparam name="T">The type of the class</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"code", (o,n) => { (o as ErrorDetail).Code = n.GetStringValue(); } },
{"message", (o,n) => {(o as ErrorDetail).Message = n.GetStringValue(); }},
{"target", (o,n) => {(o as ErrorDetail).Target = n.GetStringValue(); }}
{"code", (n) => { Code = n.GetStringValue(); } },
{"message", (n) => {Message = n.GetStringValue(); }},
{"target", (n) => {Target = n.GetStringValue(); }}
};
}

Expand Down
7 changes: 3 additions & 4 deletions src/Microsoft.Graph.Core/Exceptions/ErrorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ public class ErrorResponse :IParsable, IAdditionalDataHolder
/// <summary>
/// Gets the field deserializers for the class
/// </summary>
/// <typeparam name="T">The type of the class</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"error", (o,n) => { (o as ErrorResponse).Error = n.GetObjectValue<Error>(Error.CreateFromDiscriminatorValue); } }
{"error", (n) => { Error = n.GetObjectValue<Error>(Error.CreateFromDiscriminatorValue); } }
};
}

Expand Down
11 changes: 5 additions & 6 deletions src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionSuffix>preview.2</VersionSuffix>
<VersionSuffix>preview.3</VersionSuffix>
<PackageReleaseNotes>
- Added support for vendor specific content types
- Added support for 204 no content responses
- [Breaking] Simplifies GetFieldDeserializers from IParsable
</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down Expand Up @@ -100,11 +99,11 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.16.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.17.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.0-preview.2" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.0-preview.3" />
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.0.0-preview.1" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.0.0-preview.1" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.0.0-preview.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.0.0-preview.1" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.0.0-preview.3" />
</ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions src/Microsoft.Graph.Core/Models/AsyncOperationStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ public partial class AsyncOperationStatus: IParsable, IAdditionalDataHolder
/// <summary>
/// Gets the field deserializers for the <see cref="AsyncOperationStatus"/> instance
/// </summary>
/// <typeparam name="T">The type to deserialize</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"operation", (o,n) => { (o as AsyncOperationStatus).Operation = n.GetStringValue(); } },
{"percentageComplete", (o,n) => { (o as AsyncOperationStatus).PercentageComplete = n.GetDoubleValue(); } },
{"status", (o,n) => { (o as AsyncOperationStatus).Status = n.GetStringValue(); } },
{"operation", (n) => { Operation = n.GetStringValue(); } },
{"percentageComplete", (n) => { PercentageComplete = n.GetDoubleValue(); } },
{"status", (n) => { Status = n.GetStringValue(); } },
};
}

Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.Graph.Core/Models/UploadSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ internal class UploadSession : IUploadSession
/// <summary>
/// The deserialization information for the current model
/// </summary>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"expirationDateTime", (o,n) => { (o as UploadSession).ExpirationDateTime = n.GetDateTimeOffsetValue(); } },
{"nextExpectedRanges", (o,n) => { (o as UploadSession).NextExpectedRanges = n.GetCollectionOfPrimitiveValues<string>().ToList(); } },
{"uploadUrl", (o,n) => { (o as UploadSession).UploadUrl = n.GetStringValue(); } },
{"expirationDateTime", (n) => { ExpirationDateTime = n.GetDateTimeOffsetValue(); } },
{"nextExpectedRanges", (n) => { NextExpectedRanges = n.GetCollectionOfPrimitiveValues<string>().ToList(); } },
{"uploadUrl", (n) => { UploadUrl = n.GetStringValue(); } },
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Graph.Core/Tasks/LargeFileUploadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public LargeFileUploadTask(IParsable uploadSession, Stream uploadStream, int ma
/// <exception cref="NotImplementedException"></exception>
private IUploadSession ExtractSessionFromParsable(IParsable uploadSession)
{
if (!uploadSession.GetFieldDeserializers<IParsable>().ContainsKey("expirationDateTime"))
if (!uploadSession.GetFieldDeserializers().ContainsKey("expirationDateTime"))
throw new ArgumentException("The Parsable does not contain the 'expirationDateTime' property");
if (!uploadSession.GetFieldDeserializers<IParsable>().ContainsKey("nextExpectedRanges"))
if (!uploadSession.GetFieldDeserializers().ContainsKey("nextExpectedRanges"))
throw new ArgumentException("The Parsable does not contain the 'nextExpectedRanges' property");
if (!uploadSession.GetFieldDeserializers<IParsable>().ContainsKey("uploadUrl"))
if (!uploadSession.GetFieldDeserializers().ContainsKey("uploadUrl"))
throw new ArgumentException("The Parsable does not contain the 'uploadUrl' property");

var uploadSessionType = uploadSession.GetType();
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Graph.Core/Tasks/PageIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static PageIterator<TEntity, TCollectionPage> CreatePageIterator(IBaseCli
if (callback == null)
throw new ArgumentNullException(nameof(callback));

if (!page.GetFieldDeserializers<IParsable>().ContainsKey("value"))
if (!page.GetFieldDeserializers().ContainsKey("value"))
throw new ArgumentException("The Parsable does not contain a collection property");

var pageItems = ExtractEntityListFromParsable(page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ public class AbstractEntityType: IParsable, IAdditionalDataHolder
/// <summary>
/// Gets the field deserializers for the class
/// </summary>
/// <typeparam name="T">The type to use</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"id", (o,n) => { (o as AbstractEntityType).Id = n.GetStringValue(); } }
{"id", (n) => { Id = n.GetStringValue(); } }
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ public class DateTestClass: IParsable
/// <summary>
/// Gets the field deserializers for the class
/// </summary>
/// <typeparam name="T">The type to use</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"nullableDate", (o,n) => { (o as DateTestClass).NullableDate = n.GetDateValue(); } },
{"dateCollection", (o,n) => { (o as DateTestClass).DateCollection = n.GetCollectionOfPrimitiveValues<Date?>(); } },
{"invalidType", (o,n) => { (o as DateTestClass).InvalidType = n.GetIntValue(); } },
{"nullableDate", (n) => { NullableDate = n.GetDateValue(); } },
{"dateCollection", (n) => { DateCollection = n.GetCollectionOfPrimitiveValues<Date?>(); } },
{"invalidType", (n) => { InvalidType = n.GetIntValue(); } },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ public class DerivedTypeClass : AbstractEntityType, IParsable, IAdditionalDataHo
/// <summary>
/// Gets the field deserializers for the class
/// </summary>
/// <typeparam name="T">The type to use</typeparam>
/// <returns></returns>
public new IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public new IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>(base.GetFieldDeserializers<T>())
return new Dictionary<string, Action<IParseNode>>(base.GetFieldDeserializers())
{
{"enumType", (o,n) => { (o as DerivedTypeClass).EnumType = n.GetEnumValue<EnumType>(); } },
{"name", (o,n) => { (o as DerivedTypeClass).Name = n.GetStringValue(); } },
{"memorableDates", (o,n) => { (o as DerivedTypeClass).MemorableDates = n.GetCollectionOfObjectValues<DateTestClass>(DateTestClass.CreateFromDiscriminatorValue); } },
{"link", (o,n) => { (o as DerivedTypeClass).WebUrl = n.GetStringValue(); } },
{"enumType", (n) => { EnumType = n.GetEnumValue<EnumType>(); } },
{"name", (n) => { Name = n.GetStringValue(); } },
{"memorableDates", (n) => { MemorableDates = n.GetCollectionOfObjectValues<DateTestClass>(DateTestClass.CreateFromDiscriminatorValue); } },
{"link", (n) => { WebUrl = n.GetStringValue(); } },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ public TestAttendee()
/// <summary>
/// Gets the field deserializers for the <see cref="TestAttendee"/> instance
/// </summary>
/// <typeparam name="T">The type to deserialize</typeparam>
/// <returns></returns>
public new IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public new IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>(base.GetFieldDeserializers<T>())
return new Dictionary<string, Action<IParseNode>>(base.GetFieldDeserializers())
{
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ public class TestChangeNotificationEncryptedContent : IDecryptableContent, IPars
/// <summary>
/// Gets the field deserializers for the <see cref="TestChangeNotificationEncryptedContent"/> instance
/// </summary>
/// <typeparam name="T">The type to deserialize</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"data", (o,n) => { (o as TestChangeNotificationEncryptedContent).Data = n.GetStringValue(); } },
{"dataKey", (o,n) => { (o as TestChangeNotificationEncryptedContent).DataKey = n.GetStringValue(); } },
{"dataSignature", (o,n) => { (o as TestChangeNotificationEncryptedContent).DataSignature = n.GetStringValue(); } },
{"encryptionCertificateId", (o,n) => { (o as TestChangeNotificationEncryptedContent).EncryptionCertificateId = n.GetStringValue(); } },
{"encryptionCertificateThumbprint", (o,n) => { (o as TestChangeNotificationEncryptedContent).EncryptionCertificateThumbprint = n.GetStringValue(); } },
{"data", (n) => { Data = n.GetStringValue(); } },
{"dataKey", (n) => { DataKey = n.GetStringValue(); } },
{"dataSignature", (n) => { DataSignature = n.GetStringValue(); } },
{"encryptionCertificateId", (n) => { EncryptionCertificateId = n.GetStringValue(); } },
{"encryptionCertificateThumbprint", (n) => { EncryptionCertificateThumbprint = n.GetStringValue(); } },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ public class TestChatMessage: IParsable, IAdditionalDataHolder
/// <summary>
/// Gets the field deserializers for the <see cref="TestChatMessage"/> instance
/// </summary>
/// <typeparam name="T">The type to deserialize</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"chatId", (o,n) => { (o as TestChatMessage).ChatId = n.GetStringValue(); } },
{"createdDateTime", (o,n) => { (o as TestChatMessage).CreatedDateTime = n.GetDateTimeOffsetValue(); } },
{"deletedDateTime", (o,n) => { (o as TestChatMessage).DeletedDateTime = n.GetDateTimeOffsetValue(); } },
{"etag", (o,n) => { (o as TestChatMessage).Etag = n.GetStringValue(); } },
{"body", (o,n) => { (o as TestChatMessage).Body = n.GetObjectValue<TestItemBody>(TestItemBody.CreateFromDiscriminatorValue); } },
{"chatId", (n) => { ChatId = n.GetStringValue(); } },
{"createdDateTime", (n) => { CreatedDateTime = n.GetDateTimeOffsetValue(); } },
{"deletedDateTime", (n) => { DeletedDateTime = n.GetDateTimeOffsetValue(); } },
{"etag", (n) => { Etag = n.GetStringValue(); } },
{"body", (n) => { Body = n.GetObjectValue<TestItemBody>(TestItemBody.CreateFromDiscriminatorValue); } },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ public TestDateTimeTimeZone()
/// <summary>
/// Gets the field deserializers for the <see cref="TestDateTimeTimeZone"/> instance
/// </summary>
/// <typeparam name="T">The type to deserialize</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"dateTime", (o,n) => { (o as TestDateTimeTimeZone).DateTime = n.GetStringValue(); } },
{"timeZone", (o,n) => { (o as TestDateTimeTimeZone).TimeZone = n.GetStringValue(); } },
{"@odata.type", (o,n) => { (o as TestDateTimeTimeZone).ODataType = n.GetStringValue(); } },
{"dateTime", (n) => { DateTime = n.GetStringValue(); } },
{"timeZone", (n) => { TimeZone = n.GetStringValue(); } },
{"@odata.type", (n) => { ODataType = n.GetStringValue(); } },
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ public TestDrive()
/// <summary>
/// Gets the field deserializers for the <see cref="TestDrive"/> instance
/// </summary>
/// <typeparam name="T">The type to deserialize</typeparam>
/// <returns></returns>
public IDictionary<string, Action<T, IParseNode>> GetFieldDeserializers<T>()
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<T, IParseNode>>
return new Dictionary<string, Action<IParseNode>>
{
{"@odata.type", (o,n) => { (o as TestDrive).ODataType = n.GetStringValue(); } },
{"id", (o,n) => { (o as TestDrive).Id = n.GetStringValue(); } },
{"name", (o,n) => { (o as TestDrive).Name = n.GetStringValue(); } },
{"@odata.type", (n) => { ODataType = n.GetStringValue(); } },
{"id", (n) => { Id = n.GetStringValue(); } },
{"name", (n) => { Name = n.GetStringValue(); } },
};
}

Expand Down
Loading