Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete APIs for 3.0 #335

Merged
merged 4 commits into from
Feb 9, 2020

Conversation

mattnischan
Copy link
Contributor

Addresses #251

Wasn't completely sure how best to deal with the doc changes or the additional exception in the subcommand convention, so let me know if stuff needs to change there.

@natemcmaster
Copy link
Owner

Thanks for taking on this task, @mattnischan! Have you had a chance to look into the test failures? Looks like there are 16 failures: https://dev.azure.com/natemcmaster/github/_build/results?buildId=765&view=ms.vss-test-web.build-test-results-tab

@natemcmaster natemcmaster linked an issue Feb 7, 2020 that may be closed by this pull request
@mattnischan
Copy link
Contributor Author

Something very strange is going on locally with my build. I had all the build errors cleared when I pushed, and tests were working, but checking again now I have a number of new build errors VS hadn't surfaced before.

Let me do some digging and see if I can resolve the issues.

@mattnischan
Copy link
Contributor Author

@natemcmaster - I think this looks OK now. Got the unit tests squared away and ended up adding an exception specifically for subcommands with no Command attribute. Added a test for that as well.

Hopefully that is capturing the correct intent behind the Subcommand/Command API change.

Copy link
Owner

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

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

Thanks again for taking some time on this. It’s actually my intent to keep the current behavior as much as possible. Can you make a few changes?

var commandAttribute = typeof(TSubCommand).GetTypeInfo().GetCustomAttributes(typeof(CommandAttribute)).FirstOrDefault() as CommandAttribute;
if(commandAttribute == null)
{
throw new CommandAttributeMissingException(typeof(TSubCommand));
Copy link
Owner

Choose a reason for hiding this comment

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

This isn’t a behavior I think we should change. The Command attribute is currently optional for subcommand types. Can you find a way to remove the obsolete API without this? I believe it should work if this method is changed to...

context.Application.Command<TSubCommand>(null!, subcommand.Configure);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a problem at all. I misunderstood #139 to mean that [Command] would now be required. The subcommand's Configure() only set up the Name field, which has been removed, so I removed that method also. Looks like passing null to both works just fine (there are checks in the code to handle those cases, seems).

@@ -111,6 +111,7 @@ public void ItDoesNotInitalizeClassUnlessNecessary()
Assert.Same(app, parseResult.SelectedCommand);
}

[Command]
Copy link
Owner

Choose a reason for hiding this comment

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

Can you undo all the places this had to be added? I’d like to ensure we maintain backwards compatibility as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed where added.

…nds. Added test for subcommand naming via the Command attribute.
Copy link
Owner

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for updating and thanks for the contribution! I'll put your name in the changelog and release notes to thank you for the work :)

@natemcmaster natemcmaster merged commit dba5ef4 into natemcmaster:master Feb 9, 2020
@natemcmaster natemcmaster linked an issue Feb 9, 2020 that may be closed by this pull request
@mattnischan
Copy link
Contributor Author

@natemcmaster My pleasure! Thank you so much.

@natemcmaster natemcmaster added this to the 3.0 milestone Feb 11, 2020
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.

Remove obsolete OnExecute APIs 3.0: Remove obsolete API
2 participants