Skip to content

Commit

Permalink
.net 8 changes, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
AoshiW committed Nov 6, 2023
1 parent c1fda4c commit 167e932
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-buildstatus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build TwitchLib.Client
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build TwitchLib.Client
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build TwitchLib.Client
Expand Down
4 changes: 2 additions & 2 deletions TwitchLib.Client.Benchmark/TwitchLib.Client.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.7" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 7 additions & 2 deletions TwitchLib.Client.Models/MessageEmote.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Text;
using System.Text.RegularExpressions;

// TODO: Missing builder
Expand Down Expand Up @@ -234,7 +235,11 @@ public MessageEmote(
public class MessageEmoteCollection
{
private readonly Dictionary<string, MessageEmote> _emotes;
#if NET8_0_OR_GREATER
private static readonly CompositeFormat BasePattern = CompositeFormat.Parse(@"(\b {0}\b)|(\b{0} \b)|(?<=\W){0}(?=$)|(?<=\s){0}(?=\s)|(^{0}$)");
#else
private const string BasePattern = @"(\b {0}\b)|(\b{0} \b)|(?<=\W){0}(?=$)|(?<=\s){0}(?=\s)|(^{0}$)";
#endif

/// <summary> Do not access directly! Backing field for <see cref="CurrentPattern"/> </summary>
private string? _currentPattern;
Expand Down Expand Up @@ -321,11 +326,11 @@ public void Add(MessageEmote emote)
if (CurrentPattern == null)
{
//string i = String.Format(_basePattern, "(" + emote.EscapedText + "){0}");
CurrentPattern = string.Format(BasePattern, emote.EscapedText);
CurrentPattern = string.Format(null, BasePattern, emote.EscapedText);
}
else
{
CurrentPattern = CurrentPattern + "|" + string.Format(BasePattern, emote.EscapedText);
CurrentPattern = CurrentPattern + "|" + string.Format(null, BasePattern, emote.EscapedText);
}
}

Expand Down
2 changes: 1 addition & 1 deletion TwitchLib.Client.Models/TwitchLib.Client.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
8 changes: 4 additions & 4 deletions TwitchLib.Client.Test/MyAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public partial class MyAssert
public static async Task<RaisedEvent<T>> RaisesAsync<T>(Action<AsyncEventHandler<T>> attach, Action<AsyncEventHandler<T>> detach, Func<Task> testCode)
{
var raisedEvent = await RaisesAsyncInternal(attach, detach, testCode);

if (raisedEvent == null)
throw new RaisesException(typeof(T));
throw RaisesException.ForNoEvent(typeof(T));

if (raisedEvent.Arguments != null && !raisedEvent.Arguments.GetType().Equals(typeof(T)))
throw new RaisesException(typeof(T), raisedEvent.Arguments.GetType());
throw RaisesException.ForIncorrectType(typeof(T), raisedEvent.Arguments.GetType());

return raisedEvent;
}
Expand All @@ -45,7 +45,7 @@ public static async Task<RaisedEvent<T>> RaisesAnyAsync<T>(Action<AsyncEventHand
var raisedEvent = await RaisesAsyncInternal(attach, detach, testCode);

if (raisedEvent == null)
throw new RaisesException(typeof(T));
throw RaisesException.ForNoEvent(typeof(T));

return raisedEvent;
}
Expand Down
6 changes: 3 additions & 3 deletions TwitchLib.Client.Test/TwitchLib.Client.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
30 changes: 14 additions & 16 deletions TwitchLib.Client/Extensions/LogExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
#pragma warning disable SYSLIB1006 // Multiple logging methods cannot use the same event id within a class
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;

namespace TwitchLib.Client.Extensions;

internal static partial class LogExtensions
{
[LoggerMessage(0, LogLevel.Information, "Connecting Twitch Chat Client...")]
[LoggerMessage(LogLevel.Information, "Connecting Twitch Chat Client...")]
public static partial void LogConnecting(this ILogger<TwitchClient> logger);

[LoggerMessage(0, LogLevel.Information, "Disconnecting Twitch Chat Client...")]
[LoggerMessage(LogLevel.Information, "Disconnecting Twitch Chat Client...")]
public static partial void LogDisconnecting(this ILogger<TwitchClient> logger);

[LoggerMessage(0, LogLevel.Information, "TwitchLib-TwitchClient initialized, assembly version: {version}")]
[LoggerMessage(LogLevel.Information, "TwitchLib-TwitchClient initialized, assembly version: {version}")]
public static partial void LogInitialized(this ILogger<TwitchClient> logger, Version version);

[LoggerMessage(0, LogLevel.Information, "Joining channel: {channel}")]
[LoggerMessage(LogLevel.Information, "Joining channel: {channel}")]
public static partial void LogJoiningChannel(this ILogger<TwitchClient> logger, string channel);

[LoggerMessage(0, LogLevel.Debug, "Finished channel joining queue.")]
[LoggerMessage(LogLevel.Debug, "Finished channel joining queue.")]
public static partial void LogChannelJoiningFinished(this ILogger<TwitchClient> logger);

[LoggerMessage(0, LogLevel.Information, "Leaving channel: {channel}")]
[LoggerMessage(LogLevel.Information, "Leaving channel: {channel}")]
public static partial void LogLeavingChannel(this ILogger<TwitchClient> logger, string channel);

[LoggerMessage(0, LogLevel.Error, "Message length has exceeded the maximum character count. (500)")]
[LoggerMessage(LogLevel.Error, "Message length has exceeded the maximum character count. (500)")]
public static partial void LogMessageTooLong(this ILogger<TwitchClient> logger);

[LoggerMessage(0, LogLevel.Trace, "Received: {line}")]
[LoggerMessage(LogLevel.Trace, "Received: {line}")]
public static partial void LogReceived(this ILogger<TwitchClient> logger, string line);

[LoggerMessage(0, LogLevel.Information, "Reconnecting to Twitch")]
[LoggerMessage(LogLevel.Information, "Reconnecting to Twitch")]
public static partial void LogReconnecting(this ILogger<TwitchClient> logger);

[LoggerMessage(0, LogLevel.Debug, "Should be connected!")]
[LoggerMessage(LogLevel.Debug, "Should be connected!")]
public static partial void LogShouldBeConnected(this ILogger<TwitchClient> logger);

[LoggerMessage(0, LogLevel.Warning, "Unaccounted for: {ircString} (please create a TwitchLib GitHub issue :P)")]
[LoggerMessage(LogLevel.Warning, "Unaccounted for: {ircString} (please create a TwitchLib GitHub issue :P)")]
public static partial void LogUnaccountedFor(this ILogger<TwitchClient> logger, string ircString);

[LoggerMessage(0, LogLevel.Debug, "Writing: {message}")]
[LoggerMessage(LogLevel.Debug, "Writing: {message}")]
public static partial void LogWriting(this ILogger<TwitchClient> logger, string message);

[LoggerMessage(0, LogLevel.Error, "{message}")]
[LoggerMessage(LogLevel.Error, "{message}")]
public static partial void LogException(this ILogger logger, string message, Exception ex);
}
4 changes: 2 additions & 2 deletions TwitchLib.Client/TwitchLib.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Features>strict</Features>
<Nullable>enable</Nullable>
Expand All @@ -27,7 +27,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="TwitchLib.Communication" Version="2.0.0" />
</ItemGroup>
Expand Down

0 comments on commit 167e932

Please sign in to comment.