mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 14:27:45 +01:00
Fix CA1860: Avoid using 'Enumerable.Any()' extension method
This commit is contained in:
parent
fe37da1b94
commit
d060db3ca4
10 changed files with 22 additions and 22 deletions
|
|
@ -151,7 +151,7 @@ internal class GameInventory : IInternalDisposableService
|
||||||
bool isNew;
|
bool isNew;
|
||||||
lock (this.subscribersPendingChange)
|
lock (this.subscribersPendingChange)
|
||||||
{
|
{
|
||||||
isNew = this.subscribersPendingChange.Any() && !this.subscribers.Any();
|
isNew = this.subscribersPendingChange.Count != 0 && this.subscribers.Count == 0;
|
||||||
this.subscribers.Clear();
|
this.subscribers.Clear();
|
||||||
this.subscribers.AddRange(this.subscribersPendingChange);
|
this.subscribers.AddRange(this.subscribersPendingChange);
|
||||||
this.subscribersChanged = false;
|
this.subscribersChanged = false;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public sealed class SystemFontFamilyId : IFontFamilyId
|
||||||
else if (candidates.Any(x => x.Style == (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL))
|
else if (candidates.Any(x => x.Style == (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL))
|
||||||
candidates.RemoveAll(x => x.Style != (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL);
|
candidates.RemoveAll(x => x.Style != (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL);
|
||||||
|
|
||||||
if (!candidates.Any())
|
if (candidates.Count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (var i = 0; i < this.Fonts.Count; i++)
|
for (var i = 0; i < this.Fonts.Count; i++)
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ internal unsafe partial class Dx11Renderer : IImGuiRenderer
|
||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(this.device.IsEmpty(), this);
|
ObjectDisposedException.ThrowIf(this.device.IsEmpty(), this);
|
||||||
|
|
||||||
if (this.fontTextures.Any())
|
if (this.fontTextures.Count != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var io = ImGui.GetIO();
|
var io = ImGui.GetIO();
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ internal class PluginImageCache : IInternalDisposableService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
token.ThrowIfCancellationRequested();
|
token.ThrowIfCancellationRequested();
|
||||||
if (!pendingFuncs.Any())
|
if (pendingFuncs.Count == 0)
|
||||||
{
|
{
|
||||||
if (!this.downloadQueue.TryTake(out var taskTuple, -1, token))
|
if (!this.downloadQueue.TryTake(out var taskTuple, -1, token))
|
||||||
return;
|
return;
|
||||||
|
|
@ -373,7 +373,7 @@ internal class PluginImageCache : IInternalDisposableService
|
||||||
pendingFuncs = pendingFuncs.OrderBy(x => x.Item1).ToList();
|
pendingFuncs = pendingFuncs.OrderBy(x => x.Item1).ToList();
|
||||||
|
|
||||||
var item1 = pendingFuncs.Last().Item1;
|
var item1 = pendingFuncs.Last().Item1;
|
||||||
while (pendingFuncs.Any() && pendingFuncs.Last().Item1 == item1)
|
while (pendingFuncs.Count != 0 && pendingFuncs.Last().Item1 == item1)
|
||||||
{
|
{
|
||||||
token.ThrowIfCancellationRequested();
|
token.ThrowIfCancellationRequested();
|
||||||
while (runningTasks.Count >= concurrency)
|
while (runningTasks.Count >= concurrency)
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ internal class PluginStatWindow : Window
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGuiComponents.TextWithLabel("Total Average", $"{totalAverage:F4}ms", "All average update times added together");
|
ImGuiComponents.TextWithLabel("Total Average", $"{totalAverage:F4}ms", "All average update times added together");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGuiComponents.TextWithLabel("Collective Average", $"{(statsHistory.Any() ? totalAverage / statsHistory.Length : 0):F4}ms", "Average of all average update times");
|
ImGuiComponents.TextWithLabel("Collective Average", $"{(statsHistory.Length != 0 ? totalAverage / statsHistory.Length : 0):F4}ms", "Average of all average update times");
|
||||||
|
|
||||||
ImGui.InputTextWithHint(
|
ImGui.InputTextWithHint(
|
||||||
"###PluginStatWindow_FrameworkSearch"u8,
|
"###PluginStatWindow_FrameworkSearch"u8,
|
||||||
|
|
@ -230,7 +230,7 @@ internal class PluginStatWindow : Window
|
||||||
|
|
||||||
foreach (var handlerHistory in statsHistory)
|
foreach (var handlerHistory in statsHistory)
|
||||||
{
|
{
|
||||||
if (!handlerHistory.Value.Any())
|
if (handlerHistory.Value.Count == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
|
||||||
{
|
{
|
||||||
lock (this.entries)
|
lock (this.entries)
|
||||||
{
|
{
|
||||||
if (!this.entries.Any())
|
if (this.entries.Count == 0)
|
||||||
return Array.Empty<TitleScreenMenuEntry>();
|
return Array.Empty<TitleScreenMenuEntry>();
|
||||||
|
|
||||||
return this.entriesView ??= this.entries.OrderByDescending(x => x.IsInternal).ToArray();
|
return this.entriesView ??= this.entries.OrderByDescending(x => x.IsInternal).ToArray();
|
||||||
|
|
@ -59,7 +59,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
|
||||||
{
|
{
|
||||||
lock (this.entries)
|
lock (this.entries)
|
||||||
{
|
{
|
||||||
if (!this.entries.Any())
|
if (this.entries.Count == 0)
|
||||||
return Array.Empty<TitleScreenMenuEntry>();
|
return Array.Empty<TitleScreenMenuEntry>();
|
||||||
|
|
||||||
return this.entriesView ??= this.entries.OrderByDescending(x => x.IsInternal).ToArray();
|
return this.entriesView ??= this.entries.OrderByDescending(x => x.IsInternal).ToArray();
|
||||||
|
|
@ -81,7 +81,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
|
||||||
lock (this.entries)
|
lock (this.entries)
|
||||||
{
|
{
|
||||||
var entriesOfAssembly = this.entries.Where(x => x.CallingAssembly == Assembly.GetCallingAssembly()).ToList();
|
var entriesOfAssembly = this.entries.Where(x => x.CallingAssembly == Assembly.GetCallingAssembly()).ToList();
|
||||||
var priority = entriesOfAssembly.Any()
|
var priority = entriesOfAssembly.Count != 0
|
||||||
? unchecked(entriesOfAssembly.Select(x => x.Priority).Max() + 1)
|
? unchecked(entriesOfAssembly.Select(x => x.Priority).Max() + 1)
|
||||||
: 0;
|
: 0;
|
||||||
entry = new(Assembly.GetCallingAssembly(), priority, text, texture, onTriggered);
|
entry = new(Assembly.GetCallingAssembly(), priority, text, texture, onTriggered);
|
||||||
|
|
@ -191,7 +191,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
|
||||||
lock (this.entries)
|
lock (this.entries)
|
||||||
{
|
{
|
||||||
var entriesOfAssembly = this.entries.Where(x => x.CallingAssembly == null).ToList();
|
var entriesOfAssembly = this.entries.Where(x => x.CallingAssembly == null).ToList();
|
||||||
var priority = entriesOfAssembly.Any()
|
var priority = entriesOfAssembly.Count != 0
|
||||||
? unchecked(entriesOfAssembly.Select(x => x.Priority).Max() + 1)
|
? unchecked(entriesOfAssembly.Select(x => x.Priority).Max() + 1)
|
||||||
: 0;
|
: 0;
|
||||||
entry = new(null, priority, text, texture, onTriggered, showConditionKeys)
|
entry = new(null, priority, text, texture, onTriggered, showConditionKeys)
|
||||||
|
|
|
||||||
|
|
@ -376,7 +376,7 @@ internal class AutoUpdateManager : IServiceType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotifyUpdatesAreAvailable(ICollection<AvailablePluginUpdate> updatablePlugins)
|
private void NotifyUpdatesAreAvailable(List<AvailablePluginUpdate> updatablePlugins)
|
||||||
{
|
{
|
||||||
if (updatablePlugins.Count == 0)
|
if (updatablePlugins.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ internal class ManagedLoadContext : AssemblyLoadContext
|
||||||
private readonly IReadOnlyDictionary<string, ManagedLibrary> managedAssemblies;
|
private readonly IReadOnlyDictionary<string, ManagedLibrary> managedAssemblies;
|
||||||
private readonly IReadOnlyDictionary<string, NativeLibrary> nativeLibraries;
|
private readonly IReadOnlyDictionary<string, NativeLibrary> nativeLibraries;
|
||||||
private readonly IReadOnlyCollection<string> privateAssemblies;
|
private readonly IReadOnlyCollection<string> privateAssemblies;
|
||||||
private readonly ICollection<string> defaultAssemblies;
|
private readonly List<string> defaultAssemblies;
|
||||||
private readonly IReadOnlyCollection<string> additionalProbingPaths;
|
private readonly IReadOnlyCollection<string> additionalProbingPaths;
|
||||||
private readonly bool preferDefaultLoadContext;
|
private readonly bool preferDefaultLoadContext;
|
||||||
private readonly string[] resourceRoots;
|
private readonly string[] resourceRoots;
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ internal static class ServiceManager
|
||||||
servicesToLoad.UnionWith(earlyLoadingServices);
|
servicesToLoad.UnionWith(earlyLoadingServices);
|
||||||
servicesToLoad.UnionWith(blockingEarlyLoadingServices);
|
servicesToLoad.UnionWith(blockingEarlyLoadingServices);
|
||||||
|
|
||||||
while (servicesToLoad.Any())
|
while (servicesToLoad.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var serviceType in servicesToLoad)
|
foreach (var serviceType in servicesToLoad)
|
||||||
{
|
{
|
||||||
|
|
@ -383,23 +383,23 @@ internal static class ServiceManager
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tasks.Any())
|
if (tasks.Count == 0)
|
||||||
{
|
{
|
||||||
// No more services we can start loading for now.
|
// No more services we can start loading for now.
|
||||||
// Either we're waiting for provided services, or there's a dependency cycle.
|
// Either we're waiting for provided services, or there's a dependency cycle.
|
||||||
providedServices.RemoveWhere(x => getAsyncTaskMap[x].IsCompleted);
|
providedServices.RemoveWhere(x => getAsyncTaskMap[x].IsCompleted);
|
||||||
if (providedServices.Any())
|
if (providedServices.Count != 0)
|
||||||
await Task.WhenAny(providedServices.Select(x => getAsyncTaskMap[x]));
|
await Task.WhenAny(providedServices.Select(x => getAsyncTaskMap[x]));
|
||||||
else
|
else
|
||||||
throw new InvalidOperationException("Unresolvable dependency cycle detected");
|
throw new InvalidOperationException("Unresolvable dependency cycle detected");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servicesToLoad.Any())
|
if (servicesToLoad.Count != 0)
|
||||||
{
|
{
|
||||||
await Task.WhenAny(tasks);
|
await Task.WhenAny(tasks);
|
||||||
var faultedTasks = tasks.Where(x => x.IsFaulted).Select(x => (Exception)x.Exception!).ToArray();
|
var faultedTasks = tasks.Where(x => x.IsFaulted).Select(x => (Exception)x.Exception!).ToArray();
|
||||||
if (faultedTasks.Any())
|
if (faultedTasks.Length != 0)
|
||||||
throw new AggregateException(faultedTasks);
|
throw new AggregateException(faultedTasks);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -426,7 +426,7 @@ internal static class ServiceManager
|
||||||
|
|
||||||
await loadingDialog.HideAndJoin();
|
await loadingDialog.HideAndJoin();
|
||||||
|
|
||||||
while (tasks.Any())
|
while (tasks.Count != 0)
|
||||||
{
|
{
|
||||||
await Task.WhenAny(tasks);
|
await Task.WhenAny(tasks);
|
||||||
tasks.RemoveAll(x => x.IsCompleted);
|
tasks.RemoveAll(x => x.IsCompleted);
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ internal static class Service<T> where T : IServiceType
|
||||||
is not ServiceManager.ServiceKind.BlockingEarlyLoadedService
|
is not ServiceManager.ServiceKind.BlockingEarlyLoadedService
|
||||||
and not ServiceManager.ServiceKind.ProvidedService)
|
and not ServiceManager.ServiceKind.ProvidedService)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
if (offenders.Any())
|
if (offenders.Length != 0)
|
||||||
{
|
{
|
||||||
const string bels = nameof(ServiceManager.BlockingEarlyLoadedServiceAttribute);
|
const string bels = nameof(ServiceManager.BlockingEarlyLoadedServiceAttribute);
|
||||||
const string ps = nameof(ServiceManager.ProvidedServiceAttribute);
|
const string ps = nameof(ServiceManager.ProvidedServiceAttribute);
|
||||||
|
|
@ -351,7 +351,7 @@ internal static class Service<T> where T : IServiceType
|
||||||
BindingFlags.CreateInstance | BindingFlags.OptionalParamBinding;
|
BindingFlags.CreateInstance | BindingFlags.OptionalParamBinding;
|
||||||
return typeof(T)
|
return typeof(T)
|
||||||
.GetConstructors(ctorBindingFlags)
|
.GetConstructors(ctorBindingFlags)
|
||||||
.SingleOrDefault(x => x.GetCustomAttributes(typeof(ServiceManager.ServiceConstructor), true).Any());
|
.SingleOrDefault(x => x.GetCustomAttributes(typeof(ServiceManager.ServiceConstructor), true).Length != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<T> ConstructObject(IReadOnlyCollection<object> additionalProvidedTypedObjects)
|
private static async Task<T> ConstructObject(IReadOnlyCollection<object> additionalProvidedTypedObjects)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue