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

Allow ref struct on Generic ThrowHelper methods

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

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

2026年2月7日 から。

  • #1161 @Avid29 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp

調査の方向性

ファイルもテストも指定されていません。まず汎用的な ThrowHelper API を見つけ、それらの型パラメーターがどのように宣言されているかを確認してください。プロジェクトが .NET 9 と C# 13 をサポートしていることを確認してください。既存の ThrowHelper メソッドの動作を変更せずに、Span のような ref struct 型を使用できれば完了です。

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

説明

feature request :mailbox_with_mail:
Overview

This would allow ref structs to be used in pattern matching with a ThrowHelper case, using the new allow ref struct "anti-constraint".

API breakdown

This changes nothing except allowable use cases for existing ThrowHelper APIs.

Usage example

I encountered a situation in my code where I wanted to pattern match and return a ref struct. I found I could not use the ThrowHelper because it was a ref struct.

Here's an example of another imaginable situation utilizing the Span<T>.

Span<int> span = x switch
{
    0 => stackalloc int[size],
    1 => new int[size],
    2 => something.AsSpan(),
    _ => ThrowHelper.ThrowArgumentOutOfRangeException<Span<int>>(),
};
Breaking change?

No

Alternatives

throw without ThrowHelper

Additional context

This will require .NET 9 and C# version 13

Help us help you

Yes, I'd like to be assigned to work on this item

主要言語
C#
スター
3.8k
フォーク
401
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

CommunityToolkit/dotnet のほかの issue

CommunityToolkit/dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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