Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

Fix #862. Properties with required modifier should be required.#863

Open
Orace wants to merge 3 commits intocommandlineparser:mastercommandlineparser/commandline:masterfrom
Orace:Issue862Orace/commandline:Issue862Copy head branch name to clipboard
Open

Fix #862. Properties with required modifier should be required.#863
Orace wants to merge 3 commits intocommandlineparser:mastercommandlineparser/commandline:masterfrom
Orace:Issue862Orace/commandline:Issue862Copy head branch name to clipboard

Conversation

@Orace
Copy link

@Orace Orace commented Dec 12, 2022

Fix for #862

@Orace Orace changed the title Issue862 Fix #862. Properties with required modifier should be required. Dec 12, 2022
private class Options
{
[Option("cols")]
public required int Cols { get; set; }

Choose a reason for hiding this comment

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

What if you have a required modifier and [Option(Required = false)]? I would say, it should throw because of conflicting settings. Please add test for such case

Copy link
Author

@Orace Orace Dec 13, 2022

Choose a reason for hiding this comment

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

This is not a trivia 🤔
So I moved the discussion on #862 thread, here

Comment on lines +118 to +122
#if NET7_0_OR_GREATER
var isRequired = attrs.OfType<RequiredMemberAttribute>().Any();
#else
var isRequired = false;
#endif

Choose a reason for hiding this comment

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

Suggested change
#if NET7_0_OR_GREATER
var isRequired = attrs.OfType<RequiredMemberAttribute>().Any();
#else
var isRequired = false;
#endif
var isRequired = false;
#if NET7_0_OR_GREATER
isRequired = attrs.OfType<RequiredMemberAttribute>().Any();
#endif

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.