InvalidCastException is thrown when an underlying type of Enum cannot be casted to Int32.
AdomasBekeras opened this issue · 1 comments
AdomasBekeras commented
InvalidCastException is thrown when an underlying type of Enum cannot be casted to Int32.
Stack trace:
at MarkdownWikiGenerator.MarkdownableType.<ToString>b__18_27(String x) in ...\MarkdownGenerator\MarkdownGenerator.cs:line 186
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.OrderedEnumerable1.<GetEnumerator>d__1.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at MarkdownWikiGenerator.MarkdownableType.ToString() in ...\MarkdownGenerator.cs:line 185
at MarkdownWikiGenerator.Program.Main(String[] args) in ...\MarkdownGenerator\Program.cs:line 55
How to reproduce the issue:
Create this enum and try to use the MarkdownGenerator on it.
namespace Test
{
public enum test : short
{
test =0,
test2
}
}
This can be fixed by checking the exact underlying type of the Enum and converting to it instead of always casting to Int32 with:
(Convert.ChangeType(Enum.Parse(type, x), Enum.GetUnderlyingType(type)))
AdomasBekeras commented
Should be fixed in #11