{"id":13628963,"url":"https://github.com/skarllot/EnumUtilities","last_synced_at":"2025-04-17T04:32:39.940Z","repository":{"id":65547452,"uuid":"583909039","full_name":"skarllot/EnumUtilities","owner":"skarllot","description":"A source generator for C# that uses Roslyn to create extensions and parsers for enumerations","archived":false,"fork":false,"pushed_at":"2025-04-09T14:55:20.000Z","size":1780,"stargazers_count":11,"open_issues_count":10,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T15:47:36.600Z","etag":null,"topics":["atomic","description","display","enum","enumeration","enummember","extension","factory","fast","generator","interlocked","json","jsonconverter","parse","resource","resourcetype","shortname","validation"],"latest_commit_sha":null,"homepage":"https://fgodoy.me/EnumUtilities/","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/skarllot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["skarllot"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-12-31T12:16:26.000Z","updated_at":"2025-04-09T14:53:33.000Z","dependencies_parsed_at":"2024-03-27T16:29:33.167Z","dependency_job_id":"07051a69-6568-4ca1-a550-d534074fbc20","html_url":"https://github.com/skarllot/EnumUtilities","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarllot%2FEnumUtilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarllot%2FEnumUtilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarllot%2FEnumUtilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skarllot%2FEnumUtilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skarllot","download_url":"https://codeload.github.com/skarllot/EnumUtilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249316005,"owners_count":21249873,"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":["atomic","description","display","enum","enumeration","enummember","extension","factory","fast","generator","interlocked","json","jsonconverter","parse","resource","resourcetype","shortname","validation"],"created_at":"2024-08-01T22:01:00.348Z","updated_at":"2025-04-17T04:32:39.926Z","avatar_url":"https://github.com/skarllot.png","language":"C#","funding_links":["https://github.com/sponsors/skarllot"],"categories":["Content","Source Generators"],"sub_categories":["131. [EnumUtilities](https://ignatandrei.github.io/RSCG_Examples/v2/docs/EnumUtilities) , in the [Enum](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enum) category","Enums"],"readme":"# Enum Utilities\n\n[![Build status](https://github.com/skarllot/EnumUtilities/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/skarllot/EnumUtilities/actions)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/skarllot/EnumUtilities/badge)](https://securityscorecards.dev/viewer/?uri=github.com/skarllot/EnumUtilities)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/EngRajabi/Enum.Source.Generator/master/LICENSE)\n[![Nuget](https://img.shields.io/nuget/v/Raiqub.Generators.EnumUtilities)](https://www.nuget.org/packages/Raiqub.Generators.EnumUtilities)\n[![Nuget](https://img.shields.io/nuget/dt/Raiqub.Generators.EnumUtilities?label=Nuget.org%20Downloads\u0026style=flat-square\u0026color=blue)](https://www.nuget.org/packages/Raiqub.Generators.EnumUtilities)\n\n_A source generator for C# that uses Roslyn to create extensions and parsers for enumerations_\n\n[🏃 Quickstart](#quickstart) \u0026nbsp; | \u0026nbsp; [📖 Documentation](https://fgodoy.me/EnumUtilities/) \u0026nbsp; | \u0026nbsp; [📦 NuGet](https://www.nuget.org/packages/Raiqub.Generators.EnumUtilities)\n\n\u003chr /\u003e\n\nA source generator for C# that uses Roslyn to create extensions and parsers for enumerations, allowing to get a value associated to enum member or parse back from attribute value to enum member. All code generated at compile time thus avoid using reflection or boilerplate code.\n\n## Compatibility\n\nRaiqub.Generators.EnumUtilities runs with Roslyn compiler so does not introduce a new dependency to your project besides a library containing the EnumGenerator attribute.\n\nIt requires at least the .NET 6 SDK to run, but you can target earlier frameworks.\n\n## Documentation\nThis README aims to give a quick overview of some Raiqub Enum Utilities features. For deeper detail of available features, be sure also to check out [Documentation Page](https://fgodoy.me/EnumUtilities/).\n\n## Quickstart\n\nAdd the package to your application using\n\n```shell\ndotnet add package Raiqub.Generators.EnumUtilities\n```\n\nAdding the package will automatically add a marker attribute, `[EnumGenerator]`, to your project.\n\nTo use the generator, add the `[EnumGenerator]` attribute to an enum. For example:\n ```csharp\n[EnumGenerator]\npublic enum Categories\n{\n    Electronics,\n    Food,\n    Automotive,\n    Arts,\n    BeautyCare,\n    Fashion\n}\n```\n\nThis will generate 3 classes with the following methods:\n- [CategoriesExtensions](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.CategoriesExtensions.g.cs)\n  - ToStringFast(this Categories)\n  - GetStringCount(this Categories)\n  - IsDefined(this Categories)\n  - InterlockedAdd(this ref Categories, int)\n  - InterlockedDecrement(this ref Categories)\n  - InterlockedIncrement(this ref Categories)\n  - InterlockedCompareExchange(this ref Categories, Categories, Categories)\n  - InterlockedExchange(this ref Categories, Categories)\n- [CategoriesFactory](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.CategoriesFactory.g.cs)\n  - Parse(string, bool = false)\n  - Parse(ReadOnlySpan\u003cchar\u003e, bool = false)\n  - ParseOrNull(string?, bool = false)\n  - TryParse(string?, bool, out Categories)\n  - TryParse(string?, out Categories)\n  - TryParse(string?, bool = false)\n  - TryParse(ReadOnlySpan\u003cchar\u003e, bool, out Categories)\n  - TryParse(ReadOnlySpan\u003cchar\u003e, out Categories)\n  - TryParse(ReadOnlySpan\u003cchar\u003e, bool = false)\n  - GetValues()\n  - GetNames()\n- [CategoriesValidation](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.CategoriesValidation.g.cs)\n  - IsDefined(Categories)\n  - IsDefined(string?, StringComparison)\n  - IsDefinedIgnoreCase(string?)\n  - IsDefined(string?)\n\nBit flags enums are supported too:\n```csharp\n[Flags]\n[EnumGenerator]\npublic enum Colours\n{\n    Red = 1,\n    Blue = 2,\n    Green = 4,\n}\n```\n\nThen 3 classes will be generated with the following methods:\n- [ColoursExtensions](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.ColoursExtensions.g.cs)\n  - ToStringFast(this Colours)\n  - HasFlagFast(this Colours, Colours)\n  - GetStringCount(this Colours)\n  - IsDefined(this Colours)\n  - InterlockedAnd(this ref Colours, Colours)\n  - InterlockedOr(this ref Colours, Colours)\n  - InterlockedCompareExchange(this ref Colours, Colours, Colours)\n  - InterlockedExchange(this ref Colours, Colours)\n- [ColoursFactory](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.ColoursFactory.g.cs)\n  - Parse(string, bool = false)\n  - Parse(ReadOnlySpan\u003cchar\u003e, bool = false)\n  - ParseOrNull(string?, bool = false)\n  - TryParse(string?, bool, out Categories)\n  - TryParse(string?, out Categories)\n  - TryParse(string?, bool = false)\n  - TryParse(ReadOnlySpan\u003cchar\u003e, bool, out Categories)\n  - TryParse(ReadOnlySpan\u003cchar\u003e, out Categories)\n  - TryParse(ReadOnlySpan\u003cchar\u003e, bool = false)\n  - GetValues()\n  - GetNames()\n- [ColoursValidation](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.ColoursValidation.g.cs)\n  - IsDefined(Colours)\n  - IsDefined(string?, StringComparison)\n  - IsDefinedIgnoreCase(string?)\n  - IsDefined(string?)\n\nAll generated code are properly nullable annotated and removed from code coverage.\n\n## Supported members attributes\n\nThe following attributes are supported:\n- [`[EnumMember]`](https://fgodoy.me/EnumUtilities/members-attributes/enum-member-attribute.html)\n- [`[Description]`](https://fgodoy.me/EnumUtilities/members-attributes/description-attribute.html)\n- [`[Display]`](https://fgodoy.me/EnumUtilities/members-attributes/display-attribute.html)\n\n### JSON Serialization\n\nBesides the member name, supports the [EnumMemberAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.enummemberattribute) and [JsonPropertyNameAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonpropertynameattribute) attributes.\n\nExample:\n\n```csharp\n[JsonConverterGenerator]\n[JsonConverter(typeof(SeasonJsonConverter))]\npublic enum Season\n{\n    [EnumMember(Value = \"\\ud83c\\udf31\")]\n    Spring = 1,\n    [EnumMember(Value = \"\\u2600\\ufe0f\")]\n    Summer,\n    [EnumMember(Value = \"\\ud83c\\udf42\")]\n    Autumn,\n    [EnumMember(Value = \"\\u26c4\")]\n    Winter\n}\n```\n\nThis will generate the following JSON converter: [SeasonJsonConverter](./tests/EnumUtilities.Generators.IntegrationTests/Generated/Raiqub.Generators.EnumUtilities/Raiqub.Generators.EnumUtilities.EnumUtilitiesGenerator/Models.SeasonJsonConverter.g.cs).\n\n## Contributing\n\nIf something is not working for you or if you think that the source file\nshould change, feel free to create an issue or Pull Request.\nI will be happy to discuss and potentially integrate your ideas!\n\n## License\n\nSee the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskarllot%2FEnumUtilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskarllot%2FEnumUtilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskarllot%2FEnumUtilities/lists"}