From 6a6f45dc75a474198422b145cf7e0cb6234ca345 Mon Sep 17 00:00:00 2001 From: Milan Djurdjevic Date: Fri, 3 May 2024 16:47:27 +0200 Subject: [PATCH] Update docs --- README.md | 3 +++ src/Strinum/README.md | 28 ++++++++++++++++++++++++++++ src/Strinum/Strinum.csproj | 4 ++-- {img => src/Strinum}/icon.png | Bin 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/Strinum/README.md rename {img => src/Strinum}/icon.png (100%) diff --git a/README.md b/README.md index 0b4f431..20c2953 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ stringification methods for enum types. This "tool" efficiently scans your sourc and generates methods that facilitate the conversion of enum members to their corresponding string representations and vice versa. +## Features +To read more about the library features and usage, please visit the [documentation](src/Strinum/README.md#features) link. + ## Benchmark | Method | Mean | Error | StdDev | Gen0 | Allocated | diff --git a/src/Strinum/README.md b/src/Strinum/README.md new file mode 100644 index 0000000..2fbf349 --- /dev/null +++ b/src/Strinum/README.md @@ -0,0 +1,28 @@ +# Strinum + +Quick and easy conversion between enum and strings using source generator. + +## Features + +### Convert Enum To String +Convert an enum to a string representation, using the `StringEnum.ToString` method. The output can be customized +using the `StringEnumAttribute` class. + +```csharp +enum MyEnum +{ + ValueOne, + [StringEnum("Value 2")] ValueTwo +} + + +string value = StringEnum.ToString(MyEnum.Value); +``` + +### Convert String To Enum +Convert a string to an enum representation, using the `StringEnum.ToEnum` method. The method returns a null in case +that the string does not match any enum member. + +```csharp +MyEnum? value = StringEnum.ToEnum("Value"); +``` diff --git a/src/Strinum/Strinum.csproj b/src/Strinum/Strinum.csproj index 850b43b..de36bd4 100644 --- a/src/Strinum/Strinum.csproj +++ b/src/Strinum/Strinum.csproj @@ -34,8 +34,8 @@ - - + + diff --git a/img/icon.png b/src/Strinum/icon.png similarity index 100% rename from img/icon.png rename to src/Strinum/icon.png