Skip to content

Repository files navigation

Resxis

A source-generated, satellite-assembly-free IStringLocalizer<T> that consolidates multiple .resx files into one strongly-typed class.

Install

<PackageReference Include="Resxis" Version="1.1.1" />

Setup

Declare the neutral .resx as AdditionalFiles with Namespace, ClassName, and Visibility metadata. Culture variants (e.g. Resources.de.resx) are listed as plain AdditionalFiles — they inherit from the neutral file.

<ItemGroup>
  <AdditionalFiles Include="Resources.resx"
    Namespace="My.App" ClassName="Resources" Visibility="public" />
  <AdditionalFiles Include="Resources.de.resx" />
</ItemGroup>

The package automatically removes those .resx files from the SDK's default EmbeddedResource glob — no satellite assemblies are produced and no manual Remove entries are needed.

Dependency Injection

Register Resxis in your service container, then inject IStringLocalizer<Resources> and look up keys:

// Program.cs / Startup.cs
services.AddResxisLocalization();

// Usage
public class MyService(IStringLocalizer<Resources> localizer)
{
    public string Greet() => localizer["WELCOME"].Value;
}

Opt-in: Value Properties

Set GenerateValueProperties="true" on the neutral file to generate a public static string {KEY} property per resource key:

<AdditionalFiles Include="Resources.resx"
  Namespace="My.App" ClassName="Resources" Visibility="public"
  GenerateValueProperties="true" />

Each property returns the culture-aware value for CultureInfo.CurrentUICulture, falling back to the key name if no translation is found. This enables data-annotation interop:

[Display(ResourceType = typeof(Resources), Name = nameof(Resources.MY_KEY))]
public string MyProperty { get; set; }

Diagnostics

ID Severity Description
RESXIS001 Error Duplicate key detected across files for the same class
RESXIS002 Warning Culture file has no neutral-file sibling — it will be ignored
RESXIS003 Info Non-string entry skipped (Resxis only handles string values)

Sample

See samples/Resxis.Sample for a runnable end-to-end example.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages