Repository navigation
Closed
Labels
Milestone
Description
Feature 04 of the 11 features of ResXLocalization 2.0.0, parent issue #29. "Feature NN" in this
issue means an entry of the numbered feature list in the parent issue.
Why
- Since feature 03 the typed keys use
<Name>Keys.ResourceManager, but samples, tests and docs still
register the designer's instance - a secondResourceManagerfor the same file. - A registered manager with a wrong base name makes every later search-all lookup (a key without a
resource manager, which searches all registered managers) throw
MissingManifestResourceException, far from the typo that caused it. - The WPF designer runs no startup code, so resources registered in
App.OnStartupare missing there.
What changes
// Avalonia: in BuildAvaloniaApp (runs in the previewer too)
Localizer.Current.RegisterResourceManager(AppStringsKeys.ResourceManager);
// WPF: in a module initializer, so the designer sees it too
[ModuleInitializer]
internal static void Register() => Localizer.Current.RegisterResourceManager(AppStringsKeys.ResourceManager);Localizer.RegisterResourceManagerchecks once that resources exist under the manager's base name and
otherwise throws anArgumentExceptionnaming it.- Registration stays explicit consumer code; the library and the generator register nothing.
- The WPF sample moves registration and its initial English culture into a module initializer, so both
apply in the designer too. - New guide "Registering resource files": where to register, class libraries, dependency injection,
resources from other assemblies, Native AOT.
Breaking changes
RegisterResourceManagerrejects a plainResourceManagerwhose base name has no resources.
Acceptance criteria
- A wrong base name fails at registration, with the base name in the message; subclasses are not
probed. - Samples, tests and package consumers register the generated managers; nothing in the samples
depends on a designer. - Search-all lookups work in the Visual Studio WPF designer and the Avalonia previewer (manual check).
- Registration guide, lookup guide, changelog and migration guide updated.
Activity