{"id":21011813,"url":"https://github.com/khellang/resourcehelpergenerator","last_synced_at":"2025-05-15T04:32:25.676Z","repository":{"id":23566101,"uuid":"26933820","full_name":"khellang/ResourceHelperGenerator","owner":"khellang","description":"An MSBuild task that generates a strongly typed helper class for resource files with support for string formatting.","archived":false,"fork":false,"pushed_at":"2015-06-19T09:25:59.000Z","size":333,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-03T20:28:14.721Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/khellang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-20T21:57:02.000Z","updated_at":"2024-03-29T16:47:15.000Z","dependencies_parsed_at":"2022-08-22T01:50:45.554Z","dependency_job_id":null,"html_url":"https://github.com/khellang/ResourceHelperGenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khellang%2FResourceHelperGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khellang%2FResourceHelperGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khellang%2FResourceHelperGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khellang%2FResourceHelperGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khellang","download_url":"https://codeload.github.com/khellang/ResourceHelperGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225326552,"owners_count":17456966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T09:31:24.579Z","updated_at":"2024-11-19T09:31:25.108Z","avatar_url":"https://github.com/khellang.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ResourceHelperGenerator\n\nAn MSBuild task that generates a strongly typed helper class for resource files with support for string formatting.\n\nThe task will automatically hook into the MSBuild pipeline when you install the NuGet package, either using `Install-Package ResourceHelperGenerator` or through the Package Manager UI.\n\nIt will generate strongly typed helpers for `*.resx` files under the `Properties` folder of your project. This will hopefully be customizable at some point in the future.\n\nString resources containing either `{0}`-type placeholders or `{argumentName}`-type placeholders, will get methods accepting corresponding arguments, while resources without placeholders will get properties generated.\n\n## Example\n\nIf you have the following resource file, called `Strings.resx` sitting under the `Properties` folder of your project, which has a default namespace of `MyCompany.AwesomeApp`:\n\n| Name | Value |\n|------|-------|\n| ArgumentNull | The argument '{argumentName}' cannot be null. |\n| StringArgumentEmpty | The string argument '{argumentName}' cannot be empty. |\n\nThe following file, `Strings.Designer.cs` will be generated and placed under the `Strings.resx` file in your project:\n\n```csharp\n// \u003cauto-generated /\u003e\n\n#if NETFX_CORE\n#define RESOURCE_HELPER_TYPEINFO\n#endif\n\nnamespace MyCompany.AwesomeApp\n{\n    using System;\n    using System.CodeDom.Compiler;\n    using System.Diagnostics;\n    using System.Globalization;\n    using System.Reflection;\n    using System.Resources;\n\n    [GeneratedCode(\"ResourceHelperGenerator\", \"0.3.1\")]\n#if RESOURCE_HELPER_INTERNAL\n    internal\n#else\n    public\n#endif\n    static class Strings\n    {\n        private static readonly ResourceManager ResourceManager\n            = new ResourceManager(\"MyCompany.AwesomeApp.Properties.Strings\", GetAssembly(typeof(Strings)));\n\n        /// \u003csummary\u003e\n        /// The argument '{argumentName}' cannot be null.\n        /// \u003c/summary\u003e\n        public static string ArgumentNull(object argumentName)\n        {\n            return string.Format(CultureInfo.CurrentCulture, GetString(\"ArgumentNull\", \"argumentName\"), argumentName);\n        }\n\n        /// \u003csummary\u003e\n        /// The string argument '{argumentName}' cannot be empty.\n        /// \u003c/summary\u003e\n        public static string StringArgumentEmpty(object argumentName)\n        {\n            return string.Format(CultureInfo.CurrentCulture, GetString(\"StringArgumentEmpty\", \"argumentName\"), argumentName);\n        }\n\n        private static string GetString(string name, params string[] formatterNames)\n        {\n            var value = ResourceManager.GetString(name);\n\n            if (value == null)\n            {\n                throw new Exception(string.Format(\"Value for key '{0}' was null.\", name));\n            }\n\n            if (formatterNames != null)\n            {\n                for (var i = 0; i \u003c formatterNames.Length; i++)\n                {\n                    value = value.Replace(\"{\" + formatterNames[i] + \"}\", \"{\" + i + \"}\");\n                }\n            }\n\n            return value;\n        }\n\n        private static Assembly GetAssembly(Type type)\n        {\n#if RESOURCE_HELPER_TYPEINFO\n            return type.GetTypeInfo().Assembly;\n#else\n            return type.Assembly;\n#endif\n        }\n    }\n}\n```\n\nThe first time this happens, the task will modify your project file (to add the helper) and you will be asked to reload the project.\n\n## Internalized Helper Class\n\nIf you want to internalize the helper class, you must add the `RESOURCE_HELPER_INTERNAL` conditional compilation symbol in the project's build configuration.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhellang%2Fresourcehelpergenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhellang%2Fresourcehelpergenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhellang%2Fresourcehelpergenerator/lists"}