Skip to content

Commit 04b47b8

Browse files
authored
Merge pull request #40 from AoshiW/nullable-and-props
better nullable annotation, add missing props
2 parents 7b3edb2 + fbf9900 commit 04b47b8

15 files changed

+97
-12
lines changed

TwitchLib.EventSub.Core/Models/Charity/CharityBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ public abstract class CharityBase
2222
/// </summary>
2323
public string CharityName { get; set; } = string.Empty;
2424
/// <summary>
25+
/// A description of the charity.
26+
/// </summary>
27+
public string CharityDescription { get; set; } = string.Empty;
28+
/// <summary>
2529
/// A URL to the charity’s logo.
2630
/// </summary>
2731
public string CharityLogo { get; set; } = string.Empty;
32+
/// <summary>
33+
/// A URL to the charity’s website.
34+
/// </summary>
35+
public string CharityWebsite { get; set; } = string.Empty;
2836
}

TwitchLib.EventSub.Core/Models/Chat/ChatCommunitySubGift.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public sealed class ChatCommunitySubGift
1010
/// </summary>
1111
public string Id { get; set; } = string.Empty;
1212
/// <summary>
13+
/// Number of subscriptions being gifted.
14+
/// </summary>
15+
public int Total { get; set; }
16+
/// <summary>
1317
/// The type of subscription plan being used. Possible values are:
1418
/// <para>1000 — First level of paid subscription</para>
1519
/// <para>2000 — Second level of paid subscription</para>

TwitchLib.EventSub.Core/Models/Chat/ChatGiftPaidUpgrade.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace TwitchLib.EventSub.Core.Models.Chat;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace TwitchLib.EventSub.Core.Models.Chat;
24

35
/// <summary>
46
/// Information about the community gift paid upgrade event. Null if notice_type is not gift_paid_upgrade.
@@ -8,6 +10,9 @@ public sealed class ChatGiftPaidUpgrade
810
/// <summary>
911
/// Whether the gift was given anonymously.
1012
/// </summary>
13+
#if !NETSTANDARD
14+
[MemberNotNullWhen(false, nameof(GifterUserId), nameof(GifterUserLogin), nameof(GifterUserName))]
15+
#endif
1116
public bool GifterIsAnonymous { get; set; }
1217
/// <summary>
1318
/// Optional. The user ID of the user who gifted the subscription. Null if anonymous.

TwitchLib.EventSub.Core/Models/Chat/ChatPayItForward.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace TwitchLib.EventSub.Core.Models.Chat;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace TwitchLib.EventSub.Core.Models.Chat;
24

35
/// <summary>
46
/// Information about the pay it forward event. Null if notice_type is not pay_it_forward.
@@ -20,6 +22,9 @@ public sealed class ChatPayItForward
2022
/// <summary>
2123
/// Whether the gift was given anonymously.
2224
/// </summary>
25+
#if !NETSTANDARD
26+
[MemberNotNullWhen(false, nameof(GifterUserId), nameof(GifterUserLogin), nameof(GifterUserName))]
27+
#endif
2328
public bool GifterIsAnonymous { get; set; }
2429
/// <summary>
2530
/// Optional. The user ID of the user who gifted the subscription. Null if anonymous.

TwitchLib.EventSub.Core/Models/HypeTrain/HypeTrainBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ public class HypeTrainBase
3939
/// The current level of the Hype Train.
4040
/// </summary>
4141
public int Level { get; set; }
42+
/// <summary>
43+
/// Indicates if the Hype Train is a Golden Kappa Train.
44+
/// </summary>
45+
public bool IsGoldenKappaTrain { get; set; }
4246
}

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelBan.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics.CodeAnalysis;
23

34
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
45

@@ -60,5 +61,8 @@ public sealed class ChannelBan
6061
/// <summary>
6162
/// Indicates whether the ban is permanent (true) or a timeout (false). If true, EndsAt will be null.
6263
/// </summary>
64+
#if !NETSTANDARD
65+
[MemberNotNullWhen(false, nameof(EndsAt))]
66+
#endif
6367
public bool IsPermanent { get; set; }
6468
}

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelCharityCampaignDonate.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using TwitchLib.EventSub.Core.Models.Charity;
1+
using System;
2+
using TwitchLib.EventSub.Core.Models.Charity;
23

34
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
45

@@ -9,6 +10,10 @@ namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
910
/// </summary>
1011
public sealed class ChannelCharityCampaignDonate : CharityBase
1112
{
13+
/// <summary>
14+
/// An ID that identifies the donation. The ID is unique across campaigns.
15+
/// </summary>
16+
public string Id { get; set; } = string.Empty;
1217
/// <summary>
1318
/// An ID that uniquely identifies the charity campaign.
1419
/// </summary>
@@ -34,5 +39,6 @@ public sealed class ChannelCharityCampaignDonate : CharityBase
3439
/// <summary>
3540
/// The ISO-4217 three-letter currency code that identifies the type of currency in value.
3641
/// </summary>
42+
[Obsolete("This property is a typo, please use: Amount.Currency")]
3743
public string Currency { get; set; } = string.Empty;
3844
}

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelCharityCampaignStart.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ public sealed class ChannelCharityCampaignStart : CharityBase
1616
/// </summary>
1717
public string Id { get; set; } = string.Empty;
1818
/// <summary>
19-
/// A URL to the charity’s website.
20-
/// </summary>
21-
public string CharityWebsite { get; set; } = string.Empty;
22-
/// <summary>
2319
/// An object that contains the current amount of donations that the campaign has received.
2420
/// </summary>
2521
public CharityAmount CurrentAmount { get; set; } = new();

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelCharityCampaignStop.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ public sealed class ChannelCharityCampaignStop
2929
/// </summary>
3030
public string BroadcasterName { get; set; } = string.Empty;
3131
/// <summary>
32+
/// A description of the charity.
33+
/// </summary>
34+
public string CharityDescription { get; set; } = string.Empty;
35+
/// <summary>
36+
/// A URL to an image of the charity’s logo. The image’s type is PNG and its size is 100px X 100px.
37+
/// </summary>
38+
public string CharityLogo { get; set; } = string.Empty;
39+
/// <summary>
40+
/// A URL to the charity’s website.
41+
/// </summary>
42+
public string CharityWebsite { get; set; } = string.Empty;
43+
/// <summary>
3244
/// An object that contains the final amount of donations that the campaign received.
3345
/// </summary>
3446
public CharityAmount CurrentAmount { get; set; } = new();

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelCheer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
24

35
/// <summary>
46
/// Channel Cheer subscription type model
@@ -10,6 +12,9 @@ public sealed class ChannelCheer
1012
/// <summary>
1113
/// Whether the user cheered anonymously or not.
1214
/// </summary>
15+
#if !NETSTANDARD
16+
[MemberNotNullWhen(false, nameof(UserId), nameof(UserLogin), nameof(UserName))]
17+
#endif
1318
public bool IsAnonymous { get; set; }
1419
/// <summary>
1520
/// The user ID for the user who cheered on the specified channel. This is null if is_anonymous is true.

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarGuestUpdate.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
99
/// </summary>
1010
public sealed class ChannelGuestStarGuestUpdate : ChannelGuestStarBase
1111
{
12+
/// <summary>
13+
/// User ID of the host channel.
14+
/// </summary>
15+
public string HostUserId { get; set; }
16+
/// <summary>
17+
/// The host display name.
18+
/// </summary>
19+
public string HostUserName { get; set; }
20+
/// <summary>
21+
/// The host login.
22+
/// </summary>
23+
public string HostUserLogin { get; set; }
1224
/// <summary>
1325
/// The current state of the user after the update has taken place. Can be one of the following:
1426
/// <para>

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSessionEnd.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,16 @@ public sealed class ChannelGuestStarSessionEnd : ChannelGuestStarSessionBase
1818
/// RFC3339 timestamp indicating the time the session ended.
1919
/// </summary>
2020
public DateTimeOffset EndedAt { get; set; }
21+
/// <summary>
22+
/// User ID of the host channel.
23+
/// </summary>
24+
public string HostUserId { get; set; }
25+
/// <summary>
26+
/// The host display name.
27+
/// </summary>
28+
public string HostUserName { get; set; }
29+
/// <summary>
30+
/// The host login.
31+
/// </summary>
32+
public string HostUserLogin { get; set; }
2133
}

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelGuestStarSlotUpdate.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using TwitchLib.EventSub.Core.Models.GuestStar;
23

34
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
@@ -7,6 +8,7 @@ namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
78
/// <para>Description:</para>
89
/// <para>The channel.guest_star_slot.update subscription type sends a notification when a slot setting is updated in an active Guest Star session.</para>
910
/// </summary>
11+
[Obsolete("Removed 2023‑08‑24")]
1012
public class ChannelGuestStarSlotUpdate : ChannelGuestStarBase
1113
{
1214
/// <summary>

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelShieldModeEnd.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ public sealed class ChannelShieldModeEnd : ShieldModeBase
1313
/// <summary>
1414
/// The UTC timestamp (in RFC3339 format) of when the moderator deactivated Shield Mode.
1515
/// </summary>
16+
[Obsolete("This property is a typo, please use: EndedAt")]
1617
public DateTimeOffset StartedAt { get; set; } = DateTimeOffset.MinValue;
18+
/// <summary>
19+
/// The UTC timestamp (in RFC3339 format) of when the moderator deactivated Shield Mode.
20+
/// </summary>
21+
public DateTimeOffset EndedAt { get; set; } = DateTimeOffset.MinValue;
1722
}

TwitchLib.EventSub.Core/SubscriptionTypes/Channel/ChannelSubscriptionGift.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
24

35
/// <summary>
46
/// Channel Subscription Gift subscription type model
@@ -10,15 +12,15 @@ public sealed class ChannelSubscriptionGift
1012
/// <summary>
1113
/// The user ID of the user who sent the subscription gift. Set to null if it was an anonymous subscription gift.
1214
/// </summary>
13-
public string UserId { get; set; } = string.Empty;
15+
public string? UserId { get; set; } = string.Empty;
1416
/// <summary>
1517
/// The user display name of the user who sent the gift. Set to null if it was an anonymous subscription gift.
1618
/// </summary>
17-
public string UserName { get; set; } = string.Empty;
19+
public string? UserName { get; set; } = string.Empty;
1820
/// <summary>
1921
/// The user login of the user who sent the gift. Set to null if it was an anonymous subscription gift.
2022
/// </summary>
21-
public string UserLogin { get; set; } = string.Empty;
23+
public string? UserLogin { get; set; } = string.Empty;
2224
/// <summary>
2325
/// The broadcaster user ID.
2426
/// </summary>
@@ -46,5 +48,8 @@ public sealed class ChannelSubscriptionGift
4648
/// <summary>
4749
/// Whether the subscription gift was anonymous.
4850
/// </summary>
51+
#if !NETSTANDARD
52+
[MemberNotNullWhen(false, nameof(UserId), nameof(UserLogin), nameof(UserName))]
53+
#endif
4954
public bool IsAnonymous { get; set; }
5055
}

0 commit comments

Comments
 (0)