Document unit-test / theory-data impact of .NET 11 double→decimal conversion
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 1/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
まず docs/core/compatibility/core-libraries/11/decimal-biginteger-floating-point-conversions.md を確認し、既存の Recommended action セクションを確認してください。関連する .NET 11 のライブラリページは docs/core/whats-new/dotnet-11/libraries.md です。issue に記載された xUnit と NUnit のガイダンスおよび例を含む、単体テストへの影響についての簡潔なサブセクションを追加してください。ページで浮動小数点数のテストデータが decimal に変換される方法を説明し、decimal を保持する代替方法を示せば完了です。
索引モデルが issue の本文から書いたものです。
説明
Type of issue
- Content issue (typos, broken links, missing/outdated content)
- Product issue (bug in docs tooling/platform)
Location
- https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/11/decimal-biginteger-floating-point-conversions
- Source:
docs/core/compatibility/core-libraries/11/decimal-biginteger-floating-point-conversions.md - Also referenced from
docs/core/whats-new/dotnet-11/libraries.md
Description
The breaking-change page correctly documents that float/double → decimal is now correctly rounded (exact binary value), and recommends decimal literals (1.23m) instead of casting double literals.
What is easy to miss in migration: unit-test theory / inline data often injects floating literals as double, then binds or casts them to decimal parameters. That path was “quietly OK” on .NET 10 (15-digit-style conversion) and fails equality / validation on .NET 11 even when production code already uses decimal end-to-end.
xUnit
// Compiles: 0.1 is a double attribute argument
[Theory]
[InlineData(0.1)]
public void Rate(decimal rate)
{
// Under .NET 10: rate often equals 0.1m
// Under .NET 11: rate == 0.1000000000000000055511151231m → assert fails
Assert.Equal(0.1m, rate);
}
// Does NOT compile: decimal is not a valid C# attribute argument type
// [InlineData(0.1m)]
Workaround that keeps real decimals: MemberData / ClassData / TheoryData<decimal> with 0.1m values (not attribute args).
NUnit
// Non-m literals become double, then convert to decimal param
[TestCase(0.1)]
public void Rate(decimal rate) { ... }
// Prefer:
[TestCase("0.1")]
public void Rate(decimal rate) { ... } // parsed as decimal
Why document this on the BC page
- The failure mode is often tests only, so teams can think production is broken when CI is.
- It is not obvious that
InlineData(0.1)+decimalis a double conversion (C# forbids0.1min attributes). - Same BC already says “don’t assume a binary FP literal and a decimal literal with the same source text represent the same value” — a short “Impact on unit tests” subsection with xUnit/NUnit examples would catch a large class of migration failures.
Suggested addition (sketch)
Under Recommended action, add something like:
Unit tests (xUnit / NUnit / similar)
Theory/case attributes cannot take decimal constants in C#. Non-integer numeric attribute args are double/float. Binding those to decimal parameters uses the same conversion as (decimal)double and therefore changes under this BC. Prefer:
- xUnit:
TheoryData/MemberDatawithdecimalvalues (0.1m), or string data +decimal.Parse - NUnit:
[TestCase("0.1")]intodecimal, or explicit0.1monly outside attributes
Page URL
Related
- Runtime BC is intentional; this is a docs request only (no ask to revert conversion).
- xUnit docs request: https://github.com/xunit/xunit/issues/3658
- xUnit attribute limitation is language-level (
decimalnot allowed in attribute arguments).
- 主要言語
- 言語のデータがありません
- スター
- 4.8k
- フォーク
- 6.1k
- 平均マージ
- 23時間 7分
- マージ済み PR(30日)
- 196
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/docs のほかの issue
-
:watch: Not Triaged dotnet-fundamentals/svc
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dotnet/docs#56465 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
dotnet-fundamentals/svc install/subsvc
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dotnet/docs#56344 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Upgrade from `net9.0` to LTS (or STS) image tag対応中かも @ShyneChikwapulo が 9 日前に担当しました。 オープンdotnet-target-version
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
dotnet/docs#56293 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Documentation for dotnet sln add doesn't mention the --include-references flag対応中かも @BartoszKlonowski が 9 日前に担当しました。 オープンdotnet-fundamentals/svc
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
dotnet/docs#56289 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Add more to the documentation対応中かも @adarsh6980 が 28 日前に担当しました。 オープンdotnet-fsharp/svc help wanted
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
dotnet/docs#56209 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/vscode-docs#10534 ·
メンテナーはふだん 1 日以内に返信
-
bug effort:s impact:med raised-by:verifier risk:med to:worker
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
medici-finance/assay#4170 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Python Pointcloudオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ArduCAM/Arducam_tof_camera#125 ·
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
funmary-app/funmary#399 ·
メンテナーはふだん 1 日以内に返信
-
area:curator enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
CassioDalla/Scrinalia#150 ·
メンテナーはふだん 1 日以内に返信