Home Dashboard Directory Help
Search

Cast to enum error message should display the numeric values too by Derp McDerp


Status: 

Active


1
0
Sign in
to vote
Type: Suggestion
ID: 808600
Opened: 11/14/2013 1:41:14 PM
Access Restriction: Public
0
Workaround(s)
view

Description

[System.TypeCode]'adsf'

Returns an error message with the enum values:

Empty, Object, DBNull, Boolean, Char, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, DateTime, String

It would be better if the strings were annotated with the numeric values, e.g. If the enum doesn't have the [Flags] attribute:

Empty(0), Object(1), DBNull(2), Boolean(3), Char(4), SByte(5), Byte(6), Int16(7), UInt16(8), Int32(9), UInt32(10), Int64(11), UInt64(12), Single(13), Double(14), Decimal(15), DateTime(16), String(18)

But if it does have the [Flags] attribute, the enum should be in hex:

[System.Management.Automation.PSMemberTypes]'asdf'

AliasProperty(0x1), CodeProperty(0x2), Property(0x4), NoteProperty(0x8), ScriptProperty(0x10), Properties(0x1f), PropertySet(0x20), Method(0x40), CodeMethod(0x80), ScriptMethod(0x100), Methods(0x1c0), ParameterizedProperty(0x200), MemberSet(0x400), Event(0x800), Dynamic(0x1000), All(0x1fff)
Details
Sign in to post a comment.
Sign in to post a workaround.