-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Closed
Code quality
Copy link
Description
Description
Instead of pasting raw string code of resources let’s have a source generator to use properties. The source generator will update the class right after resw file changed.
Concerned code
None. Making new robust code.
Gains
- Robustness
Requirements
App.Strings.Strings partial class.
If comments start with GENERIC or something we can apart the class into Strings.Generic, Strings.Infecrectable, Strings.Settings, etc. this is just in my mind and not official proposal tho.
Here’s code:
// Strings.Inflectsble.cs
/// <auto-generated/>
public partial class Strings
{
/// <summary>
/// (generated comments from resw here)
/// </summary>
public string AddNewItem
=> “Add new items”;
}Strings.AddNewItems.GetLocalized(itemCount);If we want to make localization methods simplify, let's make Strings.Extension class file as partial.
// Strings.Extension.cs
[MarkupExtensionReturnType(ReturnType = typeof(string))]
public partial class Strings : MarkupExtension
{
public string Name { get; set; }
protected override object ProvideValue()
=> GetType().GetProperty(Name)?.GetValue(this);
}Comments
No response
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
✅ Done