Skip to content

Commit

Permalink
nullable anotation for the .Models project except models for `UserN…
Browse files Browse the repository at this point in the history
…ocice` events and `MessageEmote.cs` (#246)
  • Loading branch information
AoshiW authored Sep 16, 2023
1 parent d6d26ef commit 56f89f5
Show file tree
Hide file tree
Showing 57 changed files with 353 additions and 312 deletions.
12 changes: 11 additions & 1 deletion TwitchLib.Client.Models/Announcement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using TwitchLib.Client.Enums;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using TwitchLib.Client.Enums;
using TwitchLib.Client.Models.Interfaces;
using TwitchLib.Client.Models.Internal;

Expand Down Expand Up @@ -73,6 +75,11 @@ public class Announcement : IHexColorProperty
/// <summary>Property representing the message of the announcement.</summary>
public string Message { get; }

/// <summary>
/// Contains undocumented tags.
/// </summary>
public Dictionary<string, string>? UndocumentedTags { get; }

/// SAMPLE: @badge-info=;badges=broadcaster/1,ambassador/1;color=#033700;display-name=BarryCarlyon;emotes=;flags=;id=55d90904-e515-47d0-ac1d-879f7f1d7b01;login=barrycarlyon;mod=0;msg-id=announcement;msg-param-color=PRIMARY;room-id=15185913;subscriber=0;system-msg=;tmi-sent-ts=1648758023469;user-id=15185913;user-type= :tmi.twitch.tv USERNOTICE #barrycarlyon :test announcment main
/// <summary>Announcement object constructor.</summary>
/// <param name="ircMessage">The IRC message from Twitch to be processed.</param>
Expand Down Expand Up @@ -152,6 +159,9 @@ public Announcement(IrcMessage ircMessage)
case Tags.UserType:
UserType = TagHelper.ToUserType(tag.Value);
break;
default:
(UndocumentedTags = new()).Add(tag.Key, tag.Value);
break;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion TwitchLib.Client.Models/Builders/ChannelStateBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/ChatMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using TwitchLib.Client.Enums;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/CheerBadgeBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class CheerBadgeBuilder : IBuilder<CheerBadge>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class CommunitySubscriptionBuilder : IFromIrcMessageBuilder<CommunitySubscription>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class ConnectionCredentialsBuilder : IBuilder<ConnectionCredentials>
{
Expand Down
3 changes: 2 additions & 1 deletion TwitchLib.Client.Models/Builders/EmoteBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using static TwitchLib.Client.Models.EmoteSet;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
Expand Down
10 changes: 5 additions & 5 deletions TwitchLib.Client.Models/Builders/ErrorEventBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class ErrorEventBuilder : IBuilder<ErrorEvent>
{
Expand All @@ -21,10 +24,7 @@ public static ErrorEventBuilder Create()

public ErrorEvent Build()
{
return new ErrorEvent
{
Message = _message
};
return new ErrorEvent(_message);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using TwitchLib.Client.Models.Internal;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Models.Internal;

namespace TwitchLib.Client.Models.Builders
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using TwitchLib.Client.Enums;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/IBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public interface IBuilder<T>
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/IFromIrcMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public interface IFromIrcMessageBuilder<T>
{
Expand Down
3 changes: 2 additions & 1 deletion TwitchLib.Client.Models/Builders/IrcMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums.Internal;
using TwitchLib.Client.Models.Internal;
Expand Down
19 changes: 5 additions & 14 deletions TwitchLib.Client.Models/Builders/OutboundChatMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class OutboundChatMessageBuilder : IBuilder<OutboundChatMessage>
{
private string _channel;
private string _message;
private string _userName;

private OutboundChatMessageBuilder()
{
Expand All @@ -27,20 +29,9 @@ public OutboundChatMessageBuilder WithMessage(string message)
return this;
}

public OutboundChatMessageBuilder WithUsername(string userName)
{
_userName = userName;
return this;
}

public OutboundChatMessage Build()
{
return new OutboundChatMessage
{
Channel = _channel,
Message = _message,
Username = _userName,
};
return new OutboundChatMessage(_channel, _message);
}
}
}
62 changes: 0 additions & 62 deletions TwitchLib.Client.Models/Builders/OutgoingMessageBuilder.cs

This file was deleted.

4 changes: 3 additions & 1 deletion TwitchLib.Client.Models/Builders/RaidNotificationBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Drawing;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/ReSubscriberBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class ReSubscriberBuilder : SubscriberBaseBuilder, IBuilder<ReSubscriber>, IFromIrcMessageBuilder<ReSubscriber>
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/RitualNewChatterBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class RitualNewChatterBuilder : IFromIrcMessageBuilder<RitualNewChatter>
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/SentMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using TwitchLib.Client.Enums;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
{
Expand Down
4 changes: 3 additions & 1 deletion TwitchLib.Client.Models/Builders/SubscriberBaseBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Drawing;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/SubscriberBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class SubscriberBuilder : SubscriberBaseBuilder, IBuilder<Subscriber>, IFromIrcMessageBuilder<Subscriber>
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/TwitchLibMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using TwitchLib.Client.Enums;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/UserBanBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class UserBanBuilder : IBuilder<UserBan>, IFromIrcMessageBuilder<UserBan>
{
Expand Down
4 changes: 3 additions & 1 deletion TwitchLib.Client.Models/Builders/UserStateBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Drawing;
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

using TwitchLib.Client.Enums;

namespace TwitchLib.Client.Models.Builders
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/UserTimeoutBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class UserTimeoutBuilder : IBuilder<UserTimeout>, IFromIrcMessageBuilder<UserTimeout>
{
Expand Down
5 changes: 4 additions & 1 deletion TwitchLib.Client.Models/Builders/WhisperMessageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace TwitchLib.Client.Models.Builders
#nullable disable
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace TwitchLib.Client.Models.Builders
{
public sealed class WhisperMessageBuilder : IBuilder<WhisperMessage>, IFromIrcMessageBuilder<WhisperMessage>
{
Expand Down
14 changes: 11 additions & 3 deletions TwitchLib.Client.Models/ChannelState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace TwitchLib.Client.Models
public class ChannelState
{
/// <summary>Property representing the current broadcaster language.</summary>
public string BroadcasterLanguage { get; }
public string BroadcasterLanguage { get; } = default!;

/// <summary>Property representing the current channel.</summary>
public string Channel { get; }
Expand All @@ -27,14 +27,19 @@ public class ChannelState
public bool? Rituals { get; }

/// <summary>Twitch assigned room id</summary>
public string RoomId { get; }
public string RoomId { get; } = default!;

/// <summary>Property representing whether Slow mode is being applied to chat or not. WILL BE NULL IF VALUE NOT PRESENT.</summary>
public int? SlowMode { get; }

/// <summary>Property representing whether Sub Mode is being applied to chat or not. WILL BE NULL IF VALUE NOT PRESENT.</summary>
public bool? SubOnly { get; }

/// <summary>
/// Contains undocumented tags.
/// </summary>
public Dictionary<string, string>? UndocumentedTags { get; }

/// <summary>ChannelState object constructor.</summary>
public ChannelState(IrcMessage ircMessage)
{
Expand Down Expand Up @@ -76,13 +81,16 @@ public ChannelState(IrcMessage ircMessage)
Mercury = TagHelper.ToBool(tagValue);
break;
default:
Console.WriteLine("[TwitchLib][ChannelState] Unaccounted for: " + tag);
(UndocumentedTags = new()).Add(tag.Key, tag.Value);
break;
}
}
Channel = ircMessage.Channel;
}

/// <summary>
/// Initializes a new instance of the <see cref="ChannelState"/> class.
/// </summary>
public ChannelState(
bool r9k,
bool rituals,
Expand Down
Loading

0 comments on commit 56f89f5

Please sign in to comment.