commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Customizable type convesions

Open Ttxman opened this issue 2 years ago • 2 comments

I was searching for a way to use my own custom types to be parsed from arguments. For extended set of "primitive" types, Commandlineparser already uses System.ComponentModel based type conversion. So I just added this same conversion as fallback when creating by string only constructor fails.

With this you can decorate class with TypeConverterAttribute or register attribute programatically to type descriptor TypeDescriptor.AddAttributes(.., new TypeConverterAttribute(...))); and all other ways you can register conversion provider and you will get the custom types parsed from commandline attributes.

Ttxman avatar Mar 09 '22 01:03 Ttxman

can you add any tests that are relevant?

ericnewton76 avatar May 12 '22 18:05 ericnewton76

Sorry for the long delay, I just have too much work :/ I have added simulated tests around the usecase I needed: NET6 DateOnly type as commandline parameter.

Ttxman avatar Jul 03 '22 15:07 Ttxman

Dead thread and somewhat pointless implementation with the NET7+ IParsable static interfaces..

Ttxman avatar Feb 16 '24 17:02 Ttxman