Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
milandjurdjevic committed Nov 12, 2023
1 parent 225803f commit e7e1ae5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Strinum/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
### Usage

The source generator will scan the source code for enum members marked
with `System.ComponentModel.DescriptionAttribute`. Attribute argument value will retrieved from `GetDescription()`
extension method.
The source generator will scan the source code for enum types and generate a `Stringify()` extension method that will return the name of the enum member as a string.

### Example

```csharp
public enum Number
{
[Description("Number 1")] One,
[Description("Number 2")] Two,
[Description("Number 3")] Three
One,
Two,
Three
}

Console.WriteLine(Number.One.GetDescription());
Console.WriteLine(Number.Two.GetDescription());
Console.WriteLine(Number.Three.GetDescription());
Console.WriteLine(Number.One.Stringify());
Console.WriteLine(Number.Two.Stringify());
Console.WriteLine(Number.Three.Stringify());

// Output:
// Number 1
Expand Down

0 comments on commit e7e1ae5

Please sign in to comment.