Skip to content

Conversation

@Ttxman
Copy link

@Ttxman Ttxman commented Mar 9, 2022

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.

…y type instead of limiting it only to internaly extended primitive types
@ericnewton76
Copy link
Member

can you add any tests that are relevant?

@Ttxman
Copy link
Author

Ttxman commented Jul 3, 2022

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
Copy link
Author

Ttxman commented Feb 16, 2024

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

@Ttxman Ttxman closed this Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants