Skip to content

Commit 808a7db

Browse files
committed
Updated dependencies
1 parent 518e887 commit 808a7db

File tree

11 files changed

+72
-56
lines changed

11 files changed

+72
-56
lines changed

TS3ABotUnitTests/BotCommandTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void XCommandSystemTest()
188188
public void XCommandSystemTest2()
189189
{
190190
var execInfo = Utils.GetExecInfo("exact");
191-
string? CallCommand(string command) => CommandManager.Execute(execInfo, command).GetAwaiter().GetResult().AsString();
191+
string? CallCommand(string command) => CommandManager.Execute(execInfo!, command).GetAwaiter().GetResult().AsString();
192192
var group = execInfo.GetModule<CommandManager>()!.RootGroup;
193193

194194
var o1 = new OverloadedFunctionCommand();

TS3AudioBot/Config/ConfigPart.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private IEnumerable<ConfigPart> ProcessIdentifier(ReadOnlyMemory<char> pathM)
7676
{
7777
case '*':
7878
{
79-
var rest = pathM.Slice(1);
79+
var rest = pathM[1..];
8080
if (rest.IsEmpty)
8181
return GetAllSubItems();
8282

@@ -106,12 +106,12 @@ private IEnumerable<ConfigPart> ProcessIdentifier(ReadOnlyMemory<char> pathM)
106106
if (path[i] == '*')
107107
throw new ArgumentException("Invalid wildcard position", nameof(pathM));
108108

109-
var currentSub = path.Slice(i);
109+
var currentSub = path[i..];
110110
if (!IsIdentifier(currentSub)) // if (!IsName)
111111
{
112112
cont = true;
113-
subItemName = path.Slice(0, i);
114-
rest = pathM.Slice(i);
113+
subItemName = path[..i];
114+
rest = pathM[i..];
115115
break;
116116
}
117117
}
@@ -144,7 +144,7 @@ private IEnumerable<ConfigPart> ProcessArray(ReadOnlyMemory<char> pathM)
144144
{
145145
if (i == 0)
146146
throw new ArgumentException("Empty array indexer", nameof(pathM));
147-
var indexer = path.Slice(1, i - 1);
147+
var indexer = path[1..i];
148148
var rest = pathM.Slice(i + 1);
149149
bool cont = rest.Length > 0;
150150

@@ -192,7 +192,7 @@ private IEnumerable<ConfigPart> ProcessDot(ReadOnlyMemory<char> pathM)
192192
if (!IsDot(path))
193193
throw new ArgumentException("Expected dot", nameof(pathM));
194194

195-
var rest = pathM.Slice(1);
195+
var rest = pathM[1..];
196196
if (!IsIdentifier(rest.Span))
197197
throw new ArgumentException("Expected identifier after dot", nameof(pathM));
198198

TS3AudioBot/Helper/ImageUtil.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static async Task<ImageHolder> ResizeImageSave(Stream imgStream, int resi
2929
try
3030
{
3131
using var limitStream = new LimitStream(imgStream, Limits.MaxImageStreamSize);
32-
return await Task.Run(() => ResizeImage(limitStream, resizeMaxWidth));
32+
return await ResizeImage(limitStream, resizeMaxWidth);
3333
}
3434
catch (NotSupportedException)
3535
{
@@ -43,9 +43,9 @@ public static async Task<ImageHolder> ResizeImageSave(Stream imgStream, int resi
4343
}
4444
}
4545

46-
private static ImageHolder ResizeImage(Stream imgStream, int resizeMaxWidth = ResizeMaxWidthDefault)
46+
private static async Task<ImageHolder> ResizeImage(Stream imgStream, int resizeMaxWidth = ResizeMaxWidthDefault)
4747
{
48-
using var img = Image.Load(imgStream);
48+
using var img = await Image.LoadAsync(imgStream);
4949
if (img.Width > Limits.MaxImageDimension || img.Height > Limits.MaxImageDimension
5050
|| img.Width == 0 || img.Height == 0)
5151
throw Error.LocalStr("Dropping image because too large"); // TODO

TS3AudioBot/Helper/TomlTools.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static bool TryGetValueArray<T>(this TomlObject tomlObj, [NotNullWhen(tru
3030
value = new T[tomlArray.Length];
3131
for (int i = 0; i < tomlArray.Length; i++)
3232
{
33-
if (!tomlArray.Items[i].TryGetValue(out value[i]))
33+
if (!tomlArray.Items[i].TryGetValue(out value[i]!))
3434
{
3535
value = null;
3636
return false;
@@ -246,7 +246,7 @@ private static IEnumerable<TomlObject> ProcessIdentifier(TomlObject obj, ReadOnl
246246
{
247247
case '*':
248248
{
249-
var rest = pathM.Slice(1);
249+
var rest = pathM[1..];
250250
if (rest.IsEmpty)
251251
return obj.GetAllSubItems();
252252

@@ -276,12 +276,12 @@ private static IEnumerable<TomlObject> ProcessIdentifier(TomlObject obj, ReadOnl
276276
if (path[i] == '*')
277277
throw new ArgumentException("Invalid wildcard position", nameof(pathM));
278278

279-
var currentSub = path.Slice(i);
279+
var currentSub = path[i..];
280280
if (!IsIdentifier(currentSub)) // if (!IsName)
281281
{
282282
cont = true;
283-
subItemName = path.Slice(0, i);
284-
rest = pathM.Slice(i);
283+
subItemName = path[..i];
284+
rest = pathM[i..];
285285
break;
286286
}
287287
}
@@ -314,7 +314,7 @@ private static IEnumerable<TomlObject> ProcessArray(TomlObject obj, ReadOnlyMemo
314314
{
315315
if (i == 0)
316316
throw new ArgumentException("Empty array indexer", nameof(pathM));
317-
var indexer = path.Slice(1, i - 1);
317+
var indexer = path[1..i];
318318
var rest = pathM.Slice(i + 1);
319319
bool cont = rest.Length > 0;
320320

@@ -362,7 +362,7 @@ private static IEnumerable<TomlObject> ProcessDot(TomlObject obj, ReadOnlyMemory
362362
if (!IsDot(path))
363363
throw new ArgumentException("Expected dot", nameof(pathM));
364364

365-
var rest = pathM.Slice(1);
365+
var rest = pathM[1..];
366366
if (!IsIdentifier(rest.Span))
367367
throw new ArgumentException("Expected identifier after dot", nameof(pathM));
368368

TS3AudioBot/Playlists/Parser/JspfContent.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ public override XspfMeta ReadJson(JsonReader reader, Type objectType, XspfMeta?
9393
return new XspfMeta(key, value);
9494
}
9595

96-
public override void WriteJson(JsonWriter writer, XspfMeta value, JsonSerializer serializer)
96+
public override void WriteJson(JsonWriter writer, XspfMeta? value, JsonSerializer serializer)
9797
{
98+
if (value is null) throw new ArgumentNullException(nameof(value));
9899
writer.WriteStartObject();
99100
writer.WritePropertyName(value.Key);
100101
writer.WriteValue(value.Value);

TS3AudioBot/TS3AudioBot.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@
3535
</PropertyGroup>
3636

3737
<ItemGroup>
38-
<PackageReference Include="CliWrap" Version="3.0.2" />
38+
<PackageReference Include="CliWrap" Version="3.1.0" />
3939
<PackageReference Include="CommandLineParser" Version="2.8.0" />
40-
<PackageReference Include="NLog" Version="4.7.0" />
40+
<PackageReference Include="NLog" Version="4.7.2" />
4141
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
4242
<PackageReference Include="LiteDB" Version="4.1.4" />
4343
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
4444
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
4545
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
46-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.5.0">
46+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.6.0">
4747
<ExcludeAssets>analyzers</ExcludeAssets>
4848
</PackageReference>
4949
<PackageReference Include="Nett" Version="0.15.0" />
5050
<PackageReference Include="PlaylistsNET" Version="1.0.6" />
51-
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0001" />
51+
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0003" />
5252
</ItemGroup>
5353

5454
<ItemGroup>

TSLib/Commands/TsCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public TsCommand ExpectsResponse(bool expects)
7676

7777
/// <summary>Builds this command to the query-like command.</summary>
7878
/// <returns>The formatted query-like command.</returns>
79-
public override string ToString() => raw ?? (raw = BuildToString(Command, GetParameter()));
79+
public override string ToString() => raw ??= BuildToString(Command, GetParameter());
8080

8181
/// <summary>Builds the command from its parameters and returns the query-like command.</summary>
8282
/// <param name="command">The command name.</param>

TSLib/Full/NetworkStats.cs

+44-29
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,26 @@ private static PacketKind TypeToKind(PacketType type)
9090
}
9191
}
9292

93-
private static long[] GetWithin(Queue<PacketData> queue, TimeSpan time)
93+
private static void GetWithin(Queue<PacketData> queue, TimeSpan time, out DataCatergory data)
9494
{
9595
var now = Tools.Now;
96-
var bandwidth = new long[3];
96+
var nowThresh = now - time;
97+
data = new DataCatergory();
9798
foreach (var pack in queue.Reverse())
98-
if (now - pack.SendPoint <= time)
99-
bandwidth[(int)pack.Kind] += pack.Size;
100-
else
101-
break;
102-
for (int i = 0; i < 3; i++)
103-
bandwidth[i] = (long)(bandwidth[i] / time.TotalSeconds);
104-
return bandwidth;
99+
if (nowThresh <= pack.SendPoint)
100+
{
101+
switch (pack.Kind)
102+
{
103+
case PacketKind.Speech: data.Speech += pack.Size; break;
104+
case PacketKind.Keepalive: data.Keepalive += pack.Size; break;
105+
case PacketKind.Control: data.Control += pack.Size; break;
106+
default: throw Tools.UnhandledDefault(pack.Kind);
107+
}
108+
}
109+
else { break; }
110+
data.Speech = (long)(data.Speech / time.TotalSeconds);
111+
data.Keepalive = (long)(data.Keepalive / time.TotalSeconds);
112+
data.Control = (long)(data.Control / time.TotalSeconds);
105113
}
106114

107115
private static void DropOver(Queue<PacketData> queue, TimeSpan time)
@@ -113,18 +121,18 @@ private static void DropOver(Queue<PacketData> queue, TimeSpan time)
113121

114122
public TsCommand GenerateStatusAnswer()
115123
{
116-
long[] lastSecondIn;
117-
long[] lastSecondOut;
118-
long[] lastMinuteIn;
119-
long[] lastMinuteOut;
124+
DataCatergory lastSecondIn;
125+
DataCatergory lastSecondOut;
126+
DataCatergory lastMinuteIn;
127+
DataCatergory lastMinuteOut;
120128
double lastPing;
121129
double deviationPing;
122130
lock (queueLock)
123131
{
124-
lastSecondIn = GetWithin(inBytesTime, TimeSecond);
125-
lastSecondOut = GetWithin(outBytesTime, TimeSecond);
126-
lastMinuteIn = GetWithin(inBytesTime, TimeMinute);
127-
lastMinuteOut = GetWithin(outBytesTime, TimeMinute);
132+
GetWithin(inBytesTime, TimeSecond, out lastSecondIn);
133+
GetWithin(outBytesTime, TimeSecond, out lastSecondOut);
134+
GetWithin(inBytesTime, TimeMinute, out lastMinuteIn);
135+
GetWithin(outBytesTime, TimeMinute, out lastMinuteOut);
128136
if (pingTimes.Count > 0)
129137
{
130138
lastPing = pingTimes.Last().TotalMilliseconds;
@@ -155,18 +163,18 @@ public TsCommand GenerateStatusAnswer()
155163
{ "connection_server2client_packetloss_keepalive", 1.0000f },
156164
{ "connection_server2client_packetloss_control", 0.5000f },
157165
{ "connection_server2client_packetloss_total", 0.0000f },
158-
{ "connection_bandwidth_sent_last_second_speech", lastSecondOut[(int)PacketKind.Speech] },
159-
{ "connection_bandwidth_sent_last_second_keepalive", lastSecondOut[(int)PacketKind.Keepalive] },
160-
{ "connection_bandwidth_sent_last_second_control", lastSecondOut[(int)PacketKind.Control] },
161-
{ "connection_bandwidth_sent_last_minute_speech", lastMinuteOut[(int)PacketKind.Speech] },
162-
{ "connection_bandwidth_sent_last_minute_keepalive", lastMinuteOut[(int)PacketKind.Keepalive] },
163-
{ "connection_bandwidth_sent_last_minute_control", lastMinuteOut[(int)PacketKind.Control] },
164-
{ "connection_bandwidth_received_last_second_speech", lastSecondIn[(int)PacketKind.Speech] },
165-
{ "connection_bandwidth_received_last_second_keepalive", lastSecondIn[(int)PacketKind.Keepalive] },
166-
{ "connection_bandwidth_received_last_second_control", lastSecondIn[(int)PacketKind.Control] },
167-
{ "connection_bandwidth_received_last_minute_speech", lastMinuteIn[(int)PacketKind.Speech] },
168-
{ "connection_bandwidth_received_last_minute_keepalive", lastMinuteIn[(int)PacketKind.Keepalive] },
169-
{ "connection_bandwidth_received_last_minute_control", lastMinuteIn[(int)PacketKind.Control] },
166+
{ "connection_bandwidth_sent_last_second_speech", lastSecondOut.Speech },
167+
{ "connection_bandwidth_sent_last_second_keepalive", lastSecondOut.Keepalive },
168+
{ "connection_bandwidth_sent_last_second_control", lastSecondOut.Control },
169+
{ "connection_bandwidth_sent_last_minute_speech", lastMinuteOut.Speech },
170+
{ "connection_bandwidth_sent_last_minute_keepalive", lastMinuteOut.Keepalive },
171+
{ "connection_bandwidth_sent_last_minute_control", lastMinuteOut.Control },
172+
{ "connection_bandwidth_received_last_second_speech", lastSecondIn.Speech },
173+
{ "connection_bandwidth_received_last_second_keepalive", lastSecondIn.Keepalive },
174+
{ "connection_bandwidth_received_last_second_control", lastSecondIn.Control },
175+
{ "connection_bandwidth_received_last_minute_speech", lastMinuteIn.Speech },
176+
{ "connection_bandwidth_received_last_minute_keepalive", lastMinuteIn.Keepalive },
177+
{ "connection_bandwidth_received_last_minute_control", lastMinuteIn.Control },
170178
};
171179
}
172180

@@ -214,5 +222,12 @@ private readonly struct PacketData
214222

215223
public PacketData(ushort size, DateTime sendPoint, PacketKind kind) { Size = size; SendPoint = sendPoint; Kind = kind; }
216224
}
225+
226+
struct DataCatergory
227+
{
228+
public long Speech { get; set; }
229+
public long Keepalive { get; set; }
230+
public long Control { get; set; }
231+
}
217232
}
218233
}

TSLib/Full/RingQueue.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private ItemSetStatus IsSetIndex(int index)
122122
return StateGet(index) ? ItemSetStatus.InWindowSet : ItemSetStatus.InWindowNotSet;
123123
}
124124

125-
public bool TryDequeue(out T value)
125+
public bool TryDequeue([MaybeNullWhen(false)] out T value)
126126
{
127127
if (!TryPeekStart(0, out value)) return false;
128128
BufferPop();

TSLib/TSLib.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</PropertyGroup>
3434

3535
<ItemGroup>
36-
<PackageReference Include="NLog" Version="4.7.0" />
36+
<PackageReference Include="NLog" Version="4.7.2" />
3737
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
3838
<PackageReference Include="Heijden.Dns.Portable" Version="2.0.19" />
3939
<PackageReference Include="Nullable" Version="1.2.1">
@@ -42,7 +42,7 @@
4242
</PackageReference>
4343
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
4444
<PackageReference Include="Splamy.Ed25519.Toolkit" Version="1.0.3" />
45-
<PackageReference Include="System.IO.Pipelines" Version="4.7.1" />
45+
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" />
4646
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Memory" Version="4.5.3" />
4747
<PackageReference Include="System.Memory" Version="4.5.4" />
4848
</ItemGroup>

TSLib/dnc2_compat/Range.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public int GetOffset(int length)
123123

124124
/// <summary>Indicates whether the current Index object is equal to another object of the same type.</summary>
125125
/// <param name="value">An object to compare with this object</param>
126-
public override bool Equals(object? value) => value is Index && _value == ((Index)value)._value;
126+
public override bool Equals(object? value) => value is Index index && _value == index._value;
127127

128128
/// <summary>Indicates whether the current Index object is equal to another Index object.</summary>
129129
/// <param name="other">An object to compare with this object</param>

0 commit comments

Comments
 (0)