Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

RedisValue equality treats "1,000", "(5)" and " 5 " as numbers, via NumberStyles.Any

オープン
#3,233 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@banlor がすでに取り組んでいます。

2026年9月23日 から。

  • #3253 @banlor による — オープン
  • #3259 @cloudsealed による — マージされずにクローズ

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp, redis
領域
backend, databases

調査の方向性

Format.cs:178 と RedisValue.Simplify() が使用する TryParseDouble のパスから始め、それを NumberStyles.Integer を使用する整数解析のパスと比較します。列挙されている等価性のケースと、提案されている NumberStyles の代替案を確認します。受け入れる数値テキストのセマンティクスについて合意され、影響を受ける比較にリグレッションカバレッジが追加されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Raised during review of #3230, where the numeric side of RedisValue equality came up. Pre-existing
behaviour, not caused by that PR.

What happens

operator == runs Simplify() on both sides, so text that parses as a number is compared as a number.
Format.cs:178 does that parse with NumberStyles.Any:

return double.TryParse(s, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out value);

NumberStyles.Any allows thousands separators, parentheses for negatives, leading and trailing whitespace, a
currency symbol, and exponents. So:

comparison result storage
"1,000" == "1000" True String / String
"(5)" == "-5" True String / String
" 5 " == "5" True String / String
"1,0,0,0" == "1000" True String / String
"5." == "5" True String / String
"+5" == "5" True String / String
"1e2" == "100" True String / String

Both sides are String-typed throughout — these are ordinary string values, not numbers that happen to be
spelled differently.

Every integer path in Format.cs uses the much tighter NumberStyles.Integer; TryParseDouble is the only
one using Any, which makes it look more like an oversight than a decision.

Why it matters

These are distinct values on the server — distinct set members, distinct hash fields, distinct keys — that
compare equal in the client. Anything deduplicating RedisValues in a HashSet<RedisValue>, or keying a
Dictionary<RedisValue, T>, silently merges them. " 5 " and "5" are plainly different values by any
reading.

It is at least self-consistent: GetHashCode simplifies too, so equal values do share a hash and no hash
container is corrupted. The problem is that the equality is much wider than "numeric text".

Possible direction

NumberStyles.Float (leading/trailing whitespace, leading sign, decimal point, exponent) would drop the
separators, parentheses and currency symbol while keeping what Redis actually emits for numbers. Even that
leaves " 5 " == "5" true and "1e2" == "100" true, so the whitespace and exponent allowances are worth a
separate decision.

Any change here alters shipped comparison behaviour, so it wants its own discussion rather than being folded
into unrelated work — hence this issue rather than a PR.

主要言語
C#
スター
6.2k
フォーク
1.6k
平均マージ
1日 5時間
マージ済み PR(30日)
27

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

StackExchange/StackExchange.Redis のほかの issue

StackExchange/StackExchange.Redis の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。