diff --git a/CHANGELOG.md b/CHANGELOG.md index 188b3e1..9bd68f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.12.3] - 2024-09-03 + +### Changed + +- Fixed optional parameters in KiotaJsonSerialization. [#366](https://github.com/microsoft/kiota-dotnet/issues/366) + ## [1.12.2] - 2024-08-23 ### Changed -- Fixed a bug where calls to ApiClientBuilder.EnableBackingStoreForParseNodeFactory and ApiClientBuilder.EnableBackingStoreForSerializationWriterFactory would enable a BackingStore around BackingStores. [#2563] (https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2563) [#2588] (https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2588) +- Fixed a bug where calls to ApiClientBuilder.EnableBackingStoreForParseNodeFactory and ApiClientBuilder.EnableBackingStoreForSerializationWriterFactory would enable a BackingStore around BackingStores. [#2563] () [#2588] () ## [1.12.1] - 2024-08-21 diff --git a/Directory.Build.props b/Directory.Build.props index d7c7528..1e5ce4e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 1.12.2 + 1.12.3 false diff --git a/src/abstractions/RequestInformation.cs b/src/abstractions/RequestInformation.cs index 493420f..066dd1a 100644 --- a/src/abstractions/RequestInformation.cs +++ b/src/abstractions/RequestInformation.cs @@ -5,12 +5,14 @@ using System; using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.Serialization; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; + #if NET5_0_OR_GREATER using System.Diagnostics.CodeAnalysis; #endif @@ -316,6 +318,7 @@ public void SetResponseHandler(IResponseHandler responseHandler) /// /// The binary stream to set as a body. [Obsolete("Use SetStreamContent and pass the content type instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public void SetStreamContent(Stream content) => SetStreamContent(content, BinaryContentType); /// diff --git a/src/abstractions/serialization/IParseNodeFactory.cs b/src/abstractions/serialization/IParseNodeFactory.cs index d466ef7..7ba5bac 100644 --- a/src/abstractions/serialization/IParseNodeFactory.cs +++ b/src/abstractions/serialization/IParseNodeFactory.cs @@ -3,6 +3,7 @@ // ------------------------------------------------------------------------------ using System; +using System.ComponentModel; using System.IO; namespace Microsoft.Kiota.Abstractions.Serialization @@ -23,6 +24,7 @@ public interface IParseNodeFactory /// The content type of the parse node. /// A parse node. [Obsolete("Use GetRootParseNodeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] IParseNode GetRootParseNode(string contentType, Stream content); } } diff --git a/src/abstractions/serialization/KiotaJsonSerializer.Deserialization.cs b/src/abstractions/serialization/KiotaJsonSerializer.Deserialization.cs index 515a066..77d8714 100644 --- a/src/abstractions/serialization/KiotaJsonSerializer.Deserialization.cs +++ b/src/abstractions/serialization/KiotaJsonSerializer.Deserialization.cs @@ -4,9 +4,11 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Threading; using System.Threading.Tasks; + #if NET5_0_OR_GREATER using System.Diagnostics.CodeAnalysis; #endif @@ -25,6 +27,7 @@ public static partial class KiotaJsonSerializer /// The factory to create the object. /// The serialized representation of the object. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static T? Deserialize(string serializedRepresentation, ParsableFactory parsableFactory) where T : IParsable => KiotaSerializer.Deserialize(_jsonContentType, serializedRepresentation, parsableFactory); /// @@ -33,6 +36,7 @@ public static partial class KiotaJsonSerializer /// The stream to deserialize. /// The factory to create the object. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static T? Deserialize(Stream stream, ParsableFactory parsableFactory) where T : IParsable => KiotaSerializer.Deserialize(_jsonContentType, stream, parsableFactory); /// @@ -40,6 +44,7 @@ public static partial class KiotaJsonSerializer /// /// The stream to deserialize. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static T? Deserialize<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(Stream stream) where T : IParsable #else @@ -51,6 +56,7 @@ public static partial class KiotaJsonSerializer /// /// The serialized representation of the object. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static T? Deserialize<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string serializedRepresentation) where T : IParsable #else @@ -63,6 +69,7 @@ public static partial class KiotaJsonSerializer /// The stream to deserialize. /// The factory to create the object. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DeserializeCollection(Stream stream, ParsableFactory parsableFactory) where T : IParsable => KiotaSerializer.DeserializeCollection(_jsonContentType, stream, parsableFactory); /// @@ -71,6 +78,7 @@ public static IEnumerable DeserializeCollection(Stream stream, ParsableFac /// The serialized representation of the objects. /// The factory to create the object. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DeserializeCollection(string serializedRepresentation, ParsableFactory parsableFactory) where T : IParsable => KiotaSerializer.DeserializeCollection(_jsonContentType, serializedRepresentation, parsableFactory); /// @@ -78,6 +86,7 @@ public static IEnumerable DeserializeCollection(string serializedRepresent /// /// The stream to deserialize. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static IEnumerable DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(Stream stream) where T : IParsable #else @@ -89,6 +98,7 @@ public static IEnumerable DeserializeCollection(Stream stream) where T : I /// /// The serialized representation of the object. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static IEnumerable DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string serializedRepresentation) where T : IParsable #else diff --git a/src/abstractions/serialization/KiotaJsonSerializer.Serialization.cs b/src/abstractions/serialization/KiotaJsonSerializer.Serialization.cs index dba6a24..5281264 100644 --- a/src/abstractions/serialization/KiotaJsonSerializer.Serialization.cs +++ b/src/abstractions/serialization/KiotaJsonSerializer.Serialization.cs @@ -22,9 +22,10 @@ public static partial class KiotaJsonSerializer /// /// Type of the object to serialize /// The object to serialize. + /// By default, you'll only get the changed properties. /// The serialized representation as a stream. - public static Stream SerializeAsStream(T value) where T : IParsable - => KiotaSerializer.SerializeAsStream(_jsonContentType, value); + public static Stream SerializeAsStream(T value, bool serializeOnlyChangedValues = true) where T : IParsable + => KiotaSerializer.SerializeAsStream(_jsonContentType, value, serializeOnlyChangedValues); /// /// Serializes the given object into a string based on the content type. @@ -44,17 +45,31 @@ public static string SerializeAsString(T value) where T : IParsable /// The object to serialize. /// The token to monitor for cancellation requests. /// The serialized representation as a string. + [Obsolete("This method is obsolete, use SerializeAsStringAsync with optional CancellationToken parameter instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static Task SerializeAsStringAsync(T value, CancellationToken cancellationToken) where T : IParsable - => KiotaSerializer.SerializeAsStringAsync(_jsonContentType, value, true, cancellationToken); + => SerializeAsStringAsync(value, true, cancellationToken); + + /// + /// Serializes the given object into a string based on the content type. + /// + /// Type of the object to serialize + /// The object to serialize. + /// By default, you'll only get the changed properties. + /// The token to monitor for cancellation requests. + /// The serialized representation as a string. + public static Task SerializeAsStringAsync(T value, bool serializeOnlyChangedValues = true, CancellationToken cancellationToken = default) where T : IParsable + => KiotaSerializer.SerializeAsStringAsync(_jsonContentType, value, serializeOnlyChangedValues, cancellationToken); /// /// Serializes the given object into a string based on the content type. /// /// Type of the object to serialize /// The object to serialize. + /// By default, you'll only get the changed properties. /// The serialized representation as a stream. - public static Stream SerializeAsStream(IEnumerable value) where T : IParsable - => KiotaSerializer.SerializeAsStream(_jsonContentType, value); + public static Stream SerializeAsStream(IEnumerable value, bool serializeOnlyChangedValues = true) where T : IParsable + => KiotaSerializer.SerializeAsStream(_jsonContentType, value, serializeOnlyChangedValues); /// /// Serializes the given object into a string based on the content type. @@ -73,6 +88,19 @@ public static string SerializeAsString(IEnumerable value) where T : IParsa /// The object to serialize. /// The token to monitor for cancellation requests. /// The serialized representation as a string. + [Obsolete("This method is obsolete, use SerializeAsStringAsync with optional CancellationToken parameter instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static Task SerializeAsStringAsync(IEnumerable value, CancellationToken cancellationToken) where T : IParsable => - KiotaSerializer.SerializeAsStringAsync(_jsonContentType, value, true, cancellationToken); + SerializeAsStringAsync(value, true, cancellationToken); + + /// + /// Serializes the given object into a string based on the content type. + /// + /// Type of the object to serialize + /// The object to serialize. + /// By default, you'll only get the changed properties. + /// The token to monitor for cancellation requests. + /// The serialized representation as a string. + public static Task SerializeAsStringAsync(IEnumerable value, bool serializeOnlyChangedValues = true, CancellationToken cancellationToken = default) where T : IParsable => + KiotaSerializer.SerializeAsStringAsync(_jsonContentType, value, serializeOnlyChangedValues, cancellationToken); } diff --git a/src/abstractions/serialization/KiotaSerializer.Deserialization.cs b/src/abstractions/serialization/KiotaSerializer.Deserialization.cs index 9437c7f..bf5c12c 100644 --- a/src/abstractions/serialization/KiotaSerializer.Deserialization.cs +++ b/src/abstractions/serialization/KiotaSerializer.Deserialization.cs @@ -4,10 +4,12 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; + #if NET5_0_OR_GREATER using System.Diagnostics.CodeAnalysis; #endif @@ -24,6 +26,7 @@ public static partial class KiotaSerializer /// The factory to create the object. /// The serialized representation of the object. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static T? Deserialize(string contentType, string serializedRepresentation, ParsableFactory parsableFactory) where T : IParsable { if(string.IsNullOrEmpty(serializedRepresentation)) throw new ArgumentNullException(nameof(serializedRepresentation)); @@ -49,6 +52,7 @@ private static Stream GetStreamFromString(string source) /// The stream to deserialize. /// The factory to create the object. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static T? Deserialize(string contentType, Stream stream, ParsableFactory parsableFactory) where T : IParsable { if(string.IsNullOrEmpty(contentType)) throw new ArgumentNullException(nameof(contentType)); @@ -63,6 +67,7 @@ private static Stream GetStreamFromString(string source) /// The content type of the stream. /// The stream to deserialize. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static T? Deserialize<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, Stream stream) where T : IParsable #else @@ -86,6 +91,7 @@ private static ParsableFactory GetFactoryFromType() where T : IParsable /// The content type of the stream. /// The serialized representation of the object. [Obsolete("Use DeserializeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static T? Deserialize<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, string serializedRepresentation) where T : IParsable #else @@ -100,6 +106,7 @@ private static ParsableFactory GetFactoryFromType() where T : IParsable /// The stream to deserialize. /// The factory to create the object. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DeserializeCollection(string contentType, Stream stream, ParsableFactory parsableFactory) where T : IParsable { if(string.IsNullOrEmpty(contentType)) throw new ArgumentNullException(nameof(contentType)); @@ -115,6 +122,7 @@ public static IEnumerable DeserializeCollection(string contentType, Stream /// The serialized representation of the objects. /// The factory to create the object. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable DeserializeCollection(string contentType, string serializedRepresentation, ParsableFactory parsableFactory) where T : IParsable { if(string.IsNullOrEmpty(serializedRepresentation)) throw new ArgumentNullException(nameof(serializedRepresentation)); @@ -127,6 +135,7 @@ public static IEnumerable DeserializeCollection(string contentType, string /// The content type of the stream. /// The stream to deserialize. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static IEnumerable DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, Stream stream) where T : IParsable #else @@ -139,6 +148,7 @@ public static IEnumerable DeserializeCollection(string contentType, Stream /// The content type of the stream. /// The serialized representation of the object. [Obsolete("Use DeserializeCollectionAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] #if NET5_0_OR_GREATER public static IEnumerable DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, string serializedRepresentation) where T : IParsable #else diff --git a/src/abstractions/serialization/KiotaSerializer.Serialization.cs b/src/abstractions/serialization/KiotaSerializer.Serialization.cs index b331212..7df9c64 100644 --- a/src/abstractions/serialization/KiotaSerializer.Serialization.cs +++ b/src/abstractions/serialization/KiotaSerializer.Serialization.cs @@ -45,6 +45,7 @@ public static Stream SerializeAsStream(string contentType, T value, bool seri /// The object to serialize. /// The serialized representation as a string. [Obsolete("This method is obsolete, use the async method instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static string SerializeAsString(string contentType, T value) where T : IParsable { using var stream = SerializeAsStream(contentType, value); @@ -97,6 +98,7 @@ public static Stream SerializeAsStream(string contentType, IEnumerable val /// The object to serialize. /// The serialized representation as a string. [Obsolete("This method is obsolete, use the async method instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static string SerializeAsString(string contentType, IEnumerable value) where T : IParsable { using var stream = SerializeAsStream(contentType, value); diff --git a/src/abstractions/serialization/ParseNodeFactoryRegistry.cs b/src/abstractions/serialization/ParseNodeFactoryRegistry.cs index 03d5b14..d38eac4 100644 --- a/src/abstractions/serialization/ParseNodeFactoryRegistry.cs +++ b/src/abstractions/serialization/ParseNodeFactoryRegistry.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Concurrent; +using System.ComponentModel; using System.IO; using System.Text.RegularExpressions; using System.Threading; @@ -43,6 +44,7 @@ public string ValidContentType /// The to parse /// [Obsolete("Use GetRootParseNodeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public IParseNode GetRootParseNode(string contentType, Stream content) { if(string.IsNullOrEmpty(contentType)) diff --git a/src/abstractions/serialization/ParseNodeProxyFactory.cs b/src/abstractions/serialization/ParseNodeProxyFactory.cs index 20f0040..78a891e 100644 --- a/src/abstractions/serialization/ParseNodeProxyFactory.cs +++ b/src/abstractions/serialization/ParseNodeProxyFactory.cs @@ -3,6 +3,7 @@ // ------------------------------------------------------------------------------ using System; +using System.ComponentModel; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -40,6 +41,7 @@ protected ParseNodeProxyFactory(IParseNodeFactory concrete, Action on /// The content type of the parse node. /// A parse node. [Obsolete("Use GetRootParseNodeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public IParseNode GetRootParseNode(string contentType, Stream content) { var node = _concrete.GetRootParseNode(contentType, content); diff --git a/src/authentication/azure/AzureIdentityAccessTokenProvider.cs b/src/authentication/azure/AzureIdentityAccessTokenProvider.cs index 033d37a..c77d548 100644 --- a/src/authentication/azure/AzureIdentityAccessTokenProvider.cs +++ b/src/authentication/azure/AzureIdentityAccessTokenProvider.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Text; using System.Threading; @@ -57,6 +58,7 @@ public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? al /// The scopes to request the access token for. /// The observability options to use for the authentication provider. [Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")] + [EditorBrowsable(EditorBrowsableState.Never)] public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts, ObservabilityOptions? observabilityOptions, params string[] scopes) : this(credential, allowedHosts, observabilityOptions, true, scopes) { diff --git a/src/authentication/azure/AzureIdentityAuthenticationProvider.cs b/src/authentication/azure/AzureIdentityAuthenticationProvider.cs index 10437cc..94a578b 100644 --- a/src/authentication/azure/AzureIdentityAuthenticationProvider.cs +++ b/src/authentication/azure/AzureIdentityAuthenticationProvider.cs @@ -3,6 +3,7 @@ // ------------------------------------------------------------------------------ using System; +using System.ComponentModel; using Azure.Core; using Microsoft.Kiota.Abstractions.Authentication; @@ -32,6 +33,7 @@ public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? /// The scopes to request the access token for. /// The observability options to use for the authentication provider. [Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")] + [EditorBrowsable(EditorBrowsableState.Never)] public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts, ObservabilityOptions? observabilityOptions, params string[] scopes) : this(credential, allowedHosts, observabilityOptions, true, scopes) { diff --git a/src/http/httpClient/Middleware/CompressionHandler.cs b/src/http/httpClient/Middleware/CompressionHandler.cs index d80270a..90eb330 100644 --- a/src/http/httpClient/Middleware/CompressionHandler.cs +++ b/src/http/httpClient/Middleware/CompressionHandler.cs @@ -3,6 +3,7 @@ // ------------------------------------------------------------------------------ using System; +using System.ComponentModel; using System.Diagnostics; using System.IO.Compression; using System.Net.Http; @@ -17,6 +18,7 @@ namespace Microsoft.Kiota.Http.HttpClientLibrary.Middleware /// A implementation that handles compression. /// [Obsolete("kiota clients now rely on the HttpClientHandler to handle decompression")] + [EditorBrowsable(EditorBrowsableState.Never)] public class CompressionHandler : DelegatingHandler { internal const string GZip = "gzip"; diff --git a/src/serialization/json/JsonParseNodeFactory.cs b/src/serialization/json/JsonParseNodeFactory.cs index 68565ca..279e17e 100644 --- a/src/serialization/json/JsonParseNodeFactory.cs +++ b/src/serialization/json/JsonParseNodeFactory.cs @@ -3,6 +3,7 @@ // ------------------------------------------------------------------------------ using System; +using System.ComponentModel; using System.IO; using System.Text.Json; using System.Threading; @@ -47,6 +48,7 @@ public JsonParseNodeFactory(KiotaJsonSerializationContext jsonJsonSerializationC /// The containing json to parse. /// An instance of for json manipulation [Obsolete("Use GetRootParseNodeAsync instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public IParseNode GetRootParseNode(string contentType, Stream content) { if(string.IsNullOrEmpty(contentType))