Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Support for .Net 9 #919

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ab4517d
net9 changes
TedHartMS Jan 8, 2025
ed7cd27
Merge remote-tracking branch 'origin/main' into tedhar/net9
TedHartMS Jan 8, 2025
5f996a0
Collection expression fix
TedHartMS Jan 9, 2025
8b3d966
Fixing SYSLIB0057
TalZaccai Jan 9, 2025
44874e1
Removing ServicePointManager
TalZaccai Jan 9, 2025
2340ba5
Temporary fix for RedisCallErrors test failing in .net9
TalZaccai Jan 16, 2025
0cb7ff7
merging with latest main
TalZaccai Jan 17, 2025
8059a3a
some fixes
TalZaccai Jan 17, 2025
80b3dc4
Merge branch 'main' into tedhar/net9
TalZaccai Jan 17, 2025
84cc8cd
Added .net90 to CI and the Nightly GitHub Action
darrenge Jan 22, 2025
d0d948a
Fixed Garnet Worker to be both .net80 and .net90 and updated ADO pipe…
darrenge Jan 22, 2025
121d14f
Updated Tsav CI that runs in ADO when mirrored
darrenge Jan 22, 2025
faae98a
Fix to RedisCallErrors
TalZaccai Jan 23, 2025
2b67210
test
TalZaccai Jan 23, 2025
3e3ed56
fix
TalZaccai Jan 23, 2025
d94a323
Skipping RedisCallErrors test
TalZaccai Jan 23, 2025
b49a1b5
Merge branch 'tedhar/net9' of https://github.com/microsoft/garnet int…
darrenge Jan 23, 2025
a74e664
Reverting ignored test
TalZaccai Jan 23, 2025
0214669
Updating CI
TalZaccai Jan 23, 2025
ebd5f05
CI fix
TalZaccai Jan 23, 2025
3fc3ffe
Ignoring RedisCallErrors test when environment variable is not set
TalZaccai Jan 23, 2025
027fe0e
Added net90 to the external release pipeline. Required changed to pub…
darrenge Jan 24, 2025
99621f7
Merge branch 'tedhar/net9' of https://github.com/microsoft/garnet int…
darrenge Jan 24, 2025
0d668ec
Fixed bug in compressed file directory
darrenge Jan 24, 2025
2cedd73
Another try on fixing the destination directory issue
darrenge Jan 24, 2025
c82efda
Added CodeQL.yml which is custom so it works with net90 as well. Upda…
darrenge Jan 29, 2025
064ac3f
merging with latest main
TalZaccai Jan 30, 2025
37e1cbd
Set RunTImes to only be packed once since they are C++ and not depend…
darrenge Jan 30, 2025
078c297
Fixed broken merge
TalZaccai Jan 30, 2025
ffff185
Merge branch 'tedhar/net9' of https://github.com/microsoft/garnet int…
TalZaccai Jan 30, 2025
039499f
Added WorkFlow dispatch and commented out net90
darrenge Jan 30, 2025
9f3b2a6
Added net90 to CodeQL
darrenge Jan 30, 2025
ff9e9e4
Enabled the Create GH Release and Push Nuget packages tasks so it is …
darrenge Jan 30, 2025
939e97a
Merge branch 'main' into tedhar/net9
darrenge Jan 30, 2025
3dd2172
Merge branch 'main' into tedhar/net9
darrenge Jan 31, 2025
a729bf2
merging with latest main
TalZaccai Feb 18, 2025
9cbe7f5
format
TalZaccai Feb 18, 2025
1554339
format
TalZaccai Feb 18, 2025
e633959
Added 9.0 to dot net restore. Not for test matrix but for build.
darrenge Feb 19, 2025
f15a60d
Updated BDN expected values
darrenge Feb 20, 2025
fbfd10b
Trying to run BDN on net90 framework.
darrenge Feb 20, 2025
752eddc
Updated values because of the new Net90 BDN test runs
darrenge Feb 20, 2025
2aca4b4
Update some of the expected in the Operations.SortedSetOperations BDN…
darrenge Feb 20, 2025
29fc9c3
merge 'main' and resolve some "format" conflicts
TedHartMS Feb 20, 2025
5f81eae
Getting net90 expected values narrowed down. Just seems to be a coupl…
darrenge Feb 20, 2025
8559949
Merge branch 'tedhar/net9' of https://github.com/microsoft/garnet int…
darrenge Feb 20, 2025
2cf0856
Fixed a bug in the BDN script and updated expected values.
darrenge Feb 21, 2025
aa66f64
Merge branch 'main' into tedhar/net9
darrenge Feb 22, 2025
a8ca998
Merge branch 'main' into tedhar/net9
darrenge Feb 26, 2025
7c6d6e2
address new codeQL requirement
vazois Feb 27, 2025
fc7c077
Merge branch 'main' into tedhar/net9
darrenge Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup Label="Targets">
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<!-- Versioning property for builds and packages -->
Expand Down
4 changes: 2 additions & 2 deletions benchmark/BDN.benchmark/Parsing/IntegerToResp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ public void WriteInt32BulkString_AllAsciiLengths()
.. UnsignedInt32MultiplesOfTen.Select(n => n * -1),
.. UnsignedInt32MultiplesOfTen
];
public static int[] UnsignedInt32MultiplesOfTen => Enumerable.Range(0, 10).Select(n => (int)Math.Pow(10, n)).ToArray();
public static int[] UnsignedInt32MultiplesOfTen => [.. Enumerable.Range(0, 10).Select(n => (int)Math.Pow(10, n))];

// All multiples of 10 from 10^-19 to 10^19
public static long[] SignedInt64MultiplesOfTen => [
.. UnsignedInt64MultiplesOfTen.Select(n => n * -1),
.. UnsignedInt64MultiplesOfTen
];
public static long[] UnsignedInt64MultiplesOfTen => Enumerable.Range(0, 19).Select(n => (long)Math.Pow(10, n)).ToArray();
public static long[] UnsignedInt64MultiplesOfTen => [.. Enumerable.Range(0, 19).Select(n => (long)Math.Pow(10, n))];

public static int[] SignedInt32Values => [int.MinValue, -1, 0, int.MaxValue];
public static long[] SignedInt64Values => [long.MinValue, -1, 0, long.MaxValue];
Expand Down
6 changes: 5 additions & 1 deletion benchmark/BDN.benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class BaseConfig : ManualConfig
{
public Job Net8BaseJob { get; }
public Job Net9BaseJob { get; }

public BaseConfig()
{
Expand All @@ -33,9 +34,12 @@ public BaseConfig()

Net8BaseJob = baseJob.WithRuntime(CoreRuntime.Core80)
.WithEnvironmentVariables(new EnvironmentVariable("DOTNET_TieredPGO", "0"));
Net9BaseJob = baseJob.WithRuntime(CoreRuntime.Core90)
.WithEnvironmentVariables(new EnvironmentVariable("DOTNET_TieredPGO", "0"));

AddJob(
Net8BaseJob.WithId(".NET 8")
Net8BaseJob.WithId(".NET 8"),
Net9BaseJob.WithId(".NET 9")
);
}
}
4 changes: 2 additions & 2 deletions benchmark/Resp.benchmark/BenchUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Garnet.common;
using Garnet.server;
using Garnet.server.TLS;
using StackExchange.Redis;

namespace Resp.benchmark
Expand Down Expand Up @@ -62,7 +62,7 @@ public static SslClientAuthenticationOptions GetTlsOptions(string tlsHost, strin
{
return new SslClientAuthenticationOptions
{
ClientCertificates = [new X509Certificate2(certFile, certPassword)],
ClientCertificates = [CertificateUtils.GetMachineCertificateByFile(certFile, certPassword)],
TargetHost = tlsHost,
AllowRenegotiation = false,
RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true,
Expand Down
4 changes: 2 additions & 2 deletions benchmark/Resp.benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void WaitForServer(Options opts)

static void RunBasicCommandsBenchmark(Options opts)
{
int[] threadBench = opts.NumThreads.ToArray();
int[] threadBench = [.. opts.NumThreads];
int keyLen = opts.KeyLength;
int valueLen = opts.ValueLength;

Expand Down Expand Up @@ -275,7 +275,7 @@ static void RunBasicCommandsBenchmark(Options opts)
static void RunHLLBenchmark(Options opts)
{
var bench = new RespPerfBench(opts, 0, redis);
int[] threadBench = opts.NumThreads.ToArray();
int[] threadBench = [.. opts.NumThreads];

int loadThreads = 8;
int loadBatchSize = opts.DbSize / loadThreads;
Expand Down
4 changes: 2 additions & 2 deletions benchmark/Resp.benchmark/RespPerfBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ private void MGetThreadRunner(int threadid, int NumOps, int BatchSize = 1 << 12)
}
if (idx > 0)
{
var result = db.StringGet(getBatch.Take(idx).ToArray());
var result = db.StringGet([.. getBatch.Take(idx)]);
if (checkResults)
{
for (int k = 0; k < idx; k++)
Expand Down Expand Up @@ -543,7 +543,7 @@ private void LoadDatabaseStringSet(int BatchSize = 1 << 12)
{
for (int b = 0; b < DbSize; b += BatchSize)
{
db.StringSet(database.Skip(b).Take(BatchSize).ToArray());
db.StringSet([.. database.Skip(b).Take(BatchSize)]);
if (b > 0 && b % 1000000 == 0)
Console.WriteLine(b);
}
Expand Down
2 changes: 1 addition & 1 deletion hosting/Windows/Garnet.worker/Garnet.worker.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net8.0;net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion libs/common/EnumUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static IDictionary<string, string> GetEnumNameToDescription<T>() where T
public static string[] GetEnumDescriptions<T>(T value) where T : Enum
{
var nameToDesc = GetEnumNameToDescription<T>();
return value.ToString().Split(',').Select(f => nameToDesc.ContainsKey(f.Trim()) ? nameToDesc[f.Trim()] : f).ToArray();
return [.. value.ToString().Split(',').Select(f => nameToDesc.ContainsKey(f.Trim()) ? nameToDesc[f.Trim()] : f)];
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions libs/common/FailoverOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public enum FailoverOption : byte
/// </summary>
public static class FailoverUtils
{
static readonly byte[][] infoSections = Enum.GetValues<FailoverOption>()
.Select(x => Encoding.ASCII.GetBytes($"${x.ToString().Length}\r\n{x}\r\n")).ToArray();
static readonly byte[][] infoSections = [.. Enum.GetValues<FailoverOption>().Select(x => Encoding.ASCII.GetBytes($"${x.ToString().Length}\r\n{x}\r\n"))];

/// <summary>
/// Return resp formatted failover option
Expand Down
6 changes: 4 additions & 2 deletions libs/common/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ public static bool TryLoadAssemblies(IEnumerable<string> assemblyPaths, out IEnu
Assembly assembly;
try
{
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
// NET9 seems to hold the assembly locked if it's opened from the path directly, causing tests to fail.
//assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
assembly = AssemblyLoadContext.Default.LoadFromStream(new FileStream(path, FileMode.Open, FileAccess.Read));
}
catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException ||
ex is NotSupportedException || ex is BadImageFormatException ||
ex is SecurityException)
{
if (ex is FileLoadException && ex.Message == "Assembly with same name is already loaded")
if (ex is FileLoadException && ex.Message.Contains("Assembly with same name is already loaded"))
{
var assemblyName = AssemblyName.GetAssemblyName(path).Name;
tmpAssemblies.Add(AssemblyLoadContext.Default.Assemblies.First(a => a.GetName().Name == assemblyName));
Expand Down
3 changes: 1 addition & 2 deletions libs/common/Metrics/InfoMetricsType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public enum InfoMetricsType : byte
/// </summary>
public static class InfoCommandUtils
{
static readonly byte[][] infoSections = Enum.GetValues<InfoMetricsType>()
.Select(x => Encoding.ASCII.GetBytes($"${x.ToString().Length}\r\n{x}\r\n")).ToArray();
static readonly byte[][] infoSections = [.. Enum.GetValues<InfoMetricsType>().Select(x => Encoding.ASCII.GetBytes($"${x.ToString().Length}\r\n{x}\r\n"))];

/// <summary>
/// Return resp formatted info section
Expand Down
2 changes: 2 additions & 0 deletions libs/host/Garnet.host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<ItemGroup>
<Content Include="..\host\bin\Release\net8.0\*.dll" Pack="true" PackagePath="lib\net8.0" />
<Content Include="..\host\bin\Release\net8.0\*.xml" Pack="true" PackagePath="lib\net8.0" />
<Content Include="..\host\bin\Release\net9.0\*.dll" Pack="true" PackagePath="lib\net9.0" />
<Content Include="..\host\bin\Release\net9.0\*.xml" Pack="true" PackagePath="lib\net9.0" />
<Content Include="..\host\bin\Release\net8.0\runtimes\**\*.so" Pack="true" PackagePath="runtimes" />
<Content Include="..\host\bin\Release\net8.0\runtimes\**\*.dll" Pack="true" PackagePath="runtimes" />
<None Include="..\..\README.md" Pack="true" PackagePath="/"/>
Expand Down
24 changes: 16 additions & 8 deletions libs/server/Custom/CustomCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ internal int Register(string name, CommandType type, CustomRawStringFunctions cu
var newCmd = new CustomRawStringCommand(name, (ushort)extId, type, customFunctions, expirationTicks);
var setSuccessful = rawStringCommandMap.TrySetValue(cmdId, ref newCmd);
Debug.Assert(setSuccessful);
if (commandInfo != null) customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null) customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
if (commandInfo != null)
customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null)
customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
return extId;
}

Expand All @@ -73,8 +75,10 @@ internal int Register(string name, Func<CustomTransactionProcedure> proc, RespCo
var newCmd = new CustomTransaction(name, (byte)cmdId, proc);
var setSuccessful = transactionProcMap.TrySetValue(cmdId, ref newCmd);
Debug.Assert(setSuccessful);
if (commandInfo != null) customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null) customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
if (commandInfo != null)
customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null)
customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
return cmdId;
}

Expand Down Expand Up @@ -106,8 +110,10 @@ internal int RegisterType(CustomObjectFactory factory)
var scSetSuccessful = wrapper.commandMap.TrySetValue(scId, ref newSubCmd);
Debug.Assert(scSetSuccessful);

if (commandInfo != null) customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null) customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
if (commandInfo != null)
customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null)
customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);

return (extId, scId);
}
Expand All @@ -132,8 +138,10 @@ internal int Register(string name, Func<CustomProcedure> customProcedure, RespCo
var setSuccessful = customProcedureMap.TrySetValue(cmdId, ref newCmd);
Debug.Assert(setSuccessful);

if (commandInfo != null) customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null) customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
if (commandInfo != null)
customCommandsInfo.AddOrUpdate(name, commandInfo, (_, _) => commandInfo);
if (commandDocs != null)
customCommandsDocs.AddOrUpdate(name, commandDocs, (_, _) => commandDocs);
return cmdId;
}

Expand Down
21 changes: 21 additions & 0 deletions libs/server/Custom/ExpandableMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,27 @@ internal bool TrySetValue(int id, ref T value, bool noExpansion, bool updateSize
if (updateSize) TryUpdateSize(id);
return true;
}

/// <summary>
/// Maps map index to item ID
/// </summary>
/// <param name="index">Map index</param>
/// <returns>Item ID</returns>
private int GetIdFromIndex(int index) => descIds ? minId - index : index;

/// <summary>
/// Maps an item ID to a map index
/// </summary>
/// <param name="id">Item ID</param>
/// <returns>Map index</returns>
private int GetIndexFromId(int id) => descIds ? minId - id : id;

public void Clear()
{
if (Map is not null)
Array.Clear(Map);
ActualSize = 0;
}
}

/// <summary>
Expand Down
5 changes: 2 additions & 3 deletions libs/server/Metrics/Info/GarnetInfoMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ namespace Garnet.server
{
class GarnetInfoMetrics
{
public static readonly InfoMetricsType[] defaultInfo = Enum.GetValues<InfoMetricsType>()
public static readonly InfoMetricsType[] defaultInfo = [.. Enum.GetValues<InfoMetricsType>()
.Where(e => e switch
{
InfoMetricsType.STOREHASHTABLE => false,
InfoMetricsType.OBJECTSTOREHASHTABLE => false,
InfoMetricsType.STOREREVIV => false,
InfoMetricsType.OBJECTSTOREREVIV => false,
_ => true
})
.ToArray();
})];

MetricsItem[] serverInfo = null;
MetricsItem[] memoryInfo = null;
Expand Down
10 changes: 4 additions & 6 deletions libs/server/Objects/SortedSet/SortedSetObjectImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,9 @@ private void SortedSetPopMinOrMaxCount(ref ObjectInput input, ref SpanByteAndMem

if (validLimit)
{
elementsInLex = elementsInLex
elementsInLex = [.. elementsInLex
.Skip(limit.Item1 > 0 ? limit.Item1 : 0)
.Take(limit.Item2 > 0 ? limit.Item2 : elementsInLex.Count)
.ToList();
.Take(limit.Item2 > 0 ? limit.Item2 : elementsInLex.Count)];
}
}
catch (ArgumentException)
Expand Down Expand Up @@ -1067,10 +1066,9 @@ private void SortedSetPopMinOrMaxCount(ref ObjectInput input, ref SpanByteAndMem
if (doReverse) scoredElements.Reverse();
if (validLimit)
{
scoredElements = scoredElements
scoredElements = [.. scoredElements
.Skip(limit.Item1 > 0 ? limit.Item1 : 0)
.Take(limit.Item2 > 0 ? limit.Item2 : scoredElements.Count)
.ToList();
.Take(limit.Item2 > 0 ? limit.Item2 : scoredElements.Count)];
}

if (rem)
Expand Down
4 changes: 2 additions & 2 deletions libs/server/Objects/SortedSetGeo/SortedSetGeoObjectImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void GeoSearch(ref ObjectInput input, ref SpanByteAndMemory output)
}

// Check that we have the mandatory options
if (errorMessage == default && !((opts.FromMember || opts.FromLonLat) && (opts.ByRadius || opts.ByBox)))
if (errorMessage.IsEmpty && !((opts.FromMember || opts.FromLonLat) && (opts.ByRadius || opts.ByBox)))
argNumError = true;

// Check if we have a wrong number of arguments
Expand All @@ -420,7 +420,7 @@ private void GeoSearch(ref ObjectInput input, ref SpanByteAndMemory output)
}

// Check if we encountered an error while checking the parse state
if (errorMessage != default)
if (!errorMessage.IsEmpty)
{
while (!RespWriteUtils.WriteError(errorMessage, ref curr, end))
ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr, ref end);
Expand Down
6 changes: 3 additions & 3 deletions libs/server/Resp/RespCommandsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ private static bool TryInitializeRespCommandsInfo(ILogger logger = null)
.Where(ci => !ci.Value.IsInternal)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value, StringComparer.OrdinalIgnoreCase));
ExternalRespSubCommandsInfo = new ReadOnlyDictionary<string, RespCommandsInfo>(tmpExternalSubCommandsInfo);
AllRespCommandNames = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, AllRespCommandsInfo.Keys.ToArray());
ExternalRespCommandNames = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, ExternalRespCommandsInfo.Keys.ToArray());
AllRespCommandNames = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, [.. AllRespCommandsInfo.Keys]);
ExternalRespCommandNames = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, [.. ExternalRespCommandsInfo.Keys]);
FlattenedRespCommandsInfo = new ReadOnlyDictionary<RespCommand, RespCommandsInfo>(tmpFlattenedRespCommandsInfo);

AclCommandInfo =
Expand All @@ -196,7 +196,7 @@ private static bool TryInitializeRespCommandsInfo(ILogger logger = null)
.GroupBy(static t => t.Acl)
.ToDictionary(
static grp => grp.Key,
static grp => (IReadOnlyList<RespCommandsInfo>)ImmutableArray.CreateRange(grp.Select(static t => t.CommandInfo))
static grp => (IReadOnlyList<RespCommandsInfo>)[.. grp.Select(static t => t.CommandInfo)]
)
);

Expand Down
4 changes: 2 additions & 2 deletions libs/server/ServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace Garnet.server
{
static class ServerConfig
{
public static readonly HashSet<ServerConfigType> DefaultConfigType = Enum.GetValues<ServerConfigType>().
public static readonly HashSet<ServerConfigType> DefaultConfigType = [.. Enum.GetValues<ServerConfigType>().
Where(e => e switch
{
ServerConfigType.NONE => false,
ServerConfigType.ALL => false,
_ => true
}).ToHashSet();
})];

public static unsafe ServerConfigType GetConfig(Span<byte> parameter)
{
Expand Down
2 changes: 1 addition & 1 deletion libs/server/StoreWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Garnet.server
/// <summary>
/// Wrapper for store and store-specific information
/// </summary>
public sealed class StoreWrapper
public sealed class StoreWrapper : IDisposable
{
internal readonly string version;
internal readonly string redisProtocolVersion;
Expand Down
4 changes: 4 additions & 0 deletions libs/server/TLS/CertificateUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public static X509Certificate2 GetMachineCertificateBySubjectName(string subject
/// <exception cref="ArgumentException"></exception>
public static X509Certificate2 GetMachineCertificateByFile(string fileName, string password)
{
#if NET9_0_OR_GREATER
return X509CertificateLoader.LoadPkcs12FromFile(fileName, password);
#else
return new X509Certificate2(fileName, password);
#endif
}
}
}
8 changes: 5 additions & 3 deletions libs/server/TLS/GarnetTlsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ X509Certificate2 GetCertificateIssuer(string issuerCertificatePath)
{
try
{
#if NET9_0_OR_GREATER
issuer = X509CertificateLoader.LoadCertificateFromFile(issuerCertificatePath);
#else
issuer = new X509Certificate2(issuerCertificatePath);
#endif
}
catch (Exception ex)
{
Expand Down Expand Up @@ -295,9 +299,7 @@ bool ValidateCertificateIssuer(X509Certificate2 certificateToValidate, X509Certi
var chainBuilt = chain.Build(certificateToValidate);
if (!chainBuilt)
{
string[] errors = chain.ChainStatus
.Select(x => String.Format("{0} ({1})", x.StatusInformation.Trim(), x.Status))
.ToArray();
string[] errors = [.. chain.ChainStatus.Select(x => String.Format("{0} ({1})", x.StatusInformation.Trim(), x.Status))];
string certificateErrorsString = "Unknown errors.";
if (errors != null && errors.Length > 0)
certificateErrorsString = String.Join(", ", errors);
Expand Down
Loading
Loading