Skip to content

Add OutputType attribute to various commands - #16962

Merged
Dongbo Wang (daxian-dbw) merged 3 commits into
PowerShell:masterfrom
MartinGC94:AddMissingOutputTypeAttributes
Mar 24, 2022
Merged

Add OutputType attribute to various commands#16962
Dongbo Wang (daxian-dbw) merged 3 commits into
PowerShell:masterfrom
MartinGC94:AddMissingOutputTypeAttributes

Conversation

@MartinGC94

@MartinGC94 MartinGC94 commented Mar 6, 2022

Copy link
Copy Markdown
Contributor

PR Summary

Fixes #15905

Adds the OutputType attribute with a fitting type to the following commands:

  • Rename-Computer (RenameComputerChangeInfo)
  • Get-TimeZone (TimeZoneInfo)
  • Set-TimeZone (TimeZoneInfo)
  • Invoke-WebRequest (BasicHtmlWebResponseObject)
  • ConvertTo-Json (string)
  • ConvertTo-Html (string)
  • Test-Json (bool)
  • New-Variable (PSVariable)
  • Pop-Location (PathInfo when used in following providers: Certificate, FileSystem, Registry)
  • Push-Location (PathInfo when used in following provider: Registry)
  • Resolve-Path (String and PathInfo when used in the following provider: Registry)
  • Enable-WSManCredSSP (XmlElement)
  • Get-WSManCredSSP (string)
  • Invoke-WSManAction (XmlElement)
  • New-WSManSessionOption (SessionOption)
  • Test-WWMan (XmlElement)
  • Set-WSManQuickConfig (string)
  • Get-WSManInstance (XmlElement)
  • Set-WSManInstance (XmlElement)
  • New-WSManInstance (XmlElement)
  • TabExpansion2 (CommandCompletion)

I assume I don't need tests for adding this attribute, if that assumption is wrong then please tell me how you would like to see those tests.

PR Context

PR Checklist

@iSazonov

Ilya (iSazonov) commented Mar 9, 2022

Copy link
Copy Markdown
Collaborator

I assume I don't need tests for adding this attribute, if that assumption is wrong then please tell me how you would like to see those tests.

I'd prefer to have such tests. Perhaps it would be better to add tests for existent annotations and only then continue with the PR.

Not related for the PR: perhaps you could have an interest to grab https://github.com/iSazonov/PowerShell/tree/outputtype-parameterset-inference

@MartinGC94

MartinGC94 commented Mar 9, 2022

Copy link
Copy Markdown
Contributor Author

I don't think any other commands include tests for the different attributes and parameter attributes they have so it seems like overkill to me. If you insist on them getting added, I still need to know how to write those tests, I don't know how to properly test for attributes. I mean I could use tabexpansion2 to test for completions but surely there's a better way?

Not related for the PR: perhaps you could have an interest to grab https://github.com/iSazonov/PowerShell/tree/outputtype-parameterset-inference

I have thought about that feature but I suspect it's going to be a lot of work and if I was going to work on another big feature in the near future I would aim for something more important to me like pseudobinding for splatting hashtables. For now I think I'll take a bit of a break from new big PRs so mine and the other 90+ open PRs can actually get merged without too many merge conflicts.

GitHub
PowerShell for every system! Contribute to iSazonov/PowerShell development by creating an account on GitHub.

@iSazonov

Copy link
Copy Markdown
Collaborator

I don't think any other commands include tests for the different attributes and parameter attributes they have so it seems like overkill to me. If you insist on them getting added, I still need to know how to write those tests, I don't know how to properly test for attributes. I mean I could use tabexpansion2 to test for completions but surely there's a better way?

I can not insist :-) I say ideally if we have a code the code must be fully covered by tests.
I think it makes no sense to have functional tests for every cmdlet since code is in Engine and it is the same code and enough to have one functional test for every code path. (It is not huge work to cover the code by tests.)
But we could generate by a script compatibility tests (like DefaultCommands.Tests.ps1) so that if somebody changed output type of a cmdlet we could see this. The tests could read output type attributes from in-box cmdlets and compare its with etalon values.

I have thought about that feature but I suspect it's going to be a lot of work and if I was going to work on another big feature in the near future I would aim for something more important to me like pseudobinding for splatting hashtables. For now I think I'll take a bit of a break from new big PRs so mine and the other 90+ open PRs can actually get merged without too many merge conflicts.

I stopped the work because of the same reason - no code reviewers. But if you will grab my code (it is small) in near future I can review (and merge if we will have great tests).

@ghost ghost added the Review - Needed The PR is being reviewed label Mar 18, 2022
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Comment thread src/Microsoft.WSMan.Management/WSManInstance.cs
@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Review - Needed The PR is being reviewed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Mar 23, 2022
@pull-request-quantifier-deprecated

Copy link
Copy Markdown

This PR has 24 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +24 -0
Percentile : 9.6%

Total files changed: 18

Change summary by file extension:
.cs : +24 -0

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detetcted.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 5e6e7ca into PowerShell:master Mar 24, 2022
@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Mar 24, 2022
@ghost

Copy link
Copy Markdown

🎉v7.3.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log Extra Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoke-WebRequest is not annotated with OutputTypeAttribute

3 participants