Skip to content

Commit e014582

Browse files
committed
Migrate to dotnet 9.0
1 parent 74a1705 commit e014582

File tree

10 files changed

+45
-20
lines changed

10 files changed

+45
-20
lines changed

BanchoSharp/BanchoSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

BanchoSharp/Messaging/SlashCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private bool IsSlashCommand() => !string.IsNullOrWhiteSpace(_prompt) &&
4949
_prompt.StartsWith("/") &&
5050
_prompt.Length > 1;
5151

52-
private string[]? GetParamsForCommand() => Command.ToLower() switch
52+
private string[]? GetParamsForCommand() => Command?.ToLower() switch
5353
{
5454
"join" => GetFirstArgOrDefault(),
5555
"part" => GetFirstArgOrDefault(),

BanchoSharp/Multiplayer/MultiplayerLobby.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ public MultiplayerLobby(IBanchoClient client, long id, string name) : base($"#mp
165165
public event Action<int>? OnLobbyTimerStarted;
166166
public event Action? OnLobbyTimerFinished;
167167
public event Action<int>? OnMatchStartTimerStarted;
168+
#pragma warning disable CS0067
168169
public event Action? OnMatchStartTimerFinished;
170+
#pragma warning restore CS0067
169171
public event Action? OnMatchAborted;
170172
public event Action? OnMatchStarted;
171173
public event Action? OnMatchFinished;
@@ -942,7 +944,7 @@ private void UpdatePlayerJoinedInSlot(string banchoResponse)
942944
private void UpdateBeatmapFromMpSettings(string banchoResponse)
943945
{
944946
int id = -1;
945-
string difficulty, artist, title;
947+
string? difficulty, artist, title;
946948
difficulty = artist = title = null;
947949

948950
string[] splits = banchoResponse.Split(" - ");

BanchoSharpExample/BanchoSharpExample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>

BanchoSharpExample/Program.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
using BanchoSharp;
22

3-
var client = new BanchoClient(new BanchoClientConfig(new IrcCredentials(Environment.GetEnvironmentVariable("IRC_USERNAME"),
4-
Environment.GetEnvironmentVariable("IRC_PASS")), LogLevel.Trace));
3+
var username = Environment.GetEnvironmentVariable("IRC_USERNAME");
4+
var password = Environment.GetEnvironmentVariable("IRC_PASS");
55

6-
client.OnAuthenticated += async () =>
6+
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
7+
{
8+
Console.WriteLine("Please set IRC_USERNAME and IRC_PASS environment variables.");
9+
return;
10+
}
11+
12+
var client = new BanchoClient(new BanchoClientConfig(new IrcCredentials(username, password), LogLevel.Trace));
13+
14+
client.OnAuthenticated += () =>
715
{
816
client.BanchoBotEvents.OnTournamentLobbyCreated += lobby => Console.WriteLine($"Tournament lobby created: {lobby.Id}");
917
};

BanchoSharpTests/BanchoSharpTests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

@@ -11,11 +11,11 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Humanizer" Version="2.14.1" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
15-
<PackageReference Include="NUnit" Version="3.13.3" />
16-
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
17-
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
18-
<PackageReference Include="coverlet.collector" Version="3.1.2" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
15+
<PackageReference Include="NUnit" Version="4.3.2" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
17+
<PackageReference Include="NUnit.Analyzers" Version="4.9.2" />
18+
<PackageReference Include="coverlet.collector" Version="6.0.4" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

BanchoSharpTests/ClientConfigTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public void Setup()
1212
_client = new BanchoClient();
1313
}
1414

15+
[TearDown]
16+
public void TearDown()
17+
{
18+
_client?.Dispose();
19+
}
20+
1521
[Test]
1622
public async Task TestSaveMessagesConfig()
1723
{

BanchoSharpTests/ClientTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class ClientTests
1212
[SetUp]
1313
public void Setup() => _client = new BanchoClient();
1414

15+
[TearDown]
16+
public void TearDown() => _client?.Dispose();
17+
1518
[Test]
1619
public async Task TestJoinChannelAsync()
1720
{

BanchoSharpTests/ExceptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ namespace BanchoSharpTests;
33
public class ExceptionTests
44
{
55
[SetUp]
6-
public async Task Setup() {}
6+
public void Setup() {}
77

88
[Test]
9-
public async Task TestNotConnectedException()
9+
public void TestNotConnectedException()
1010
{
1111
BanchoClient client = new();
1212
Assert.Multiple(() =>

BanchoSharpTests/MultiplayerTests.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public void Setup()
4646
_lobby = DefaultLobby(_client);
4747
}
4848

49+
[TearDown]
50+
public void TearDown()
51+
{
52+
_client?.Dispose();
53+
}
54+
4955
[TestCase("OWC 2021: (United States) vs. (Germany)", "https://osu.ppy.sh/mp/106275696", 106275696,
5056
Mods.HalfTime | Mods.Freemod, 1096903, "Unmei no Dark Side -Rolling Gothic mix", "Kanpyohgo", "Satellite's Lunatic",
5157
LobbyFormat.TagCoop, WinCondition.Score, TeamColor.None, true, PlayerState.NotReady,
@@ -79,13 +85,13 @@ public void TestMpSettingsUpdates(string lobbyName, string historyUrl, int match
7985
Assert.That(_lobby.HistoryUrl, Is.EqualTo(historyUrl));
8086
Assert.That(_lobby.Id, Is.EqualTo(matchId));
8187
Assert.That(_lobby.Mods, Is.EqualTo(lobbyMods));
82-
Assert.That(_lobby.CurrentBeatmap.Id, Is.EqualTo(beatmapId));
83-
Assert.That(_lobby.CurrentBeatmap.Title, Is.EqualTo(beatmapTitle));
84-
Assert.That(_lobby.CurrentBeatmap.Artist, Is.EqualTo(beatmapArtist));
85-
Assert.That(_lobby.CurrentBeatmap.Difficulty, Is.EqualTo(beatmapDifficulty));
88+
Assert.That(_lobby.CurrentBeatmap?.Id, Is.EqualTo(beatmapId));
89+
Assert.That(_lobby.CurrentBeatmap?.Title, Is.EqualTo(beatmapTitle));
90+
Assert.That(_lobby.CurrentBeatmap?.Artist, Is.EqualTo(beatmapArtist));
91+
Assert.That(_lobby.CurrentBeatmap?.Difficulty, Is.EqualTo(beatmapDifficulty));
8692
Assert.That(_lobby.Format, Is.EqualTo(format));
8793
Assert.That(_lobby.WinCondition, Is.EqualTo(winCondition));
88-
Assert.That(_lobby.Host.Equals(_lobby.Players[0]), Is.EqualTo(p1IsHost));
94+
Assert.That(_lobby.Host?.Equals(_lobby.Players[0]), Is.EqualTo(p1IsHost));
8995
Assert.That(_lobby.Players[0].Team, Is.EqualTo(p1TeamColor));
9096
Assert.That(_lobby.Players[0].State, Is.EqualTo(p1State));
9197
Assert.That(_lobby.Players[0].Id, Is.EqualTo(p1Id));

0 commit comments

Comments
 (0)