- More code cleanup and codestyle updates

- Fixed some possible nullref exceptions
- Methods signatures now have up to 3 parameters before breakaing down each parameter in a separate line
- Method invocations have the same rule, except the first parameter will be in the same line as the invocation to prevent some ugliness when passing lambas as arguments
- Applied many more codestyles
- Extensions folder fully reformatted
This commit is contained in:
Kwoth
2021-12-26 17:28:39 +01:00
parent b85ba177cd
commit d5fd6aae8e
217 changed files with 1017 additions and 1494 deletions

View File

@@ -44,10 +44,8 @@ public sealed class AyuVoiceStateService : INService
}
private Task InvokeSendVoiceStateUpdateAsync(ulong guildId, ulong? channelId = null, bool isDeafened = false, bool isMuted = false)
{
// return _voiceStateUpdate(guildId, channelId, isDeafened, isMuted);
return (Task) _sendVoiceStateUpdateMethodInfo.Invoke(_dnetApiClient, new object[] {guildId, channelId, isMuted, isDeafened, null});
}
=> (Task) _sendVoiceStateUpdateMethodInfo.Invoke(_dnetApiClient, new object[] {guildId, channelId, isMuted, isDeafened, null});
private Task SendLeaveVoiceChannelInternalAsync(ulong guildId)
=> InvokeSendVoiceStateUpdateAsync(guildId);

View File

@@ -407,7 +407,7 @@ public sealed class MusicService : IMusicService
public async Task SetVolumeAsync(ulong guildId, int value)
{
if (value < 0 || value > 100)
if (value is < 0 or > 100)
throw new ArgumentOutOfRangeException(nameof(value));
await ModifySettingsInternalAsync(guildId, (settings, newValue) =>
@@ -438,12 +438,10 @@ public sealed class MusicService : IMusicService
}
public Task SetMusicQualityAsync(ulong guildId, QualityPreset preset)
{
return ModifySettingsInternalAsync(guildId, (settings, _) =>
=> ModifySettingsInternalAsync(guildId, (settings, _) =>
{
settings.QualityPreset = preset;
}, preset);
}
#endregion
}

View File

@@ -16,9 +16,7 @@ public sealed partial class YtLoader
};
public YtLoader(IHttpClientFactory httpFactory)
{
_httpFactory = httpFactory;
}
=> _httpFactory = httpFactory;
// public async Task<TrackInfo> LoadTrackByIdAsync(string videoId)
// {
@@ -115,13 +113,13 @@ public sealed partial class YtLoader
private Memory<byte> GetScriptResponseSpan(byte[] response)
{
var responseSpan = response.AsSpan().Slice(140_000);
var responseSpan = response.AsSpan()[140_000..];
var startIndex = responseSpan.IndexOf(YT_RESULT_INITIAL_DATA);
if (startIndex == -1)
return null; // todo future try selecting html
startIndex += YT_RESULT_INITIAL_DATA.Length;
var endIndex = 140_000 + startIndex + responseSpan.Slice(startIndex + 20_000).IndexOf(YT_RESULT_JSON_END) + 20_000;
var endIndex = 140_000 + startIndex + responseSpan[(startIndex + 20_000)..].IndexOf(YT_RESULT_JSON_END) + 20_000;
startIndex += 140_000;
return response.AsMemory(
startIndex,