ushort and short not supported
See original GitHub issueclass Options
{
[Option('p', "port", Required = false, HelpText = "port number")]
public int Port { get;set; }
}
If i change the type of Port to ushort or short I get an error when starting the program:
“ERROR(S): Error setting value to option ‘p, port’: Check if Option or Value attribute values are set properly for the given type.”
Expected behavior:
- clear error message that the type is not supported
- support the types ushort and short
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
What is the difference between a short and ushort in C#? - ...
short can be any value from -32768 to 32767 , whereas ushort can be from 0 to 65535 . They have the same...
Read more >C# short and ushort Types
Understand the short and ushort number types. These types use 16 bits to represent a number.
Read more >UShort Data Type - Visual Basic
Because UShort is an unsigned type, it cannot represent a negative number. If you use the unary minus ( - ) operator on...
Read more >ushorttoint
This function converts short values to integer values by treating the input short as an "unsigned short," i.e. a short in the range...
Read more >unsigned data types not supported
Im get System.NotSupportedException when i try map an ushort (or uint) column. Short sample: create table x( f number(5) )
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Default
is object and need to be casted. Parser fail when trying to cast object value to short because Impossible cast from object to short More cast detailsFor decimal values, it can not be casted like
decimal type is not a valid Attribute Parameter (c# language constraint).
Ok, I found it:
The error seems to be that I set Default to a value not of type string or uint. An explicit cast (ushort)5001 is necessary. It would be helpful if the error message on the terminal would not say:
Error setting value to option 'port': Check if Option or Value attribute values are set properly for the given type.
but more something like:
...: Expected type 'ushort', DefaultValue type 'int'
Which by the way could easily be solved, but I understand that since even dotnet needs a cast, it is more a question of if it should be done like this or not.
Maybe the parser could have an option: strict. If that is set to false the int would be converted (use Convert class from dotnet) otherwise the error message should appear.