diff --git a/.github/workflows/check-buildstatus.yml b/.github/workflows/check-buildstatus.yml index c1cfaaf..836000d 100644 --- a/.github/workflows/check-buildstatus.yml +++ b/.github/workflows/check-buildstatus.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dotnet-version: [ '7.0.x' ] + dotnet-version: [ '8.0.x' ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml index 5e66190..5dfe996 100644 --- a/.github/workflows/preview-release.yml +++ b/.github/workflows/preview-release.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v2 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore dependencies run: dotnet restore - name: Build TwitchLib.Communication diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bbeead9..6a8de29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v2 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Restore dependencies run: dotnet restore - name: Build TwitchLib.Communication diff --git a/.github/workflows/tests-linux.yml b/.github/workflows/tests-linux.yml index 0266b95..c82070f 100644 --- a/.github/workflows/tests-linux.yml +++ b/.github/workflows/tests-linux.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - dotnet-version: [ '7.0.x' ] + dotnet-version: [ '8.0.x' ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/tests-windows.yml b/.github/workflows/tests-windows.yml index 4aee907..ca8040a 100644 --- a/.github/workflows/tests-windows.yml +++ b/.github/workflows/tests-windows.yml @@ -9,7 +9,7 @@ jobs: runs-on: windows-latest strategy: matrix: - dotnet-version: [ '7.0.x' ] + dotnet-version: [ '8.0.x' ] steps: - uses: actions/checkout@v3 diff --git a/src/TwitchLib.Communication.Tests/Clients/ClientTestsBase.cs b/src/TwitchLib.Communication.Tests/Clients/ClientTestsBase.cs index 7894e57..766dc25 100644 --- a/src/TwitchLib.Communication.Tests/Clients/ClientTestsBase.cs +++ b/src/TwitchLib.Communication.Tests/Clients/ClientTestsBase.cs @@ -1,5 +1,4 @@ using System; -using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -8,7 +7,6 @@ using TwitchLib.Communication.Models; using TwitchLib.Communication.Tests.Helpers; using Xunit; -using Xunit.Sdk; [assembly: CollectionBehavior(DisableTestParallelization = true)] namespace TwitchLib.Communication.Tests.Clients; @@ -45,7 +43,7 @@ public async Task Client_Raises_OnConnected_EventArgs() { var pauseConnected = new ManualResetEvent(false); - await Assert.RaisesAsync( + await MyAssert.RaisesAsync( h => client.OnConnected += h, h => client.OnConnected -= h, async () => @@ -81,7 +79,7 @@ public async Task Client_Raises_OnDisconnected_EventArgs() { var pauseDisconnected = new ManualResetEvent(false); - await Assert.RaisesAsync( + await MyAssert.RaisesAsync( h => client.OnDisconnected += h, h => client.OnDisconnected -= h, async () => @@ -122,7 +120,7 @@ public async Task Client_Raises_OnReconnected_EventArgs() { var pauseReconnected = new ManualResetEvent(false); - await Assert.RaisesAsync( + await MyAssert.RaisesAsync( h => client.OnReconnected += h, h => client.OnReconnected -= h, async () => @@ -189,631 +187,3 @@ public void Dispose_Client_Before_Connecting_IsOK() return (TClient?)constructor?.Invoke(constructorParameters); } } - - -#region Modified Assert -//TL;DR: Extracted version of XUNIT with -//modification to accept new event Handler - -public partial class Assert -{ - - /// - /// Verifies that a event with the exact event args (and not a derived type) is raised. - /// - /// The type of the event arguments to expect - /// Code to attach the event handler - /// Code to detach the event handler - /// A delegate to the code to be tested - /// The event sender and arguments wrapped in an object - /// Thrown when the expected event was not raised. - public static async Task> RaisesAsync(Action> attach, Action> detach, Func testCode) - { - var raisedEvent = await RaisesAsyncInternal(attach, detach, testCode); - - if (raisedEvent == null) - throw new RaisesException(typeof(T)); - - if (raisedEvent.Arguments != null && !raisedEvent.Arguments.GetType().Equals(typeof(T))) - throw new RaisesException(typeof(T), raisedEvent.Arguments.GetType()); - - return raisedEvent; - } - - /// - /// Verifies that an event with the exact or a derived event args is raised. - /// - /// The type of the event arguments to expect - /// Code to attach the event handler - /// Code to detach the event handler - /// A delegate to the code to be tested - /// The event sender and arguments wrapped in an object - /// Thrown when the expected event was not raised. - public static async Task> RaisesAnyAsync(Action> attach, Action> detach, Func testCode) - { - var raisedEvent = await RaisesAsyncInternal(attach, detach, testCode); - - if (raisedEvent == null) - throw new RaisesException(typeof(T)); - - return raisedEvent; - } - -#if XUNIT_NULLABLE - static async Task?> RaisesAsyncInternal(Action> attach, Action> detach, Func testCode) -#else - static async Task> RaisesAsyncInternal(Action> attach, Action> detach, Func testCode) -#endif - { - NotNull(attach); - NotNull(detach); - NotNull(testCode); - -#if XUNIT_NULLABLE - RaisedEvent? raisedEvent = null; - void handler(object? s, T args) => raisedEvent = new RaisedEvent(s, args); -#else - RaisedEvent? raisedEvent = null; - AsyncEventHandler value = (object? s, T args) => - { - raisedEvent = new RaisedEvent(s, args); - return Task.CompletedTask; - }; - AsyncEventHandler handler = value; -#endif - attach(handler); - await testCode(); - detach(handler); - return raisedEvent; - } - - /// - /// Represents a raised event after the fact. - /// - /// The type of the event arguments. - public class RaisedEvent - { - /// - /// The sender of the event. - /// -#if XUNIT_NULLABLE - public object? Sender { get; } -#else - public object Sender { get; } -#endif - - /// - /// The event arguments. - /// - public T Arguments { get; } - - /// - /// Creates a new instance of the class. - /// - /// The sender of the event. - /// The event arguments -#if XUNIT_NULLABLE - public RaisedEvent(object? sender, T args) -#else - public RaisedEvent(object sender, T args) -#endif - { - Sender = sender; - Arguments = args; - } - } - - -#if XUNIT_NULLABLE - public static void False([DoesNotReturnIf(parameterValue: true)] bool condition) -#else - public static void False(bool condition) -#endif - { - False((bool?)condition, null); - } - - /// - /// Verifies that the condition is false. - /// - /// The condition to be tested - /// Thrown if the condition is not false -#if XUNIT_NULLABLE - public static void False([DoesNotReturnIf(parameterValue: true)] bool? condition) -#else - public static void False(bool? condition) -#endif - { - False(condition, null); - } - - /// - /// Verifies that the condition is false. - /// - /// The condition to be tested - /// The message to show when the condition is not false - /// Thrown if the condition is not false -#if XUNIT_NULLABLE - public static void False([DoesNotReturnIf(parameterValue: true)] bool condition, string? userMessage) -#else - public static void False(bool condition, string userMessage) -#endif - { - False((bool?)condition, userMessage); - } - - /// - /// Verifies that the condition is false. - /// - /// The condition to be tested - /// The message to show when the condition is not false - /// Thrown if the condition is not false -#if XUNIT_NULLABLE - public static void False([DoesNotReturnIf(parameterValue: true)] bool? condition, string? userMessage) -#else - public static void False(bool? condition, string userMessage) -#endif - { - if (!condition.HasValue || condition.GetValueOrDefault()) - throw new FalseException(userMessage, condition); - } - - /// - /// Verifies that an expression is true. - /// - /// The condition to be inspected - /// Thrown when the condition is false -#if XUNIT_NULLABLE - public static void True([DoesNotReturnIf(parameterValue: false)] bool condition) -#else - public static void True(bool condition) -#endif - { - True((bool?)condition, null); - } - - /// - /// Verifies that an expression is true. - /// - /// The condition to be inspected - /// Thrown when the condition is false -#if XUNIT_NULLABLE - public static void True([DoesNotReturnIf(parameterValue: false)] bool? condition) -#else - public static void True(bool? condition) -#endif - { - True(condition, null); - } - - /// - /// Verifies that an expression is true. - /// - /// The condition to be inspected - /// The message to be shown when the condition is false - /// Thrown when the condition is false -#if XUNIT_NULLABLE - public static void True([DoesNotReturnIf(parameterValue: false)] bool condition, string? userMessage) -#else - public static void True(bool condition, string userMessage) -#endif - { - True((bool?)condition, userMessage); - } - - /// - /// Verifies that an expression is true. - /// - /// The condition to be inspected - /// The message to be shown when the condition is false - /// Thrown when the condition is false -#if XUNIT_NULLABLE - public static void True([DoesNotReturnIf(parameterValue: false)] bool? condition, string? userMessage) -#else - public static void True(bool? condition, string userMessage) -#endif - { - if (!condition.HasValue || !condition.GetValueOrDefault()) - throw new TrueException(userMessage, condition); - } - - /// - /// Verifies that a string contains a given sub-string, using the current culture. - /// - /// The sub-string expected to be in the string - /// The string to be inspected - /// Thrown when the sub-string is not present inside the string -#if XUNIT_NULLABLE - public static void Contains(string expectedSubstring, string? actualString) -#else - public static void Contains(string expectedSubstring, string actualString) -#endif - { - Contains(expectedSubstring, actualString, StringComparison.CurrentCulture); - } - - /// - /// Verifies that a string contains a given sub-string, using the given comparison type. - /// - /// The sub-string expected to be in the string - /// The string to be inspected - /// The type of string comparison to perform - /// Thrown when the sub-string is not present inside the string -#if XUNIT_NULLABLE - public static void Contains(string expectedSubstring, string? actualString, StringComparison comparisonType) -#else - public static void Contains(string expectedSubstring, string actualString, StringComparison comparisonType) -#endif - { - NotNull(expectedSubstring); - - if (actualString == null || actualString.IndexOf(expectedSubstring, comparisonType) < 0) - throw new ContainsException(expectedSubstring, actualString); - } - - /// - /// Verifies that a string does not contain a given sub-string, using the current culture. - /// - /// The sub-string which is expected not to be in the string - /// The string to be inspected - /// Thrown when the sub-string is present inside the string -#if XUNIT_NULLABLE - public static void DoesNotContain(string expectedSubstring, string? actualString) -#else - public static void DoesNotContain(string expectedSubstring, string actualString) -#endif - { - DoesNotContain(expectedSubstring, actualString, StringComparison.CurrentCulture); - } - - /// - /// Verifies that a string does not contain a given sub-string, using the current culture. - /// - /// The sub-string which is expected not to be in the string - /// The string to be inspected - /// The type of string comparison to perform - /// Thrown when the sub-string is present inside the given string -#if XUNIT_NULLABLE - public static void DoesNotContain(string expectedSubstring, string? actualString, StringComparison comparisonType) -#else - public static void DoesNotContain(string expectedSubstring, string actualString, StringComparison comparisonType) -#endif - { - NotNull(expectedSubstring); - - if (actualString != null && actualString.IndexOf(expectedSubstring, comparisonType) >= 0) - throw new DoesNotContainException(expectedSubstring, actualString); - } - - /// - /// Verifies that a string starts with a given string, using the current culture. - /// - /// The string expected to be at the start of the string - /// The string to be inspected - /// Thrown when the string does not start with the expected string -#if XUNIT_NULLABLE - public static void StartsWith(string? expectedStartString, string? actualString) -#else - public static void StartsWith(string expectedStartString, string actualString) -#endif - { - StartsWith(expectedStartString, actualString, StringComparison.CurrentCulture); - } - - /// - /// Verifies that a string starts with a given string, using the given comparison type. - /// - /// The string expected to be at the start of the string - /// The string to be inspected - /// The type of string comparison to perform - /// Thrown when the string does not start with the expected string -#if XUNIT_NULLABLE - public static void StartsWith(string? expectedStartString, string? actualString, StringComparison comparisonType) -#else - public static void StartsWith(string expectedStartString, string actualString, StringComparison comparisonType) -#endif - { - if (expectedStartString == null || actualString == null || !actualString.StartsWith(expectedStartString, comparisonType)) - throw new StartsWithException(expectedStartString, actualString); - } - - /// - /// Verifies that a string ends with a given string, using the current culture. - /// - /// The string expected to be at the end of the string - /// The string to be inspected - /// Thrown when the string does not end with the expected string -#if XUNIT_NULLABLE - public static void EndsWith(string? expectedEndString, string? actualString) -#else - public static void EndsWith(string expectedEndString, string actualString) -#endif - { - EndsWith(expectedEndString, actualString, StringComparison.CurrentCulture); - } - - /// - /// Verifies that a string ends with a given string, using the given comparison type. - /// - /// The string expected to be at the end of the string - /// The string to be inspected - /// The type of string comparison to perform - /// Thrown when the string does not end with the expected string -#if XUNIT_NULLABLE - public static void EndsWith(string? expectedEndString, string? actualString, StringComparison comparisonType) -#else - public static void EndsWith(string expectedEndString, string actualString, StringComparison comparisonType) -#endif - { - if (expectedEndString == null || actualString == null || !actualString.EndsWith(expectedEndString, comparisonType)) - throw new EndsWithException(expectedEndString, actualString); - } - - /// - /// Verifies that a string matches a regular expression. - /// - /// The regex pattern expected to match - /// The string to be inspected - /// Thrown when the string does not match the regex pattern -#if XUNIT_NULLABLE - public static void Matches(string expectedRegexPattern, string? actualString) -#else - public static void Matches(string expectedRegexPattern, string actualString) -#endif - { - NotNull(expectedRegexPattern); - - if (actualString == null || !Regex.IsMatch(actualString, expectedRegexPattern)) - throw new MatchesException(expectedRegexPattern, actualString); - } - - /// - /// Verifies that a string matches a regular expression. - /// - /// The regex expected to match - /// The string to be inspected - /// Thrown when the string does not match the regex -#if XUNIT_NULLABLE - public static void Matches(Regex expectedRegex, string? actualString) -#else - public static void Matches(Regex expectedRegex, string actualString) -#endif - { - NotNull(expectedRegex); - - if (actualString == null || !expectedRegex.IsMatch(actualString)) - throw new MatchesException(expectedRegex.ToString(), actualString); - } - - /// - /// Verifies that a string does not match a regular expression. - /// - /// The regex pattern expected not to match - /// The string to be inspected - /// Thrown when the string matches the regex pattern -#if XUNIT_NULLABLE - public static void DoesNotMatch(string expectedRegexPattern, string? actualString) -#else - public static void DoesNotMatch(string expectedRegexPattern, string actualString) -#endif - { - NotNull(expectedRegexPattern); - - if (actualString != null && Regex.IsMatch(actualString, expectedRegexPattern)) - throw new DoesNotMatchException(expectedRegexPattern, actualString); - } - - /// - /// Verifies that a string does not match a regular expression. - /// - /// The regex expected not to match - /// The string to be inspected - /// Thrown when the string matches the regex -#if XUNIT_NULLABLE - public static void DoesNotMatch(Regex expectedRegex, string? actualString) -#else - public static void DoesNotMatch(Regex expectedRegex, string actualString) -#endif - { - NotNull(expectedRegex); - - if (actualString != null && expectedRegex.IsMatch(actualString)) - throw new DoesNotMatchException(expectedRegex.ToString(), actualString); - } - - /// - /// Verifies that two strings are equivalent. - /// - /// The expected string value. - /// The actual string value. - /// Thrown when the strings are not equivalent. -#if XUNIT_NULLABLE - public static void Equal(string? expected, string? actual) -#else - public static void Equal(string expected, string actual) -#endif - { - Equal(expected, actual, false, false, false); - } - - /// - /// Verifies that two strings are equivalent. - /// - /// The expected string value. - /// The actual string value. - /// If set to true, ignores cases differences. The invariant culture is used. - /// If set to true, treats \r\n, \r, and \n as equivalent. - /// If set to true, treats spaces and tabs (in any non-zero quantity) as equivalent. - /// Thrown when the strings are not equivalent. -#if XUNIT_NULLABLE - public static void Equal( - string? expected, - string? actual, - bool ignoreCase = false, - bool ignoreLineEndingDifferences = false, - bool ignoreWhiteSpaceDifferences = false) -#else - public static void Equal( - string expected, - string actual, - bool ignoreCase = false, - bool ignoreLineEndingDifferences = false, - bool ignoreWhiteSpaceDifferences = false) -#endif - { -#if XUNIT_SPAN - if (expected == null && actual == null) - return; - if (expected == null || actual == null) - throw new EqualException(expected, actual, -1, -1); - - Equal(expected.AsSpan(), actual.AsSpan(), ignoreCase, ignoreLineEndingDifferences, ignoreWhiteSpaceDifferences); -#else - // Start out assuming the one of the values is null - int expectedIndex = -1; - int actualIndex = -1; - int expectedLength = 0; - int actualLength = 0; - - if (expected == null) - { - if (actual == null) - return; - } - else if (actual != null) - { - // Walk the string, keeping separate indices since we can skip variable amounts of - // data based on ignoreLineEndingDifferences and ignoreWhiteSpaceDifferences. - expectedIndex = 0; - actualIndex = 0; - expectedLength = expected.Length; - actualLength = actual.Length; - - while (expectedIndex < expectedLength && actualIndex < actualLength) - { - char expectedChar = expected[expectedIndex]; - char actualChar = actual[actualIndex]; - - if (ignoreLineEndingDifferences && IsLineEnding(expectedChar) && IsLineEnding(actualChar)) - { - expectedIndex = SkipLineEnding(expected, expectedIndex); - actualIndex = SkipLineEnding(actual, actualIndex); - } - else if (ignoreWhiteSpaceDifferences && IsWhiteSpace(expectedChar) && IsWhiteSpace(actualChar)) - { - expectedIndex = SkipWhitespace(expected, expectedIndex); - actualIndex = SkipWhitespace(actual, actualIndex); - } - else - { - if (ignoreCase) - { - expectedChar = Char.ToUpperInvariant(expectedChar); - actualChar = Char.ToUpperInvariant(actualChar); - } - - if (expectedChar != actualChar) - { - break; - } - - expectedIndex++; - actualIndex++; - } - } - } - - if (expectedIndex < expectedLength || actualIndex < actualLength) - { - throw new EqualException(expected, actual, expectedIndex, actualIndex); - } -#endif - } - static bool IsLineEnding(char c) - { - return c == '\r' || c == '\n'; - } - - static bool IsWhiteSpace(char c) - { - return c == ' ' || c == '\t'; - } - - static int SkipLineEnding(string value, int index) - { - if (value[index] == '\r') - { - ++index; - } - if (index < value.Length && value[index] == '\n') - { - ++index; - } - - return index; - } - - static int SkipWhitespace(string value, int index) - { - while (index < value.Length) - { - switch (value[index]) - { - case ' ': - case '\t': - index++; - break; - - default: - return index; - } - } - - return index; - } - - /// - /// Verifies that an object reference is not null. - /// - /// The object to be validated - /// Thrown when the object reference is null -#if XUNIT_NULLABLE - public static void NotNull([NotNull] object? @object) -#else - public static void NotNull(object @object) -#endif - { - if (@object == null) - throw new NotNullException(); - } - - /// - /// Verifies that an object reference is null. - /// - /// The object to be inspected - /// Thrown when the object reference is not null -#if XUNIT_NULLABLE - public static void Null([MaybeNull] object? @object) -#else - public static void Null(object @object) -#endif - { - if (@object != null) - throw new NullException(@object); - } - - /// - /// Indicates that the test should immediately fail. - /// - /// The failure message -#if XUNIT_NULLABLE - [DoesNotReturn] -#endif - public static void Fail(string message) - { - NotNull( message); - - throw new FailException(message); - } -} -#endregion diff --git a/src/TwitchLib.Communication.Tests/MyAssert.cs b/src/TwitchLib.Communication.Tests/MyAssert.cs new file mode 100644 index 0000000..2c42a44 --- /dev/null +++ b/src/TwitchLib.Communication.Tests/MyAssert.cs @@ -0,0 +1,79 @@ +using System; +using System.Threading.Tasks; +using TwitchLib.Communication.Events; +using Xunit; +using Xunit.Sdk; + +namespace TwitchLib.Communication.Tests; + +//Assert to accept new event Handler +public partial class MyAssert +{ + /// + /// Verifies that a event with the exact event args (and not a derived type) is raised. + /// + /// The type of the event arguments to expect + /// Code to attach the event handler + /// Code to detach the event handler + /// A delegate to the code to be tested + /// The event sender and arguments wrapped in an object + /// Thrown when the expected event was not raised. + public static async Task> RaisesAsync(Action> attach, Action> detach, Func testCode) + { + var raisedEvent = await RaisesAsyncInternal(attach, detach, testCode); + + if (raisedEvent == null) + throw RaisesException.ForNoEvent(typeof(T)); + + if (raisedEvent.Arguments != null && !raisedEvent.Arguments.GetType().Equals(typeof(T))) + throw RaisesException.ForIncorrectType(typeof(T), raisedEvent.Arguments.GetType()); + + return raisedEvent; + } + + static async Task?> RaisesAsyncInternal(Action> attach, Action> detach, Func testCode) + { + Assert.NotNull(attach); + Assert.NotNull(detach); + Assert.NotNull(testCode); + RaisedEvent? raisedEvent = null; + AsyncEventHandler handler = (s, args) => + { + raisedEvent = new RaisedEvent(s, args); + return Task.CompletedTask; + }; + + attach(handler); + await testCode(); + detach(handler); + return raisedEvent; + } + + /// + /// Represents a raised event after the fact. + /// + /// The type of the event arguments. + public class RaisedEvent + { + /// + /// The sender of the event. + /// + public object? Sender { get; } + + /// + /// The event arguments. + /// + public T Arguments { get; } + + /// + /// Creates a new instance of the class. + /// + /// The sender of the event. + /// The event arguments + public RaisedEvent(object? sender, T args) + { + Sender = sender; + Arguments = args; + } + } +} diff --git a/src/TwitchLib.Communication.Tests/TwitchLib.Communication.Tests.csproj b/src/TwitchLib.Communication.Tests/TwitchLib.Communication.Tests.csproj index c245c36..5d9b78d 100644 --- a/src/TwitchLib.Communication.Tests/TwitchLib.Communication.Tests.csproj +++ b/src/TwitchLib.Communication.Tests/TwitchLib.Communication.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 false enable disable @@ -9,15 +9,15 @@ - - - - - + + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/TwitchLib.Communication/Clients/ClientBase.cs b/src/TwitchLib.Communication/Clients/ClientBase.cs index 0dfc91f..e03c0c3 100644 --- a/src/TwitchLib.Communication/Clients/ClientBase.cs +++ b/src/TwitchLib.Communication/Clients/ClientBase.cs @@ -237,9 +237,6 @@ private async Task OpenPrivateAsync(bool isReconnect) return true; } - // Always create new client when opening new connection - Client = CreateClient(); - var first = true; Options.ReconnectionPolicy.Reset(isReconnect); @@ -247,6 +244,10 @@ private async Task OpenPrivateAsync(bool isReconnect) !Options.ReconnectionPolicy.AreAttemptsComplete()) { Logger?.TraceAction(GetType(), "try to connect"); + + // Always create new client when opening new connection + Client = CreateClient(); + if (!first) { await Task.Delay(Options.ReconnectionPolicy.GetReconnectInterval(), CancellationToken.None); diff --git a/src/TwitchLib.Communication/Clients/TcpClient.cs b/src/TwitchLib.Communication/Clients/TcpClient.cs index 1bfc475..683435d 100644 --- a/src/TwitchLib.Communication/Clients/TcpClient.cs +++ b/src/TwitchLib.Communication/Clients/TcpClient.cs @@ -19,6 +19,9 @@ public class TcpClient : ClientBase /// public override bool IsConnected => Client?.Connected ?? false; + /// + /// Initializes a new instance of the . + /// public TcpClient( IClientOptions? options = null, ILogger? logger = null) diff --git a/src/TwitchLib.Communication/Clients/WebsocketClient.cs b/src/TwitchLib.Communication/Clients/WebsocketClient.cs index 516175e..e3b574d 100644 --- a/src/TwitchLib.Communication/Clients/WebsocketClient.cs +++ b/src/TwitchLib.Communication/Clients/WebsocketClient.cs @@ -10,10 +10,15 @@ namespace TwitchLib.Communication.Clients; public class WebSocketClient : ClientBase { + /// protected override string Url { get; } + /// public override bool IsConnected => Client?.State == WebSocketState.Open; + /// + /// Initializes a new instance of the . + /// public WebSocketClient( IClientOptions? options = null, ILogger? logger = null) diff --git a/src/TwitchLib.Communication/Events/OnErrorEventArgs.cs b/src/TwitchLib.Communication/Events/OnErrorEventArgs.cs index 49a3217..11e456e 100644 --- a/src/TwitchLib.Communication/Events/OnErrorEventArgs.cs +++ b/src/TwitchLib.Communication/Events/OnErrorEventArgs.cs @@ -4,6 +4,9 @@ public class OnErrorEventArgs : EventArgs { public Exception Exception { get; } + /// + /// Initializes a new instance of the . + /// public OnErrorEventArgs(Exception exception) { Exception = exception; diff --git a/src/TwitchLib.Communication/Events/OnFatalErrorEventArgs.cs b/src/TwitchLib.Communication/Events/OnFatalErrorEventArgs.cs index 47cf586..af31ba4 100644 --- a/src/TwitchLib.Communication/Events/OnFatalErrorEventArgs.cs +++ b/src/TwitchLib.Communication/Events/OnFatalErrorEventArgs.cs @@ -4,11 +4,17 @@ public class OnFatalErrorEventArgs : EventArgs { public string Reason { get; } + /// + /// Initializes a new instance of the . + /// public OnFatalErrorEventArgs(string reason) { Reason = reason; } + /// + /// Initializes a new instance of the . + /// public OnFatalErrorEventArgs(Exception e) { Reason = e.ToString(); diff --git a/src/TwitchLib.Communication/Events/OnMessageEventArgs.cs b/src/TwitchLib.Communication/Events/OnMessageEventArgs.cs index 934b896..6fd374c 100644 --- a/src/TwitchLib.Communication/Events/OnMessageEventArgs.cs +++ b/src/TwitchLib.Communication/Events/OnMessageEventArgs.cs @@ -4,6 +4,9 @@ public class OnMessageEventArgs : EventArgs { public string Message { get; } + /// + /// Initializes a new instance of the . + /// public OnMessageEventArgs(string message) { Message = message; diff --git a/src/TwitchLib.Communication/Events/OnSendFailedEventArgs.cs b/src/TwitchLib.Communication/Events/OnSendFailedEventArgs.cs index 4b0c4c9..30d351b 100644 --- a/src/TwitchLib.Communication/Events/OnSendFailedEventArgs.cs +++ b/src/TwitchLib.Communication/Events/OnSendFailedEventArgs.cs @@ -6,6 +6,9 @@ public class OnSendFailedEventArgs : EventArgs public Exception Exception { get; } + /// + /// Initializes a new instance of the . + /// public OnSendFailedEventArgs(Exception exception, string message) { Exception = exception; diff --git a/src/TwitchLib.Communication/Extensions/LogExtensions.cs b/src/TwitchLib.Communication/Extensions/LogExtensions.cs index 8be0a16..9604757 100644 --- a/src/TwitchLib.Communication/Extensions/LogExtensions.cs +++ b/src/TwitchLib.Communication/Extensions/LogExtensions.cs @@ -1,5 +1,4 @@ -#pragma warning disable SYSLIB1006 // Multiple logging methods cannot use the same event id within a class -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using Microsoft.Extensions.Logging; namespace TwitchLib.Communication.Extensions @@ -17,16 +16,16 @@ public static void TraceMethodCall(this ILogger logger, Type type, [CallerMember TraceMethodCallCore(logger, type, callerMemberName, callerLineNumber); } - [LoggerMessage(0, LogLevel.Trace, "{type}.{callerMemberName} at line {callerLineNumber} is called")] + [LoggerMessage(LogLevel.Trace, "{type}.{callerMemberName} at line {callerLineNumber} is called")] static partial void TraceMethodCallCore(this ILogger logger, Type type, string callerMemberName, int callerLineNumber); - [LoggerMessage(0, LogLevel.Error, "Exception in {type}.{callerMemberName} at line {callerLineNumber}")] + [LoggerMessage(LogLevel.Error, "Exception in {type}.{callerMemberName} at line {callerLineNumber}")] public static partial void LogExceptionAsError(this ILogger logger, Type type, Exception exception, [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = 0); - [LoggerMessage(0, LogLevel.Information, "Exception in {type}.{callerMemberName} at line {callerLineNumber}")] + [LoggerMessage(LogLevel.Information, "Exception in {type}.{callerMemberName} at line {callerLineNumber}")] public static partial void LogExceptionAsInformation(this ILogger logger, Type type, Exception exception, [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = 0); - [LoggerMessage(0, LogLevel.Trace, "{type}.{callerMemberName} at line {callerLineNumber}: {action}")] + [LoggerMessage(LogLevel.Trace, "{type}.{callerMemberName} at line {callerLineNumber}: {action}")] public static partial void TraceAction(this ILogger logger, Type type, string action, [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = 0); } } diff --git a/src/TwitchLib.Communication/Models/ClientOptions.cs b/src/TwitchLib.Communication/Models/ClientOptions.cs index 0741bf3..55e3b7b 100644 --- a/src/TwitchLib.Communication/Models/ClientOptions.cs +++ b/src/TwitchLib.Communication/Models/ClientOptions.cs @@ -18,6 +18,7 @@ public class ClientOptions : IClientOptions public ClientType ClientType { get; } /// + /// Initializes a new instance of the . /// /// /// your own diff --git a/src/TwitchLib.Communication/Models/NoReconnectionPolicy.cs b/src/TwitchLib.Communication/Models/NoReconnectionPolicy.cs index 70b4df1..adcc6ff 100644 --- a/src/TwitchLib.Communication/Models/NoReconnectionPolicy.cs +++ b/src/TwitchLib.Communication/Models/NoReconnectionPolicy.cs @@ -5,6 +5,9 @@ /// public class NoReconnectionPolicy : ReconnectionPolicy { + /// + /// Initializes a new instance of the . + /// public NoReconnectionPolicy() : base( reconnectInterval: 0, diff --git a/src/TwitchLib.Communication/TwitchLib.Communication.csproj b/src/TwitchLib.Communication/TwitchLib.Communication.csproj index b59d546..338c43a 100644 --- a/src/TwitchLib.Communication/TwitchLib.Communication.csproj +++ b/src/TwitchLib.Communication/TwitchLib.Communication.csproj @@ -1,26 +1,26 @@  - netstandard2.0;netstandard2.1;net6.0;net7.0 + netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0 enable enable latest - 2.0.0 + 2.0.1 $(VersionSuffix) swiftyspiffy, Prom3theu5, Syzuna, LuckyNoS7evin swiftyspiffy, Prom3theu5, Syzuna, LuckyNoS7evin Connection library used throughout TwitchLib to replace third party depedencies. - Copyright 2023 + Copyright 2024 https://opensource.org/licenses/MIT https://github.com/TwitchLib/TwitchLib.Communication https://cdn.syzuna-programs.de/images/twitchlib.png https://github.com/TwitchLib/TwitchLib.Communication Git twitch twitchlib library irc chat c# csharp api events pubsub net standard 2.0 - Fix reconnect loop on disconnect + Fix disposing issue, updated dependecies and framework version en-US - 2.0.0 - 2.0.0 + 2.0.1 + 2.0.1 true True nullable @@ -29,6 +29,6 @@ - +