Repository: microsoft/garnet
File: libs/server/Resp/Parser/RespCommand.cs (C#)

Code before:
        /// </summary>
        public static ReadOnlySpan<RespCommand> ExpandForACLs(this RespCommand cmd)
        {
            return
                cmd switch
                {
                    RespCommand.SET => ExpandedSET,
                    RespCommand.BITOP => ExpandedBITOP,
                    _ => default
                };
        }

        internal const RespCommand FirstReadCommand = RespCommand.NONE + 1;

        internal const RespCommand LastReadCommand = RespCommand.APPEND - 1;

        internal const RespCommand FirstWriteCommand = RespCommand.APPEND;

        internal const RespCommand LastWriteCommand = RespCommand.BITOP_NOT;

        internal const RespCommand LastDataCommand = RespCommand.EVALSHA;

        /// <summary>
        /// Last valid command (i.e. RespCommand with the largest value excluding INVALID).
        /// </summary>
        public static RespCommand LastValidCommand = Enum.GetValues<RespCommand>().Where(cmd => cmd != RespCommand.INVALID).Max();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool IsReadOnly(this RespCommand cmd)
            => cmd <= LastReadCommand;

        public static bool IsDataCommand(this RespCommand cmd)
        {
            return cmd switch
            {
                // TODO: validate if these cases need to be excluded
                RespCommand.MIGRATE => false,
                RespCommand.DBSIZE => false,
                RespCommand.MEMORY_USAGE => false,
                RespCommand.FLUSHDB => false,
                RespCommand.FLUSHALL => false,
                RespCommand.KEYS => false,
                RespCommand.SCAN => false,
                _ => cmd >= FirstReadCommand && cmd <= LastDataCommand
            };
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool IsWriteOnly(this RespCommand cmd)
        {
            // If cmd < RespCommand.Append - underflows, setting high bits

Review comment (suggestion):
make this readonly

```suggestion
        public static RespCommand LastValidCommand { get; } = Enum.GetValues<RespCommand>().Where(cmd => cmd != RespCommand.INVALID).Max();
```

Code after:
        /// </summary>
        public static ReadOnlySpan<RespCommand> ExpandForACLs(this RespCommand cmd)
        {
            return
                cmd switch
                {
                    RespCommand.SET => ExpandedSET,
                    RespCommand.BITOP => ExpandedBITOP,
                    _ => default
                };
        }

        internal const RespCommand FirstReadCommand = RespCommand.NONE + 1;

        internal const RespCommand LastReadCommand = RespCommand.APPEND - 1;

        internal const RespCommand FirstWriteCommand = RespCommand.APPEND;

        internal const RespCommand LastWriteCommand = RespCommand.BITOP_NOT;

        internal const RespCommand LastDataCommand = RespCommand.EVALSHA;

        /// <summary>
        /// Last valid command (i.e. RespCommand with the largest value excluding INVALID).
        /// </summary>
        public static RespCommand LastValidCommand { get; } = Enum.GetValues<RespCommand>().Where(cmd => cmd != RespCommand.INVALID).Max();

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool IsReadOnly(this RespCommand cmd)
            => cmd <= LastReadCommand;

        public static bool IsDataCommand(this RespCommand cmd)
        {
            return cmd switch
            {
                // TODO: validate if these cases need to be excluded
                RespCommand.MIGRATE => false,
                RespCommand.DBSIZE => false,
                RespCommand.MEMORY_USAGE => false,
                RespCommand.FLUSHDB => false,
                RespCommand.FLUSHALL => false,
                RespCommand.KEYS => false,
                RespCommand.SCAN => false,
                _ => cmd >= FirstReadCommand && cmd <= LastDataCommand
            };
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool IsWriteOnly(this RespCommand cmd)
        {
            // If cmd < RespCommand.Append - underflows, setting high bits