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

Use ComponentResourceKey instead of strings to identify resources

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

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

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp
領域
desktop

調査の方向性

まず、現在リソースを文字列で識別しているリソースディクショナリの宣言と XAML の使用箇所を特定します。提案されている静的な ComponentResourceKey パターンを確認し、移行の範囲を決定します。リソースがコンパイラで検証されるキーを使用し、後方互換性またはバージョニングに関する判断が文書化され、検証されていれば完了です。

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

説明

enhancement evaluation required

Is your feature request related to a problem? Please describe.

  • Currently resources are identified using strings. The string can only be validated at runtime and not while writing the XAML code
  • When a resource key changes in a new version, the compiler does not indicate a problem and we get an Exception at runtime

Describe the solution you'd like

  • Using ComponentResourceKey would make resources type-save
  • Optional: preserve the existing string-based resource keys for backward-compatibility, or increase the version number because of breaking changes

Describe alternatives you've considered

  • Don't know a better way

Additional context
To create the resource key, you need to create a Component resource key in a static class:

public static partial class MaterialDesignColors
{
    public static ComponentResourceKey Primary50Color { get; } = new(typeof(MaterialDesignColors), nameof(Primary50Color));
    // ...
}

When declaring the resource in the ResouceDictionary, use the ComponentResourceKey as Key:

<Color Key="{x:Static md:MaterialDesignColors.Primary50Color}" ... />

When using the resource, we can now use a static reference that is checked by the compiler:

<Brush Color="{DynamicResource {x:Static md:MaterialDesignColors.Primary50Color}}" ... />
主要言語
C#
スター
16.3k
フォーク
3.5k
平均マージ
1日 15時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

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

MaterialDesignInXAML/MaterialDesignInXamlToolkit のほかの issue

MaterialDesignInXAML/MaterialDesignInXamlToolkit の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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