-
-
Notifications
You must be signed in to change notification settings - Fork 18
Added ToShortNames and DisplayShortNames dictionary #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for handling "short names" for enum values through a new ShortName attribute in the Supernova.Enum.Generators project. The enhancement enables developers to define and access abbreviated representations of enum values alongside existing display names and descriptions.
Key changes include:
- Introduction of short name processing in the enum source generator with dictionary storage and extension methods
- Addition of
ToShortNameFastextension method andDisplayShortNamesDictionaryproperty generation - Comprehensive test coverage for the new short name functionality including edge cases
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Supernova.Enum.Generators/EnumSourceGenerator.cs | Core implementation of short name processing, dictionary generation, and extension method creation |
| Supernova.Enum.Generators/SourceGeneratorHelper.cs | Added constants for new extension method and property names |
| test/UnitTests/EnumGeneratorTest.cs | Updated test enum with ShortName attributes and added comprehensive unit tests |
| test/UnitTests/InternalEnumGeneratorTest.cs | Mirror of public enum tests for internal enum validation |
| test/Console.Test.Benchmark/Program.cs | Added performance benchmarks and native implementation for comparison |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces support for handling "short names" for enum values in the
Supernova.Enum.Generatorsproject. The changes include updates to the source generator to process a newShortNameattribute, generate corresponding extension methods and dictionaries, and add comprehensive tests to validate the functionality.Linked issues
resolves #138
Enhancements to Enum Source Generator:
enumShortNamesto store short names for enum members and updated the source generator to populate it when theShortNameattribute is provided. (Supernova.Enum.Generators/EnumSourceGenerator.cs: [1] [2]ToShortNamemethod to generate extension methods for converting enum values to their short names. (Supernova.Enum.Generators/EnumSourceGenerator.cs: [1] [2]DisplayShortNamesDictionarymethod to generate a dictionary mapping enum values to their short names. (Supernova.Enum.Generators/EnumSourceGenerator.cs: Supernova.Enum.Generators/EnumSourceGenerator.csR395-R419)Updates to Source Generator Helper:
ToShortNameFastextension method andDisplayShortNamesDictionaryproperty. (Supernova.Enum.Generators/SourceGeneratorHelper.cs: Supernova.Enum.Generators/SourceGeneratorHelper.csR11-R17)Test Enhancements:
UserType,UserTypeTest, andInternalUserTypeTest) to include theShortNameattribute for enum members. (test/Console.Test.Benchmark/Program.cs: [1]test/UnitTests/EnumGeneratorTest.cs: [2]test/UnitTests/InternalEnumGeneratorTest.cs: [3]ToShortNameFastextension method, including cases for undefined values and default values. (test/UnitTests/EnumGeneratorTest.cs: [1] [2];test/UnitTests/InternalEnumGeneratorTest.cs: [3] [4]ToShortNameFastandToShortNameNativemethods to measure performance. (test/Console.Test.Benchmark/Program.cs: [1] [2]