Skip to content

Can't use List or From methods before explicit use of enum value #2

@strandloper

Description

@strandloper

Unless a call to one of the enum declarations (e.g. TestEnum.One) is made first, the List, FromName and FromValue methods do not always work correctly.

Having added the following tests to SmartEnumFromName

[Fact]
public void ReturnsEnumGivenNoExplicitPriorUse()
{
	string expected = "One";
	Assert.Equal(expected, TestEnum.FromName(expected).Name);
}

[Fact]
public void ReturnsEnumGivenExplicitPriorUse()
{
	string expected = TestEnum.One.Name;
	Assert.Equal(expected, TestEnum.FromName(expected).Name);
}

I found that they both pass when running all tests but when run individually, ReturnsEnumGivenNoExplicitPriorUse does not pass. Additionally I found that SmartEnumList.ReturnsAllDefinedSmartEnums also fails when run individually. Thus it seems that the forced invocation code is not working properly. I'll try to figure out why but in the meantime you may also want to take a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions