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

Refactor GetCommandHandler to not use dynamic #1268

Merged

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Apr 21, 2020

Refactor GetCommandHandler to not use dynamic.

This includes a test change that was needed because a PowerShell type didn't serialize correctly.

cc @corbob

@TylerLeonhardt TylerLeonhardt requested a review from rjmholt as a code owner April 21, 2020 22:28
commandList.Add(new PSCommandMessage
{
Name = command.Name,
ModuleName = command.ModuleName,
Parameters = command.Parameters,
ParameterSets = command.ParameterSets,
DefaultParameterSet = command.DefaultParameterSet
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the story on needing the for-loop instead of this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

DefaultParameterSet's might only exist on CmdletInfo and FunctionInfo.. so I could special case those types... but there are a lot of *Info's

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we're probably mostly going to deal with those types, I think that would make sense as an optimisation

Copy link
Member Author

Choose a reason for hiding this comment

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

added a switch but still kept the loop for everything else (which atm is just ExternalScript).

// Some info objects have a quicker way to get the DefaultParameterSet. These
// are also the most likely to show up so win-win.
string defaultParameterSet = null;
switch (command)
Copy link
Member Author

Choose a reason for hiding this comment

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

I just wanna use the new pattern matching switch but it says it's still "preview" 😭

@TylerLeonhardt
Copy link
Member Author

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 2
           

Complexity increasing per file
==============================
- src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetCommandHandler.cs  3
         

See the complete overview on Codacy

// Some info objects have a quicker way to get the DefaultParameterSet. These
// are also the most likely to show up so win-win.
string defaultParameterSet = null;
switch (command)
Copy link
Member Author

Choose a reason for hiding this comment

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

// Some info objects have a quicker way to get the DefaultParameterSet. These
// are also the most likely to show up so win-win.
string defaultParameterSet = null;
switch (command)
Copy link
Member Author

Choose a reason for hiding this comment

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

@TylerLeonhardt TylerLeonhardt merged commit fc1a95a into PowerShell:master Apr 23, 2020
@TylerLeonhardt TylerLeonhardt deleted the refactor-getcommand-a-bit branch April 23, 2020 20:51
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