ThisAssembly.Strings 2.0.10

This project uses SponsorLink to attribute sponsor status (direct, indirect or implicit). For IDE usage, sponsor status is required. IDE-only warnings will be issued after a grace period otherwise.

This package generates a static ThisAssembly.Strings class with public constants exposing string resources in .resx files or methods with the right number of parameters for strings that use formatting parameters.

In addition, it groups constants and methods in nested classes according to an optional underscore separator to organize strings. For example, User_InvalidCredentials can be accessed with ThisAssembly.Strings.User.InvalidCredentials if it contains a simple string, or as a method with the right number of parametres if its value has a format string.

Given the following Resx file:

Name Value Comment
Infrastructure_MissingService Service {0} is required. For logging only!
Shopping_NoShipping We cannot ship {0} to {1}.
Shopping_OutOfStock Product is out of stock at this time.
Shopping_AvailableOn Product available on .

The following code would be generated:

partial class ThisAssembly
{
    public static partial class Strings
    {
        public static partial class Infrastructure
        {
            /// <summary>
            /// For logging only!
            /// => "Service {0} is required."
            /// </summary>
            public static string MissingService(object arg0)
                => string.Format(CultureInfo.CurrentCulture, 
                    Strings.GetResourceManager("ThisStore.Properties.Resources").GetString("MissingService"), 
                    arg0);
        }

        public static partial class Shopping
        {
            /// <summary>
            /// => "We cannot ship {0} to {1}."
            /// </summary>
            public static string NoShipping(object arg0, object arg1)
                => string.Format(CultureInfo.CurrentCulture, 
                    Strings.GetResourceManager("ThisStore.Properties.Resources").GetString("NoShipping"), 
                    arg0, arg1);

            /// <summary>
            /// => "Product is out of stock at this time."
            /// </summary>
            public static string OutOfStock
                => Strings.GetResourceManager("ThisStore.Properties.Resources").GetString("OutOfStock");

            /// <summary>
            /// Product available on {date:yyyy-MM}.
            /// </summary>
            public static string AvailableOn(object date) 
                => string.Format(CultureInfo.CurrentCulture, 
                    Strings.GetResourceManager("ThisAssemblyTests.Resources").GetString("WithNamedFormat").Replace("{date:yyyy-MM}", "{0}"), 
                    ((IFormattable)date).ToString("yyyy-MM", CultureInfo.CurrentCulture));
        }
    }
}

Customizing the generated code

The following MSBuild properties can be used to customize the generated code:

Property Description
ThisAssemblyNamespace Sets the namespace of the generated ThisAssembly root class. If not set, it will be in the global namespace.
ThisAssemblyVisibility Sets the visibility modifier of the generated ThisAssembly root class. If not set, it will be internal.

Sponsors

Clarius Org Kirill Osenkov MFB Technologies, Inc. Torutek DRIVE.NET, Inc. Keith Pickford Thomas Bolon Kori Francis Toni Wenzel Uno Platform Dan Siegel Reuben Swartz Jacob Foshee Eric Johnson Ix Technologies B.V. David JENNI Jonathan Charley Wu Jakob Tikjøb Andersen Tino Hager Mark Seemann Ken Bonny Simon Cropp agileworks-eu sorahex Zheyu Shen Vezel ChilliCream 4OTC Vincent Limo Jordan S. Jones domischell

Sponsor this project  

Learn more about GitHub Sponsors

Showing the top 20 packages that depend on ThisAssembly.Strings.

Packages Downloads
ThisAssembly
Meta-package that includes all ThisAssembly.* packages.
4
ThisAssembly
Meta-package that includes all ThisAssembly.* packages. > This project uses SponsorLink to attribute sponsor status (direct, indirect or implicit). For IDE usage, sponsor status is required. > IDE-only warnings will be emitted after a grace period otherwise. Learn more at https://github.com/devlooped#sponsorlink.
3
ThisAssembly
Meta-package that includes all ThisAssembly.* packages.
2
ThisAssembly
Meta-package that includes all ThisAssembly.* packages. ** C# 9.0 ONLY **
2
ThisAssembly
Meta-package that includes all ThisAssembly.* packages. > This project uses SponsorLink to attribute sponsor status (direct, indirect or implicit). For IDE usage, sponsor status is required. > IDE-only warnings will be emitted after a grace period otherwise. Learn more at https://github.com/devlooped#sponsorlink.
2
ThisAssembly
Meta-package that includes all ThisAssembly.* packages. ** C# 9.0 ONLY ** Built from https://github.com/devlooped/ThisAssembly/tree/832f99169
2

.NET Standard 2.0

Version Downloads Last updated
2.1.2 2 06/16/2026
2.1.1 2 06/16/2026
2.1.0 2 06/16/2026
2.1.0-rc.1 2 06/16/2026
2.1.0-rc 2 06/16/2026
2.1.0-beta 2 06/16/2026
2.0.14 3 06/16/2026
2.0.13 3 06/16/2026
2.0.12 3 06/16/2026
2.0.11 3 06/16/2026
2.0.10 3 06/16/2026
2.0.9 2 06/16/2026
2.0.8 2 06/16/2026
2.0.7 2 06/15/2026
2.0.6 2 06/16/2026
2.0.5 3 06/16/2026
2.0.4 3 06/16/2026
2.0.3 3 06/16/2026
2.0.2 3 06/16/2026
1.4.3 3 06/16/2026
1.4.2 3 06/16/2026
1.4.1 3 06/16/2026
1.4.0 3 06/16/2026
1.1.3 3 06/16/2026
1.1.2 3 06/16/2026
1.1.1 3 06/16/2026
1.1.1-beta 3 06/16/2026
1.1.0 3 06/16/2026
1.0.10 3 06/16/2026
1.0.9 3 06/16/2026
1.0.8 2 06/16/2026
1.0.7 3 06/16/2026
1.0.6 3 06/16/2026
1.0.5 3 06/16/2026
1.0.4 3 06/16/2026
1.0.3 3 06/16/2026
1.0.2 3 06/16/2026
1.0.1 3 06/16/2026
1.0.0 3 06/16/2026
1.0.0-rc.1 3 06/16/2026
1.0.0-rc 3 06/16/2026
1.0.0-beta 3 06/16/2026
1.0.0-alpha.3 3 06/16/2026
1.0.0-alpha.2 3 06/16/2026
1.0.0-alpha.1 3 06/16/2026
1.0.0-alpha 3 06/16/2026
0.10.6 3 06/16/2026
0.10.5 3 06/16/2026