MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

Use ComponentResourceKey instead of strings to identify resources

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

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

enhancement evaluation required
主要言語
C#
スター
16.3k
フォーク
3.5k
平均マージ
1日 22時間
マージ済み PR(30日)
8

説明

**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:
```csharp
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`:
```xaml

```

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

```

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

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

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

評価

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

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

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