Use ComponentResourceKey instead of strings to identify resources
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by locating the resource dictionary declarations and XAML usages that currently identify resources with strings. Review the proposed static ComponentResourceKey pattern and determine the scope of the migration. Done means resources use compiler-checked keys, with the backward-compatibility or versioning decision documented and validated.
Written by the indexing model from the issue text.
Description
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
ComponentResourceKeywould 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}}" ... />
- Dominant language
- C#
- Stars
- 16.3k
- Forks
- 3.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MaterialDesignInXAML/MaterialDesignInXamlToolkit
-
enhancement up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#2485 ·
Maintainers usually reply within 1 day
-
Deadzone in `NumericUpDown` controlPossibly taken @Keboo claimed this 6 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 58/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#4094 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 52/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#4093 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement evaluation required
Difficulty 5/5 Over a week Newbie friendliness 25/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#3997 · 1 comment ·
Maintainers usually reply within 1 day
-
bug evaluation required
Difficulty 3/5 1-2 days Newbie friendliness 45/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#3971 · 1 comment ·
Maintainers usually reply within 1 day
All issues in MaterialDesignInXAML/MaterialDesignInXamlToolkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stryker-mutator/stryker-net#3892 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
MobiFlight/MobiFlight-Connector#3419 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Kryptos-FR/MarkView.Avalonia#105 ·
Maintainers usually reply within 1 day
-
[辞書]Open提案 辞書
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
microsoft/fluentui-blazor#5410 ·
Maintainers usually reply within 1 day