Skip to content

Commit d860828

Browse files
committed
restore nullable enums being nullable type -> it might be handy to differentiate between "empty value" and "no value"
1 parent ce6cc5f commit d860828

14 files changed

Lines changed: 51 additions & 21 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using StreamChat.Core.LowLevelClient;
3+
4+
namespace StreamChat.Core.Helpers
5+
{
6+
/// <summary>
7+
/// Extensions for <see cref="IEnumeratedStruct{TType}"/>
8+
/// </summary>
9+
internal static class EnumeratedStructExt
10+
{
11+
public static TDomain? TryLoadNullableStructFromDto<TDomain, TDto>(this TDomain? domain, TDto? dto)
12+
where TDomain : struct, IEquatable<TDomain>, ILoadableFrom<TDto, TDomain>
13+
where TDto : struct, IEnumeratedStruct<TDto>
14+
{
15+
if (!dto.HasValue)
16+
{
17+
return null;
18+
}
19+
20+
return domain?.LoadFromDto(dto.Value) ?? default(TDomain).LoadFromDto(dto.Value);
21+
}
22+
}
23+
}

Assets/Plugins/StreamChat/Core/Helpers/EnumeratedStructExt.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/StreamChat/Core/InternalDTO/Models/BlockListOptionsInternalDTO.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ internal partial class BlockListOptionsInternalDTO
2020
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<BlockListOptionsBehaviorInternalDTO>))]
2121
public BlockListOptionsBehaviorInternalDTO Behavior { get; set; }
2222

23+
[Newtonsoft.Json.JsonProperty("blocklist", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
24+
public string Blocklist { get; set; }
25+
2326
private System.Collections.Generic.Dictionary<string, object> _additionalProperties;
2427

2528
[Newtonsoft.Json.JsonExtensionData]

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ChannelConfigInternalDTO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal partial class ChannelConfigInternalDTO
3535

3636
[Newtonsoft.Json.JsonProperty("blocklist_behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3737
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodBehaviourTypeInternalDTO>))]
38-
public AutomodBehaviourTypeInternalDTO BlocklistBehavior { get; set; }
38+
public AutomodBehaviourTypeInternalDTO? BlocklistBehavior { get; set; }
3939

4040
[Newtonsoft.Json.JsonProperty("blocklists", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
4141
public System.Collections.Generic.List<BlockListOptionsInternalDTO> Blocklists { get; set; }

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ChannelConfigWithInfoInternalDTO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal partial class ChannelConfigWithInfoInternalDTO
3535

3636
[Newtonsoft.Json.JsonProperty("blocklist_behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3737
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodBehaviourTypeInternalDTO>))]
38-
public AutomodBehaviourTypeInternalDTO BlocklistBehavior { get; set; }
38+
public AutomodBehaviourTypeInternalDTO? BlocklistBehavior { get; set; }
3939

4040
[Newtonsoft.Json.JsonProperty("blocklists", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
4141
public System.Collections.Generic.List<BlockListOptionsInternalDTO> Blocklists { get; set; }

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ImageSizeInternalDTO.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal partial class ImageSizeInternalDTO
2121
/// </summary>
2222
[Newtonsoft.Json.JsonProperty("crop", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2323
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<ImageCropTypeInternalDTO>))]
24-
public ImageCropTypeInternalDTO Crop { get; set; }
24+
public ImageCropTypeInternalDTO? Crop { get; set; }
2525

2626
/// <summary>
2727
/// Target image height
@@ -34,7 +34,7 @@ internal partial class ImageSizeInternalDTO
3434
/// </summary>
3535
[Newtonsoft.Json.JsonProperty("resize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3636
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<ImageResizeTypeInternalDTO>))]
37-
public ImageResizeTypeInternalDTO Resize { get; set; }
37+
public ImageResizeTypeInternalDTO? Resize { get; set; }
3838

3939
/// <summary>
4040
/// Target image width

Assets/Plugins/StreamChat/Core/InternalDTO/Requests/CreatePollRequestInternalDTO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ internal partial class CreatePollRequestInternalDTO
6969

7070
[Newtonsoft.Json.JsonProperty("voting_visibility", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
7171
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<CreatePollRequestVotingVisibilityInternalDTO>))]
72-
public CreatePollRequestVotingVisibilityInternalDTO VotingVisibility { get; set; }
72+
public CreatePollRequestVotingVisibilityInternalDTO? VotingVisibility { get; set; }
7373

7474
private System.Collections.Generic.Dictionary<string, object> _additionalProperties;
7575

Assets/Plugins/StreamChat/Core/InternalDTO/Requests/MessageRequestInternalDTO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal partial class MessageRequestInternalDTO
7171

7272
[Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
7373
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<MessageRequestTypeInternalDTO>))]
74-
public MessageRequestTypeInternalDTO Type { get; set; }
74+
public MessageRequestTypeInternalDTO? Type { get; set; }
7575

7676
private System.Collections.Generic.Dictionary<string, object> _additionalProperties;
7777

Assets/Plugins/StreamChat/Core/InternalDTO/Requests/UpdatePollRequestInternalDTO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal partial class UpdatePollRequestInternalDTO
7878
/// </summary>
7979
[Newtonsoft.Json.JsonProperty("voting_visibility", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
8080
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<UpdatePollRequestVotingVisibilityInternalDTO>))]
81-
public UpdatePollRequestVotingVisibilityInternalDTO VotingVisibility { get; set; }
81+
public UpdatePollRequestVotingVisibilityInternalDTO? VotingVisibility { get; set; }
8282

8383
private System.Collections.Generic.Dictionary<string, object> _additionalProperties;
8484

Assets/Plugins/StreamChat/Core/InternalDTO/Responses/ChannelMemberResponseInternalDTO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ internal partial class ChannelMemberResponseInternalDTO
7575
/// </summary>
7676
[Newtonsoft.Json.JsonProperty("role", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
7777
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<ChannelMemberResponseRoleInternalDTO>))]
78-
public ChannelMemberResponseRoleInternalDTO Role { get; set; }
78+
public ChannelMemberResponseRoleInternalDTO? Role { get; set; }
7979

8080
/// <summary>
8181
/// Whether member is shadow banned in this channel or not

0 commit comments

Comments
 (0)