Skip to content

Conversation

@ChristosMaragkos
Copy link

This is in regards to issue #1314 in the main repository, which has not yet been migrated.

This PR introduces the ability to mark a CommandOption as Deprecated, marking it as obsolete and subject to removal. In this first iteration of my implementation, developers can deprecate CommandOptions simply by specifying a deprecation message in the CommandOptionAttribute ctor, like so:

[CommandOption("-d|--deprecated <VALUE>", isRequired: true, deprecationMessage: "This option is deprecated. Please use <...>")]
public string? Deprecated { get; set; }

Deprecated options are parsed and consumed properly, while also printing their deprecation message as a warning to the console.
A unit test is also included, which I (successfully) ran locally. It can be found in CommandOptionAttributeTests.Deprecation.cs.

Copy link
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should go the route of using the built-in ObsoleteAttribute here.

@ChristosMaragkos
Copy link
Author

I'm working on it. The semantics this provides are much cleaner compared to an optional ctor parameter.
I'll probably have a revision ready before long.

@ChristosMaragkos
Copy link
Author

ChristosMaragkos commented Dec 3, 2025

This second iteration simply checks for the existence of ObsoleteAttribute on the backing property of the given CommandOption. The syntax is this:

[CommandOption("-d|--deprecated <VALUE>"]
[Obsolete("This option is deprecated. Please use <...>")]
public string? Deprecated { get; set; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants