From b91a70a3dc517a20685ce0bf3bb85da114f15970 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Wed, 25 Sep 2024 12:39:09 +0300 Subject: [PATCH] adds changelog entry. format code --- CHANGELOG.md | 5 + Directory.Build.props | 2 +- .../serialization/ParsableExtensions.cs | 114 +++++++++--------- 3 files changed, 63 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8704dbe..a61895c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.13.0] - 2024-09-25 + +### Changed + +- Adds extension methods for make serializing easier [#338](https://github.com/microsoft/kiota-dotnet/issues/338). ## [1.12.4] - 2024-09-05 diff --git a/Directory.Build.props b/Directory.Build.props index f202c97..9b7955b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 1.12.4 + 1.13.0 false diff --git a/src/abstractions/serialization/ParsableExtensions.cs b/src/abstractions/serialization/ParsableExtensions.cs index 4aad0a8..94280dd 100644 --- a/src/abstractions/serialization/ParsableExtensions.cs +++ b/src/abstractions/serialization/ParsableExtensions.cs @@ -15,67 +15,67 @@ namespace Microsoft.Kiota.Serialization; /// public static class ParsableExtensions { - /// - /// Serializes the given object into a stream based on the content type. - /// - /// Content type to serialize the object t - /// The object to serialize. - /// If this object uses the , use this to control if you want all properties or just the changed once. - /// The serialized representation as a stream. - public static Stream SerializeAsStream(this T value, string contentType, bool serializeOnlyChangedValues = false) where T : IParsable - => KiotaSerializer.SerializeAsStream(contentType, value, serializeOnlyChangedValues); + /// + /// Serializes the given object into a stream based on the content type. + /// + /// Content type to serialize the object t + /// The object to serialize. + /// If this object uses the , use this to control if you want all properties or just the changed once. + /// The serialized representation as a stream. + public static Stream SerializeAsStream(this T value, string contentType, bool serializeOnlyChangedValues = false) where T : IParsable + => KiotaSerializer.SerializeAsStream(contentType, value, serializeOnlyChangedValues); - /// - /// Serializes the given object into a string based on the content type. - /// - /// Content type to serialize the object to - /// The object to serialize. - /// If this object uses the , use this to control if you want all properties or just the changed once. - /// Cancel the request during execution. - /// The serialized representation as a string. - public static async Task SerializeAsStringAsync(this T value, string contentType, bool serializeOnlyChangedValues = false, CancellationToken cancellationToken = default) where T : IParsable - => await KiotaSerializer.SerializeAsStringAsync(contentType, value, serializeOnlyChangedValues, cancellationToken); + /// + /// Serializes the given object into a string based on the content type. + /// + /// Content type to serialize the object to + /// The object to serialize. + /// If this object uses the , use this to control if you want all properties or just the changed once. + /// Cancel the request during execution. + /// The serialized representation as a string. + public static async Task SerializeAsStringAsync(this T value, string contentType, bool serializeOnlyChangedValues = false, CancellationToken cancellationToken = default) where T : IParsable + => await KiotaSerializer.SerializeAsStringAsync(contentType, value, serializeOnlyChangedValues, cancellationToken); - /// - /// Serializes the given collection into a stream based on the content type. - /// - /// Content type to serialize the object t - /// The object to serialize. - /// If this object uses the , use this to control if you want all properties or just the changed once. - /// The serialized representation as a stream. - public static Stream SerializeAsStream(this IEnumerable value, string contentType, bool serializeOnlyChangedValues = false) where T : IParsable - => KiotaSerializer.SerializeAsStream(contentType, value, serializeOnlyChangedValues); + /// + /// Serializes the given collection into a stream based on the content type. + /// + /// Content type to serialize the object t + /// The object to serialize. + /// If this object uses the , use this to control if you want all properties or just the changed once. + /// The serialized representation as a stream. + public static Stream SerializeAsStream(this IEnumerable value, string contentType, bool serializeOnlyChangedValues = false) where T : IParsable + => KiotaSerializer.SerializeAsStream(contentType, value, serializeOnlyChangedValues); - /// - /// Serializes the given collection into a string based on the content type. - /// - /// Content type to serialize the object to. - /// The object to serialize. - /// If this object uses the , use this to control if you want all properties or just the changed once. - /// Cancel the request during execution. - /// The serialized representation as a string. - public static async Task SerializeAsStringAsync(this IEnumerable value, string contentType, bool serializeOnlyChangedValues = false, CancellationToken cancellationToken = default) where T : IParsable - => await KiotaSerializer.SerializeAsStringAsync(contentType, value, serializeOnlyChangedValues, cancellationToken); + /// + /// Serializes the given collection into a string based on the content type. + /// + /// Content type to serialize the object to. + /// The object to serialize. + /// If this object uses the , use this to control if you want all properties or just the changed once. + /// Cancel the request during execution. + /// The serialized representation as a string. + public static async Task SerializeAsStringAsync(this IEnumerable value, string contentType, bool serializeOnlyChangedValues = false, CancellationToken cancellationToken = default) where T : IParsable + => await KiotaSerializer.SerializeAsStringAsync(contentType, value, serializeOnlyChangedValues, cancellationToken); - /// - /// Serializes the given collection into a stream based on the content type. - /// - /// Content type to serialize the object t - /// The object to serialize. - /// If this object uses the , use this to control if you want all properties or just the changed once. - /// The serialized representation as a stream. - public static Stream SerializeAsStream(this T[] value, string contentType, bool serializeOnlyChangedValues = false) where T : IParsable - => KiotaSerializer.SerializeAsStream(contentType, value, serializeOnlyChangedValues); + /// + /// Serializes the given collection into a stream based on the content type. + /// + /// Content type to serialize the object t + /// The object to serialize. + /// If this object uses the , use this to control if you want all properties or just the changed once. + /// The serialized representation as a stream. + public static Stream SerializeAsStream(this T[] value, string contentType, bool serializeOnlyChangedValues = false) where T : IParsable + => KiotaSerializer.SerializeAsStream(contentType, value, serializeOnlyChangedValues); - /// - /// Serializes the given collection into a string based on the content type. - /// - /// Content type to serialize the object to. - /// The object to serialize. - /// If this object uses the , use this to control if you want all properties or just the changed once. - /// Cancel the request during execution. - /// The serialized representation as a string. - public static async Task SerializeAsStringAsync(this T[] value, string contentType, bool serializeOnlyChangedValues = false, CancellationToken cancellationToken = default) where T : IParsable - => await KiotaSerializer.SerializeAsStringAsync(contentType, value, serializeOnlyChangedValues, cancellationToken); + /// + /// Serializes the given collection into a string based on the content type. + /// + /// Content type to serialize the object to. + /// The object to serialize. + /// If this object uses the , use this to control if you want all properties or just the changed once. + /// Cancel the request during execution. + /// The serialized representation as a string. + public static async Task SerializeAsStringAsync(this T[] value, string contentType, bool serializeOnlyChangedValues = false, CancellationToken cancellationToken = default) where T : IParsable + => await KiotaSerializer.SerializeAsStringAsync(contentType, value, serializeOnlyChangedValues, cancellationToken); } \ No newline at end of file