Enum based on int - problem in EnumUtils

Sep 24, 2009 at 2:26 PM

In my case I have the declaration for class as follows. when I run the function f I get the exception while generating the json schema.

public enum SortTypeFlag : int { No = 0, Asc = 1, Desc = -1 }
class X
{
        public SortTypeFlag x;
}

void f()
{
X x= new X();
Type type = x.GetType();
Newtonsoft.Json.Schema.JsonSchemaGenerator jsonSchemaGenerator = new Newtonsoft.Json.Schema.JsonSchemaGenerator();
Newtonsoft.Json.Schema.JsonSchema jsonSchema = jsonSchemaGenerator.Generate(type);
}
This results in exception on line 136 of Enumutils.cs file.

EnumValues<ulong> enumValues = EnumUtils.GetNamesAndValues<ulong>(type); 

File JsonSchemaGenerator.cs line 314 has hard coded type ulong. Since the enum is actually a int based one - we should not try to convery it to ulong, uint64

Can you please help fix this?

Coordinator
Oct 3, 2009 at 12:49 AM

Fixed. Source code checked into CodePlex.

Oct 5, 2009 at 11:19 AM

Thank you. I have started using this version.