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

IParseNode.GetCollectionOf* methods can now return null #174

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions src/serialization/IParseNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,22 @@ public interface IParseNode
/// Gets the collection of primitive values of the node.
/// </summary>
/// <returns>The collection of primitive values.</returns>
IEnumerable<T> GetCollectionOfPrimitiveValues<T>();
IEnumerable<T>? GetCollectionOfPrimitiveValues<T>();
/// <summary>
/// Gets the collection of enum values of the node.
/// </summary>
/// <returns>The collection of enum values.</returns>
#if NET5_0_OR_GREATER
IEnumerable<T?> GetCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>() where T : struct, Enum;
IEnumerable<T?>? GetCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>() where T : struct, Enum;
#else
IEnumerable<T?> GetCollectionOfEnumValues<T>() where T : struct, Enum;
IEnumerable<T?>? GetCollectionOfEnumValues<T>() where T : struct, Enum;
#endif
/// <summary>
/// Gets the collection of model objects values of the node.
/// </summary>
/// <param name="factory">The factory to use to create the model object.</param>
/// <returns>The collection of model objects values.</returns>
IEnumerable<T> GetCollectionOfObjectValues<T>(ParsableFactory<T> factory) where T : IParsable;
IEnumerable<T>? GetCollectionOfObjectValues<T>(ParsableFactory<T> factory) where T : IParsable;
/// <summary>
/// Gets the enum value of the node.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions src/serialization/KiotaJsonSerializer.Deserialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,33 @@ public static partial class KiotaJsonSerializer
/// </summary>
/// <param name="stream">The stream to deserialize.</param>
/// <param name="parsableFactory">The factory to create the object.</param>
public static IEnumerable<T> DeserializeCollection<T>(Stream stream, ParsableFactory<T> parsableFactory) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(Stream stream, ParsableFactory<T> parsableFactory) where T : IParsable
=> KiotaSerializer.DeserializeCollection(_jsonContentType, stream, parsableFactory);
/// <summary>
/// Deserializes the given stream into a collection of objects based on the content type.
/// </summary>
/// <param name="serializedRepresentation">The serialized representation of the objects.</param>
/// <param name="parsableFactory">The factory to create the object.</param>
public static IEnumerable<T> DeserializeCollection<T>(string serializedRepresentation, ParsableFactory<T> parsableFactory) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(string serializedRepresentation, ParsableFactory<T> parsableFactory) where T : IParsable
=> KiotaSerializer.DeserializeCollection(_jsonContentType, serializedRepresentation, parsableFactory);
/// <summary>
/// Deserializes the given stream into a collection of objects based on the content type.
/// </summary>
/// <param name="stream">The stream to deserialize.</param>
#if NET5_0_OR_GREATER
public static IEnumerable<T> DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(Stream stream) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(Stream stream) where T : IParsable
#else
public static IEnumerable<T> DeserializeCollection<T>(Stream stream) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(Stream stream) where T : IParsable
#endif
=> KiotaSerializer.DeserializeCollection<T>(_jsonContentType, stream);
/// <summary>
/// Deserializes the given stream into a collection of objects based on the content type.
/// </summary>
/// <param name="serializedRepresentation">The serialized representation of the object.</param>
#if NET5_0_OR_GREATER
public static IEnumerable<T> DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string serializedRepresentation) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string serializedRepresentation) where T : IParsable
#else
public static IEnumerable<T> DeserializeCollection<T>(string serializedRepresentation) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(string serializedRepresentation) where T : IParsable
#endif
=> KiotaSerializer.DeserializeCollection<T>(_jsonContentType, serializedRepresentation);
}
12 changes: 6 additions & 6 deletions src/serialization/KiotaSerializer.Deserialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static ParsableFactory<T> GetFactoryFromType<T>() where T : IParsable
/// <param name="contentType">The content type of the stream.</param>
/// <param name="stream">The stream to deserialize.</param>
/// <param name="parsableFactory">The factory to create the object.</param>
public static IEnumerable<T> DeserializeCollection<T>(string contentType, Stream stream, ParsableFactory<T> parsableFactory) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(string contentType, Stream stream, ParsableFactory<T> parsableFactory) where T : IParsable
{
if(string.IsNullOrEmpty(contentType)) throw new ArgumentNullException(nameof(contentType));
if(stream == null) throw new ArgumentNullException(nameof(stream));
Expand All @@ -106,7 +106,7 @@ public static IEnumerable<T> DeserializeCollection<T>(string contentType, Stream
/// <param name="contentType">The content type of the stream.</param>
/// <param name="serializedRepresentation">The serialized representation of the objects.</param>
/// <param name="parsableFactory">The factory to create the object.</param>
public static IEnumerable<T> DeserializeCollection<T>(string contentType, string serializedRepresentation, ParsableFactory<T> parsableFactory) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(string contentType, string serializedRepresentation, ParsableFactory<T> parsableFactory) where T : IParsable
{
if(string.IsNullOrEmpty(serializedRepresentation)) throw new ArgumentNullException(nameof(serializedRepresentation));
using var stream = GetStreamFromString(serializedRepresentation);
Expand All @@ -118,9 +118,9 @@ public static IEnumerable<T> DeserializeCollection<T>(string contentType, string
/// <param name="contentType">The content type of the stream.</param>
/// <param name="stream">The stream to deserialize.</param>
#if NET5_0_OR_GREATER
public static IEnumerable<T> DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, Stream stream) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, Stream stream) where T : IParsable
#else
public static IEnumerable<T> DeserializeCollection<T>(string contentType, Stream stream) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(string contentType, Stream stream) where T : IParsable
#endif
=> DeserializeCollection(contentType, stream, GetFactoryFromType<T>());
/// <summary>
Expand All @@ -129,9 +129,9 @@ public static IEnumerable<T> DeserializeCollection<T>(string contentType, Stream
/// <param name="contentType">The content type of the stream.</param>
/// <param name="serializedRepresentation">The serialized representation of the object.</param>
#if NET5_0_OR_GREATER
public static IEnumerable<T> DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, string serializedRepresentation) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(string contentType, string serializedRepresentation) where T : IParsable
#else
public static IEnumerable<T> DeserializeCollection<T>(string contentType, string serializedRepresentation) where T : IParsable
public static IEnumerable<T>? DeserializeCollection<T>(string contentType, string serializedRepresentation) where T : IParsable
#endif
=> DeserializeCollection(contentType, serializedRepresentation, GetFactoryFromType<T>());
}
Loading