Skip to content

Releases: OctopBP/enum-ext

1.6.0

19 Mar 06:52

Choose a tag to compare

New

  • ConversionStrategy — Choose how enums are serialized: by name (Name), snake_case (SnakeCase), or numeric value (Value) for JsonConverter, JsonArrayConverter, ValueConverter, and ValueArrayConverter.
  • Support for [Flags] enums — For flag enums, generated methods: SetFlag, GetFlag, ClearFlag, GetActiveFlags.
  • Array model binder — Generated model binder and attribute for enum arrays (enum[]) in ASP.NET Core.
  • LanguageExt — Optional generation of TryFromString, TryFromSnakeCaseString, TryFromValue, TryFromStringValue when LanguageExt is referenced.
  • Value() — Generated as a simple cast instead of a switch.

Fixes

  • JsonConverter: added null-token check when reading.

Docs

  • README updated with EnumExt.dll import steps and feature overview.

1.5.0

05 Feb 09:57

Choose a tag to compare

  • Add two type of conversion for JsonArrayConverter (by name and by value).
  • Add summary for generated code.
  • Add new methods to work with enum value.

Full Changelog: OctopBP/unity-attributes@1.4.0...1.5.0

1.4.0

19 Mar 20:28

Choose a tag to compare

Add EnumTypeFor attribute

You can add this attribute to enum

[EnumTypeFor(typeof(AssetReference))]
public enum UnitType
{
    Frog,
    Snake,
}

and it will generate new type for you

[Serializable]
public class UnitTypeForAssetReference
{
    [SerializeField] public AssetReference Frog;
    [SerializeField] public AssetReference Snake;

    public AssetReference Get(UnitType key)
    {
        return key switch
        {
            UnitType.Frog => Frog,
            UnitType.Snake => Snake,
            _ => throw new System.ArgumentOutOfRangeException(nameof(key), key, null),
        };
    }
}

So you can use it like this:

var assetAtType = unitAssets.Get(type);

1.3.1

18 Mar 18:00

Choose a tag to compare

Fixes

1.3.0.0

18 Mar 17:41

Choose a tag to compare

Update PublicAccessor to IncrementalGenerator

1.2.1.0

02 Dec 10:48

Choose a tag to compare

  • GenConstructor
  • PublicAccessor
  • Readonly
  • MonoReadonly
  • Singleton

1.1.2.1

19 Oct 12:07

Choose a tag to compare

  • GenConstructor
  • PublicAccessor
  • Readonly
  • MonoReadonly