diff --git a/mixtape.Raven/Extensions/RavenQueryableExtensions.cs b/mixtape.Raven/Extensions/RavenQueryableExtensions.cs index ba4edb20..5d271bc3 100644 --- a/mixtape.Raven/Extensions/RavenQueryableExtensions.cs +++ b/mixtape.Raven/Extensions/RavenQueryableExtensions.cs @@ -92,7 +92,7 @@ public static class RavenQueryableExtensions searchTerms = searchTerms.Trim(); - string[] searchParts = searchTerms.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => + string[] searchParts = searchTerms.Split([" "], StringSplitOptions.RemoveEmptyEntries).Select(x => { if (suffix != null) { @@ -107,7 +107,7 @@ public static class RavenQueryableExtensions if (searchTerms.StartsWith('"') && searchTerms.EndsWith('"')) { - searchParts = new[] { searchTerms }; + searchParts = [searchTerms]; } return source.Search(fieldSelector, searchParts, @operator: @operator); diff --git a/mixtape.Raven/Indexes/MixtapeTreeHierachyIndex.cs b/mixtape.Raven/Indexes/MixtapeTreeHierachyIndex.cs index 72908e64..652e4c3c 100644 --- a/mixtape.Raven/Indexes/MixtapeTreeHierachyIndex.cs +++ b/mixtape.Raven/Indexes/MixtapeTreeHierachyIndex.cs @@ -4,7 +4,7 @@ namespace Mixtape.Raven; public class MixtapeTreeHierarchyIndexResult : MixtapeIdEntity, ISupportsDbConventions { - public List Path { get; set; } = new List(); + public List Path { get; set; } = []; } public abstract class MixtapeTreeHierarchyIndex : MixtapeIndex where T : MixtapeIdEntity, ISupportsTrees diff --git a/mixtape.Raven/MixtapeRavenModule.cs b/mixtape.Raven/MixtapeRavenModule.cs index a2c804f2..b548ab79 100644 --- a/mixtape.Raven/MixtapeRavenModule.cs +++ b/mixtape.Raven/MixtapeRavenModule.cs @@ -50,7 +50,7 @@ internal class MixtapeRavenModule : MixtapeModule IDocumentStore store = new DocumentStore() { Database = ravenOptions.Database, - Urls = new string[1] { ravenOptions.Url }, + Urls = [ravenOptions.Url], Conventions = { AggressiveCache = diff --git a/mixtape.Raven/Operations/RavenOperations.Read.cs b/mixtape.Raven/Operations/RavenOperations.Read.cs index 258ed14b..8f08ae27 100644 --- a/mixtape.Raven/Operations/RavenOperations.Read.cs +++ b/mixtape.Raven/Operations/RavenOperations.Read.cs @@ -46,7 +46,7 @@ public partial class RavenOperations : IRavenOperations ids = ids.Distinct().ToArray(); Dictionary models = await Session.LoadAsync(ids); - List result = new(); + List result = []; foreach (string id in ids) { @@ -148,7 +148,7 @@ public partial class RavenOperations : IRavenOperations /// public virtual async Task> LoadAll() where T : MixtapeIdEntity, new() { - List items = new(); + List items = []; await foreach (T item in Stream(null)) { diff --git a/mixtape.Raven/Operations/RavenOperations.Tree.cs b/mixtape.Raven/Operations/RavenOperations.Tree.cs index 2e86d9a2..10352cdf 100644 --- a/mixtape.Raven/Operations/RavenOperations.Tree.cs +++ b/mixtape.Raven/Operations/RavenOperations.Tree.cs @@ -25,10 +25,10 @@ public partial class RavenOperations : IRavenOperations if (result == null) { - return Array.Empty(); + return []; } - List ids = result.Path ?? new(); + List ids = result.Path ?? []; ids.Add(id); return (await Session.LoadAsync(ids)).Select(x => x.Value).ToArray(); @@ -162,7 +162,7 @@ public partial class RavenOperations : IRavenOperations /// async Task> GetDescendantsAndSelf(T model) where T : MixtapeIdEntity, ISupportsTrees, new() { - List items = new() { model }; + List items = [model]; async Task AddChildren(T parent) { diff --git a/mixtape.Raven/RavenDocumentConventionsBuilder.cs b/mixtape.Raven/RavenDocumentConventionsBuilder.cs index 32afe721..3006deef 100644 --- a/mixtape.Raven/RavenDocumentConventionsBuilder.cs +++ b/mixtape.Raven/RavenDocumentConventionsBuilder.cs @@ -8,7 +8,7 @@ namespace Mixtape.Raven; public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder { - protected HashSet PolymorphTypes { get; } = new(); + protected HashSet PolymorphTypes { get; } = []; protected Type AcceptsMixtapeConventionsType { get; set; } = typeof(ISupportsDbConventions); diff --git a/mixtape.Raven/RavenOptions.cs b/mixtape.Raven/RavenOptions.cs index 7b4555c3..6da00a24 100644 --- a/mixtape.Raven/RavenOptions.cs +++ b/mixtape.Raven/RavenOptions.cs @@ -32,7 +32,7 @@ public class RavenIndexesOptions : List } - public RavenIndexModifiersOptions Modifiers { get; private set; } = new(); + public RavenIndexModifiersOptions Modifiers { get; private set; } = []; public void Add() where T : IMixtapeIndexDefinition, new() { diff --git a/mixtape/Assemblies/AssemblyDiscovery.cs b/mixtape/Assemblies/AssemblyDiscovery.cs index 03746d93..f3d78b0f 100644 --- a/mixtape/Assemblies/AssemblyDiscovery.cs +++ b/mixtape/Assemblies/AssemblyDiscovery.cs @@ -26,7 +26,7 @@ public class AssemblyDiscovery : IAssemblyDiscovery /// public void Execute(IEnumerable rules) { - List assemblies = new List(); + List assemblies = []; DependencyContext dependencyContext = DependencyContext.Load(Context.EntryAssembly); if (dependencyContext == null) diff --git a/mixtape/Communication/Messages/MessageAggregator.cs b/mixtape/Communication/Messages/MessageAggregator.cs index 94518ab1..37df09e8 100644 --- a/mixtape/Communication/Messages/MessageAggregator.cs +++ b/mixtape/Communication/Messages/MessageAggregator.cs @@ -5,7 +5,7 @@ namespace Mixtape.Communication; public class MessageAggregator : IMessageAggregator { - readonly ConcurrentBag Subscription = new ConcurrentBag(); + readonly ConcurrentBag Subscription = []; readonly IServiceProvider ServiceProvider; diff --git a/mixtape/Extensions/CharExtensions.cs b/mixtape/Extensions/CharExtensions.cs index b0a8ed96..cc80c837 100644 --- a/mixtape/Extensions/CharExtensions.cs +++ b/mixtape/Extensions/CharExtensions.cs @@ -4,20 +4,20 @@ public static class CharExtensions { private static Dictionary accents { get; } = new Dictionary() { - { 'ä', new char[2] { 'a', 'e' } }, - { 'á', new char[1] { 'a' } }, - { 'à', new char[1] { 'a' } }, - { 'ó', new char[1] { 'o' } }, - { 'ò', new char[1] { 'o' } }, - { 'é', new char[1] { 'e' } }, - { 'è', new char[1] { 'e' } }, - { 'ú', new char[1] { 'u' } }, - { 'ù', new char[1] { 'u' } }, - { 'í', new char[1] { 'i' } }, - { 'ì', new char[1] { 'i' } }, - { 'ö', new char[2] { 'o', 'e' } }, - { 'ü', new char[2] { 'u', 'e' } }, - { 'ß', new char[2] { 's', 's' } }, + { 'ä', ['a', 'e'] }, + { 'á', ['a'] }, + { 'à', ['a'] }, + { 'ó', ['o'] }, + { 'ò', ['o'] }, + { 'é', ['e'] }, + { 'è', ['e'] }, + { 'ú', ['u'] }, + { 'ù', ['u'] }, + { 'í', ['i'] }, + { 'ì', ['i'] }, + { 'ö', ['o', 'e'] }, + { 'ü', ['u', 'e'] }, + { 'ß', ['s', 's'] }, //{ '&', new char[1] { '+' } } }; diff --git a/mixtape/Extensions/NumberExtensions.cs b/mixtape/Extensions/NumberExtensions.cs index b33f16ac..9194a953 100644 --- a/mixtape/Extensions/NumberExtensions.cs +++ b/mixtape/Extensions/NumberExtensions.cs @@ -4,9 +4,9 @@ public static class NumberExtensions { static Dictionary FileSizeUnits = new() { - { FileSizeNotation.SI, new string[] { "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" } }, - { FileSizeNotation.IEC, new string[] { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" } }, - { FileSizeNotation.JEDEC, new string[] { "B", "KB", "MB", "GB" } } + { FileSizeNotation.SI, ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] }, + { FileSizeNotation.IEC, ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] }, + { FileSizeNotation.JEDEC, ["B", "KB", "MB", "GB"] } }; public static int Limit(this int input, int min, int max) diff --git a/mixtape/Identity/Models/MixtapeIdentityRole.cs b/mixtape/Identity/Models/MixtapeIdentityRole.cs index 69680f69..8b8edc60 100644 --- a/mixtape/Identity/Models/MixtapeIdentityRole.cs +++ b/mixtape/Identity/Models/MixtapeIdentityRole.cs @@ -5,5 +5,5 @@ public abstract class MixtapeIdentityRole : MixtapeEntity /// /// The role's claims, for use in claims-based authentication. /// - public List Claims { get; set; } = new(); + public List Claims { get; set; } = []; } diff --git a/mixtape/Identity/UserManagerExtensions.cs b/mixtape/Identity/UserManagerExtensions.cs index 2f2bef5d..aa567aea 100644 --- a/mixtape/Identity/UserManagerExtensions.cs +++ b/mixtape/Identity/UserManagerExtensions.cs @@ -78,7 +78,7 @@ public static class UserManagerExtensions return Result.Success(recoveryCodes.ToArray()); } - return Result.Success(Array.Empty()); + return Result.Success([]); } diff --git a/mixtape/Media/ImageSharp/Processors/BlurWebProcessor.cs b/mixtape/Media/ImageSharp/Processors/BlurWebProcessor.cs index 730ad857..feece5c0 100644 --- a/mixtape/Media/ImageSharp/Processors/BlurWebProcessor.cs +++ b/mixtape/Media/ImageSharp/Processors/BlurWebProcessor.cs @@ -17,7 +17,7 @@ public class BlurWebProcessor : IImageWebProcessor /// /// The reusable collection of commands. /// - private static readonly IEnumerable BlurCommands = new[] { Blur }; + private static readonly IEnumerable BlurCommands = [Blur]; /// public IEnumerable Commands { get; } = BlurCommands; diff --git a/mixtape/Media/ImageSharp/Processors/RotateWebProcessor.cs b/mixtape/Media/ImageSharp/Processors/RotateWebProcessor.cs index 00d1c333..494cbccb 100644 --- a/mixtape/Media/ImageSharp/Processors/RotateWebProcessor.cs +++ b/mixtape/Media/ImageSharp/Processors/RotateWebProcessor.cs @@ -18,7 +18,7 @@ public class RotateWebProcessor : IImageWebProcessor /// The reusable collection of commands. /// private static readonly IEnumerable RotateCommands - = new[] { Rotate }; + = [Rotate]; /// public IEnumerable Commands { get; } = RotateCommands; diff --git a/mixtape/Models/Flavors/FlavorProvider.cs b/mixtape/Models/Flavors/FlavorProvider.cs index db025568..cf5bed57 100644 --- a/mixtape/Models/Flavors/FlavorProvider.cs +++ b/mixtape/Models/Flavors/FlavorProvider.cs @@ -20,7 +20,7 @@ public class FlavorProvider [JsonIgnore] public Func FlavorlessConstruct { get; set; } - public List Flavors { get; set; } = new(); + public List Flavors { get; set; } = []; /// /// Flavor discriminator converter diff --git a/mixtape/Models/Results/Result.cs b/mixtape/Models/Results/Result.cs index c78952b4..e78c2710 100644 --- a/mixtape/Models/Results/Result.cs +++ b/mixtape/Models/Results/Result.cs @@ -11,7 +11,7 @@ public class Result public bool IsSuccess { get; set; } [DataMember(Name = "errors")] - public List Errors { get; set; } = new(); + public List Errors { get; set; } = []; public Result() { } diff --git a/mixtape/Models/Results/UrlsResult.cs b/mixtape/Models/Results/UrlsResult.cs index 105a5356..9f9f8c24 100644 --- a/mixtape/Models/Results/UrlsResult.cs +++ b/mixtape/Models/Results/UrlsResult.cs @@ -24,7 +24,7 @@ public class UrlResult public class UrlsResult { - public string[] Urls { get; set; } = Array.Empty(); + public string[] Urls { get; set; } = []; public string Domain { get; set; } diff --git a/mixtape/Numbers/Number.cs b/mixtape/Numbers/Number.cs index 2ec00225..4cc43bd7 100644 --- a/mixtape/Numbers/Number.cs +++ b/mixtape/Numbers/Number.cs @@ -43,7 +43,7 @@ public class Number : MixtapeEntity /// /// Store current counters /// - public List Counters { get; set; } = new(); + public List Counters { get; set; } = []; /// /// Post process the compiled number diff --git a/mixtape/Numbers/Numbers.cs b/mixtape/Numbers/Numbers.cs index 75b81c1f..497b665b 100644 --- a/mixtape/Numbers/Numbers.cs +++ b/mixtape/Numbers/Numbers.cs @@ -115,7 +115,7 @@ public class Numbers : INumbers return; } - number.Counters = new(); + number.Counters = []; await Db.Update(number); } diff --git a/mixtape/Rendering/QrCode/QrCode.cs b/mixtape/Rendering/QrCode/QrCode.cs index d1a46891..87ee3885 100644 --- a/mixtape/Rendering/QrCode/QrCode.cs +++ b/mixtape/Rendering/QrCode/QrCode.cs @@ -108,7 +108,7 @@ public class QrCode Objects.RequireNonNull(data); Objects.RequireNonNull(ecl); var seg = QrSegment.MakeBytes(data); - return EncodeSegments(new List { seg }, ecl); + return EncodeSegments([seg], ecl); } #endregion @@ -1030,7 +1030,7 @@ public class QrCode { if (Version == 1) { - return new int[] { }; + return []; } var numAlign = Version / 7 + 2; @@ -1292,7 +1292,7 @@ public class QrCode public static readonly Ecc High = new Ecc(3, 2); - internal static readonly Ecc[] AllValues = { Low, Medium, Quartile, High }; + internal static readonly Ecc[] AllValues = [Low, Medium, Quartile, High]; /// /// Ordinal number of error correction level (in the range 0 to 3). diff --git a/mixtape/Rendering/QrCode/QrSegmentAdvanced.cs b/mixtape/Rendering/QrCode/QrSegmentAdvanced.cs index bab2c342..87402ae5 100644 --- a/mixtape/Rendering/QrCode/QrSegmentAdvanced.cs +++ b/mixtape/Rendering/QrCode/QrSegmentAdvanced.cs @@ -106,7 +106,7 @@ public static class QrSegmentAdvanced private static List MakeSegmentsOptimally(int[] codePoints, int version) { if (codePoints.Length == 0) - return new List(); + return []; var charModes = ComputeCharacterModes(codePoints, version); return SplitIntoSegments(codePoints, charModes); } @@ -120,7 +120,7 @@ public static class QrSegmentAdvanced throw new ArgumentOutOfRangeException(nameof(codePoints)); } - Mode[] modeTypes = { Mode.Byte, Mode.Alphanumeric, Mode.Numeric, Mode.Kanji }; // Do not modify + Mode[] modeTypes = [Mode.Byte, Mode.Alphanumeric, Mode.Numeric, Mode.Kanji]; // Do not modify var numModes = modeTypes.Length; // Segment header sizes, measured in 1/6 bits diff --git a/mixtape/Routing/RequestUrlResolver.cs b/mixtape/Routing/RequestUrlResolver.cs index 2d80a4d0..89c15ae2 100644 --- a/mixtape/Routing/RequestUrlResolver.cs +++ b/mixtape/Routing/RequestUrlResolver.cs @@ -9,7 +9,7 @@ public class RequestUrlResolver : IRequestUrlResolver protected ILogger Logger { get; } - static string[] Protocols = new[] { "http://", "https://", "ftp://", "ftps://", "sftp://", "udp://" }; + static string[] Protocols = ["http://", "https://", "ftp://", "ftps://", "sftp://", "udp://"]; public RequestUrlResolver(IHttpContextAccessor httpContextAccessor, ILogger logger) diff --git a/mixtape/Utils/Base32.cs b/mixtape/Utils/Base32.cs index 5cac46f7..8bffa26a 100644 --- a/mixtape/Utils/Base32.cs +++ b/mixtape/Utils/Base32.cs @@ -44,7 +44,7 @@ public static class Base32 input = input.TrimEnd('=').ToUpperInvariant(); if (input.Length == 0) { - return new byte[0]; + return []; } var output = new byte[input.Length * 5 / 8]; diff --git a/mixtape/Utils/ObjectTraverser.cs b/mixtape/Utils/ObjectTraverser.cs index aff65642..f6ad5710 100644 --- a/mixtape/Utils/ObjectTraverser.cs +++ b/mixtape/Utils/ObjectTraverser.cs @@ -18,8 +18,8 @@ public class ObjectTraverser /// public static List> Find(object value) where T : class { - HashSet exploredObjects = new HashSet(); - List> found = new List>(); + HashSet exploredObjects = []; + List> found = []; Find(value, null, string.Empty, null, exploredObjects, found); @@ -32,8 +32,8 @@ public class ObjectTraverser /// public static List Find(Type type, object value) { - HashSet exploredObjects = new HashSet(); - List found = new List(); + HashSet exploredObjects = []; + List found = []; Find(type, value, null, string.Empty, null, exploredObjects, found); @@ -46,8 +46,8 @@ public class ObjectTraverser /// public static List> FindAttribute(object value) where T : Attribute { - HashSet exploredObjects = new HashSet(); - List> found = new List>(); + HashSet exploredObjects = []; + List> found = []; FindAttribute(value, null, string.Empty, null, exploredObjects, found); diff --git a/mixtape/Utils/Safenames.cs b/mixtape/Utils/Safenames.cs index 116979a5..597ea889 100644 --- a/mixtape/Utils/Safenames.cs +++ b/mixtape/Utils/Safenames.cs @@ -15,7 +15,7 @@ public class Safenames const char DOT = '.'; - static char[] TICKS = new char[3] { '`', '\'', '´' }; + static char[] TICKS = ['`', '\'', '´']; ///