Skip to content
| Marketplace
Sign in
Visual Studio>Tools>ResW File Code Generator
ResW File Code Generator

ResW File Code Generator

Christian Resma Helle

|
196,756 installs
| (13) | Free
A Visual Studio Custom Tool for generating a strongly typed helper class for accessing localized resources from a .ResW file.
Download

buymeacoffee

ResW File Code Generator

A Visual Studio Custom Tool for generating a strongly typed helper class for accessing localized resources from a .ResW file.

Features

  • Define custom namespace for the generated file
  • Auto-updating of generated code file when changes are made to the .ResW Resource file
  • XML documentation style comments like "Localized resource similar to '[the value]'"
  • Supports Visual Studio 2015, 2017, 2019, and 2022
  • Supports dotted keys - Replaces . with _ (e.g. Something.Awesome = Something_Awesome)

Custom Tools

  • ReswFileCodeGenerator - Generates a public class
  • InternalReswFileCodeGenerator - Generates an internal (C#) / friend (VB) class

Supported Languages

  • C#
  • Visual Basic

Screenshots

ReswFileCodeGenerator Custom Tool

InternalReswFileCodeGenerator Custom Tool

Example C# Usage

string test1, test2, test3, test4;

void LoadLocalizedStrings()
{
    test1 = CSharpUwpApp.Properties.Resources.Test1;
    test2 = CSharpUwpApp.Properties.Resources.Test2;
    test3 = CSharpUwpApp.Properties.Resources.Test3;
    test4 = CSharpUwpApp.Properties.Resources.Test_With_Dotted_Keys;
}

Example VB Usage

Dim test1, test2, test3, test4

Private Sub LoadLocalizedStrings()
    test1 = VisualBasicUwpApp.Properties.Resources.Test1
    test2 = VisualBasicUwpApp.Properties.Resources.Test2
    test3 = VisualBasicUwpApp.Properties.Resources.Test3
    test4 = VisualBasicUwpApp.Properties.Resources.Test_With_Dotted_Keys
End Sub

Example Generated C# Code

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by ResW File Code Generator (http://bit.ly/reswcodegen)
//     ResW File Code Generator was written by Christian Resma Helle
//     and is under GNU General Public License version 2 (GPLv2)
//
//     This code contains a helper class exposing property representations
//     of the string resources defined in the specified .ResW file
//
//     Code generation environment:
//         Time and Date: 4/29/2025 11:49:45 PM (UTC-08:00) Pacific Time (US & Canada)
//         Computer Name: my-pc.my-domain.net
//         User Name    : MY-DOMAIN\JohnDoe
// </auto-generated>
// ---------------------------------------------------------------------------------------
namespace CSharpUwpApp.Properties
{
    public sealed partial class Resources
    {
        private static global::Windows.ApplicationModel.Resources.ResourceLoader resourceLoader;

        /// <summary>
        /// Get or set ResourceLoader implementation
        /// </summary>
        public static global::Windows.ApplicationModel.Resources.ResourceLoader Resource
        {
            get
            {
                if ((resourceLoader == null))
                {
                    Resources.Initialize();
                }
                return resourceLoader;
            }
            set
            {
                resourceLoader = value;
            }
        }

        /// <summary>
        /// Localized resource similar to "Test 1 value"
        /// </summary>
        public static string Test1
        {
            get
            {
                return Resource.GetString("Test1");
            }
        }

        /// <summary>
        /// Localized resource similar to "Test 2 value"
        /// </summary>
        public static string Test2
        {
            get
            {
                return Resource.GetString("Test2");
            }
        }

        /// <summary>
        /// Localized resource similar to "Test 3 value"
        /// </summary>
        public static string Test3
        {
            get
            {
                return Resource.GetString("Test3");
            }
        }

        /// <summary>
        /// Localized resource similar to "Test With Dotted Keys"
        /// </summary>
        public static string Test_With_Dotted_Keys
        {
            get
            {
                return Resource.GetString("Test/With/Dotted/Keys");
            }
        }

        public static void Initialize()
        {
            string executingAssemblyName;
            executingAssemblyName = global::System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
            string currentAssemblyName;
            currentAssemblyName = typeof(Resources).AssemblyQualifiedName;
            string[] currentAssemblySplit;
            currentAssemblySplit = currentAssemblyName.Split(',');
            currentAssemblyName = currentAssemblySplit[1].Trim();
            if ((global::Windows.UI.Core.CoreWindow.GetForCurrentThread() == null))
            {
                if (executingAssemblyName.Equals(currentAssemblyName))
                {
                    resourceLoader = global::Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse("Resources");
                }
                else
                {
                    resourceLoader = global::Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse(currentAssemblyName + "/Resources");
                }
            }
            else
            {
                if (executingAssemblyName.Equals(currentAssemblyName))
                {
                    resourceLoader = global::Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView("Resources");
                }
                else
                {
                    resourceLoader = global::Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(currentAssemblyName + "/Resources");
                }
            }
        }
    }
}

Example Generated Visual Basic Code

'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.42000
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On


'---------------------------------------------------------------------------------------
'<auto-generated>
'    This code was generated by ResW File Code Generator (http://bit.ly/reswcodegen)
'    ResW File Code Generator was written by Christian Resma Helle
'    and is under GNU General Public License version 2 (GPLv2)
'
'    This code contains a helper class exposing property representations
'    of the string resources defined in the specified .ResW file
'
'    Code generation environment:
'        Time and Date: 4/30/2025 12:04:30 AM (UTC-08:00) Pacific Time (US & Canada)
'        Computer Name: my-pc.my-domain.net
'        User Name    : MY-DOMAIN\JohnDoe
'</auto-generated>
'---------------------------------------------------------------------------------------

Partial Public NotInheritable Class Resources

    Private Shared resourceLoader As Global.Windows.ApplicationModel.Resources.ResourceLoader

    '''<summary>
    '''Get or set ResourceLoader implementation
    '''</summary>
    Public Shared Property Resource() As Global.Windows.ApplicationModel.Resources.ResourceLoader
        Get
            If (resourceLoader Is Nothing) Then
                Resources.Initialize
            End If
            Return resourceLoader
        End Get
        Set
            resourceLoader = value
        End Set
    End Property

    '''<summary>
    '''Localized resource similar to "Test 1 value"
    '''</summary>
    Public Shared ReadOnly Property Test1() As String
        Get
            Return Resource.GetString("Test1")
        End Get
    End Property

    '''<summary>
    '''Localized resource similar to "Test 2 value"
    '''</summary>
    Public Shared ReadOnly Property Test2() As String
        Get
            Return Resource.GetString("Test2")
        End Get
    End Property

    '''<summary>
    '''Localized resource similar to "Test 3 value"
    '''</summary>
    Public Shared ReadOnly Property Test3() As String
        Get
            Return Resource.GetString("Test3")
        End Get
    End Property

    '''<summary>
    '''Localized resource similar to "Test With Dotted Keys"
    '''</summary>
    Public Shared ReadOnly Property Test_With_Dotted_Keys() As String
        Get
            Return Resource.GetString("Test/With/Dotted/Keys")
        End Get
    End Property

    Public Shared Sub Initialize()
        Dim executingAssemblyName As String
        executingAssemblyName = Global.System.Reflection.[Assembly].GetEntryAssembly.GetName.Name
        Dim currentAssemblyName As String
        currentAssemblyName = GetType(Resources).AssemblyQualifiedName
        Dim currentAssemblySplit() As String
        currentAssemblySplit = currentAssemblyName.Split(Global.Microsoft.VisualBasic.ChrW(44))
        currentAssemblyName = currentAssemblySplit(1).Trim
        If (Global.Windows.UI.Core.CoreWindow.GetForCurrentThread Is Nothing) Then
            If executingAssemblyName.Equals(currentAssemblyName) Then
                resourceLoader = Global.Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse("Resources")
            Else
                resourceLoader = Global.Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse(currentAssemblyName + "/Resources")
            End If
        Else
            If executingAssemblyName.Equals(currentAssemblyName) Then
                resourceLoader = Global.Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView("Resources")
            Else
                resourceLoader = Global.Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(currentAssemblyName + "/Resources")
            End If
        End If
    End Sub
End Class
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft