Some MemoryMarshal methods are source incompatible in .NET11
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
まず、PR #126252 のオーバーロード優先順位の変更と、ソース互換性に関する注記の .NET Runtime ドキュメント規約を読みます。影響を受ける MemoryMarshal オーバーロードに this を渡す readonly struct のメソッドはコンパイルに失敗する場合があることを文書化し、issue の例または回避策を含めます。互換性の破壊とその範囲が正式に文書化されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
#126252 added [OverloadResolutionPriority(1)] to several methods in System.Runtime.InteropServices.MemoryMarshal to prefer Span<T> over ReadOnlySpan<T>. This change fixed source incompatibility for a larger issue, but at the expense of source compatibility for edge cases.
One such example is attempting to use these methods by passing this inside an instance method of a struct that has implicit conversions to both Span<T> and ReadOnlySpan<T> when the method is marked readonly.
This change should be formally documented to acknowledge that such code patterns will now fail to compile.
Minimum example
[InlineArray(8)]
public struct CoolInlineArray {
byte data;
// Works in .NET10 - chooses ReadOnlySpan<T> overload
// Fails in .NET11 - chooses Span<T> overload
internal readonly ulong GetLongA() => MemoryMarshal.Cast<byte, ulong>(this)[0];
// Works in .NET10
// Works in .NET11
internal ulong GetLongB() => MemoryMarshal.Cast<byte, ulong>(this)[0];
}
Workarounds
This pattern is likely incredibly rare, and easily addressed:
- Explicitly cast
thistoReadOnlySpan<T> - Remove
readonlyfrom the method (potentially undesirable for performance reasons)
- 主要言語
- C#
- スター
- 18.4k
- フォーク
- 5.8k
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 590
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/runtime のほかの issue
-
area-Setup untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/runtime#137376 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ImmutableSortedSet<T>.Builder: enumerating through IEnumerable<T> doesn't throw on modification and can return wrong items対応中かも @aw0lid が 3 日前に担当しました。 オープンarea-System.Collections
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#137167 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
DbTransaction.SupportsSavepoints docs say Release/ReleaseAsync are expected to throw, but they are no-ops by design対応中かも @alaricd が 7 日前に担当しました。 オープンarea-System.Transactions untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dotnet/runtime#137040 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
FileSystemGlobbing: Matcher throws ArgumentOutOfRangeException when the rootDir is the same value as the file対応中かも @makazeu が 7 日前に担当しました。 オープンarea-Extensions-FileSystem
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#136989 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Configuration binder source generator emits unqualified List<T> when binding arrays without implicit usings対応中かも @makazeu が 7 日前に担当しました。 オープンarea-Extensions-Configuration bug source-generator
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#136972 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug emitter:client:csharp
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/typespec#12572 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
newrelic/newrelic-dotnet-agent#3949 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-networking
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/aspnetcore#70545 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信