From 98da6f0c755a3d907a9936a871c494d902e929d3 Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Thu, 24 Jan 2019 13:20:51 -0500 Subject: [PATCH 01/12] docs: Made git work for all package managers --- docs/git/basics.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/git/basics.md b/docs/git/basics.md index 049f3b3b772..cb8db460b61 100644 --- a/docs/git/basics.md +++ b/docs/git/basics.md @@ -24,11 +24,7 @@ During the installation process, choose these recommended settings: #### Linux -Install by using the package manager: - -```sh -sudo apt-get install git -``` +Install by using the package manager on your system. A list of all the package managers and commands can be found [here][linux-git-dl] Interactive tutorials ---------------------- @@ -87,3 +83,4 @@ git config --global url.git@github.com:.insteadOf https://github.com/ [SSH key]: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key [token]: https://help.github.com/articles/creating-an-access-token-for-command-line-use/ [manager]: https://github.com/Microsoft/Git-Credential-Manager-for-Windows +[linux-git-dl]: https://git-scm.com/download/linux From 2b52e8194caf935597691222f0852b9a3de3097d Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 24 Jan 2019 11:45:08 -0800 Subject: [PATCH 02/12] Use semantics line break and add the ending period. --- docs/git/basics.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/git/basics.md b/docs/git/basics.md index cb8db460b61..79a92f742c2 100644 --- a/docs/git/basics.md +++ b/docs/git/basics.md @@ -24,7 +24,8 @@ During the installation process, choose these recommended settings: #### Linux -Install by using the package manager on your system. A list of all the package managers and commands can be found [here][linux-git-dl] +Install by using the package manager on your system. +A list of all the package managers and commands can be found [here][linux-git-dl]. Interactive tutorials ---------------------- From 9a74b691472e991dbff0f7cc84737b0736902bd2 Mon Sep 17 00:00:00 2001 From: RDIL Date: Sat, 9 Feb 2019 10:30:07 -0500 Subject: [PATCH 03/12] documentation cleanup --- docs/DOCSMIGRATION.md | 2 +- docs/building/internals.md | 2 +- .../visual-studio-simple-example.md | 6 +++--- docs/git/basics.md | 21 +++++++------------ 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/docs/DOCSMIGRATION.md b/docs/DOCSMIGRATION.md index e3aef3ad111..43c1b23dfe4 100644 --- a/docs/DOCSMIGRATION.md +++ b/docs/DOCSMIGRATION.md @@ -2,7 +2,7 @@ The docs folder in this repo contains a lot of documentation about the PowerShell source code and build environment. It also has contained documentation about installing and using PowerShell. -That documentation really belongs in the [PowerShell/PowerShell-Docs](https://github.com/PowerShell/PowerShell-Docs) repo. +That documentation belongs in the [PowerShell/PowerShell-Docs](https://github.com/PowerShell/PowerShell-Docs) repo. We are in the process of migrating the user-focused articles to the docs repo. This file records which files have been migrated. diff --git a/docs/building/internals.md b/docs/building/internals.md index 1ed23dc85b5..e6d800167b5 100644 --- a/docs/building/internals.md +++ b/docs/building/internals.md @@ -143,7 +143,7 @@ Be sure to build and test for all supported architectures: `x86`, `x64`, `x64_ar The `x64_arm` and `x64_arm64` architectures mean that the host system needs to be x64 to cross-compile to ARM. When building for multiple architectures, be sure to use the `-clean` switch as cmake will cache the previous run and the wrong compiler will be used to generate the subsequent architectures. -After that, the binary `pwrshplugin.dll`, its PDB file, and `powershell.core.instrumentation.dll` will be placed under 'src\powershell-win-core'. +After that, the binary `pwrshplugin.dll`, its PDB file, and `powershell.core.instrumentation.dll` will be placed under `src\powershell-win-core`. To create a new NuGet package for `pwrshplugin.dll`, first you need to get the `psrp.windows.nuspec` from an existing `psrp.windows` package. You can find it at `~/.nuget/packages/psrp.windows` on your windows machine if you have recently built PowerShell on it. diff --git a/docs/cmdlet-example/visual-studio-simple-example.md b/docs/cmdlet-example/visual-studio-simple-example.md index 6f91d064a3e..d027bcdf0f8 100644 --- a/docs/cmdlet-example/visual-studio-simple-example.md +++ b/docs/cmdlet-example/visual-studio-simple-example.md @@ -30,7 +30,7 @@ Add another package source with name `powershell-core` and source `https://power ![Step4](./Images/Step4.png) 1. Add the code of cmdlet: - ```CSharp + ```csharp using System.Management.Automation; // PowerShell namespace. namespace SendGreeting @@ -90,7 +90,7 @@ It should find `PowerShellStandard.Library` package, select it and it will show ![StdImage3](./Images/Std3.png) 1. Add the code of cmdlet: - ```CSharp + ```csharp using System.Management.Automation; // PowerShell namespace. namespace SendGreeting @@ -128,4 +128,4 @@ It should find `PowerShellStandard.Library` package, select it and it will show On PowerShell Core on Linux: ![StdImage62](./Images/Std62.png) On Windows PowerShell on Windows (this requires [.NET Framework 4.7.1](https://github.com/Microsoft/dotnet-framework-early-access/blob/master/instructions.md)): -![StdImage63](./Images/Std63.png) \ No newline at end of file +![StdImage63](./Images/Std63.png) diff --git a/docs/git/basics.md b/docs/git/basics.md index 79a92f742c2..a8a9bacf046 100644 --- a/docs/git/basics.md +++ b/docs/git/basics.md @@ -1,14 +1,12 @@ -Getting started with Git -======================== +# Getting started with Git We are using Git version 2.9.0, but any recent version should be good. It's recommended to learn the `git` command-line tool for full cross-platform experience and a deeper understanding of Git itself. -Install ---------- +## Install -#### Windows +### Windows Install [Git for Windows][]. @@ -22,13 +20,12 @@ During the installation process, choose these recommended settings: [Git for Windows]: https://git-scm.com/download/win -#### Linux +### Linux Install by using the package manager on your system. A list of all the package managers and commands can be found [here][linux-git-dl]. -Interactive tutorials ----------------------- +### Interactive tutorials There are (too) many Git tutorials on the internet. Here we post references to our favorites. @@ -55,11 +52,10 @@ learn Git in couple hours. After finishing 50+ real-world scenarios you will have a pretty good idea about what and when you can do with Git. +## Authentication -Authentication --------------- +### Windows -#### Windows On Windows, the best way to use Git securely is [Git Credential Manager for Windows][manager]. It's included in the official Git installer for Windows. @@ -76,11 +72,10 @@ git config --global credential.helper store Alternatively, you can use [SSH key][]. In this case, you may want to use git-ssh even for HTTPS Git URLs. -``` +```none git config --global url.git@github.com:.insteadOf https://github.com/ ``` - [SSH key]: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key [token]: https://help.github.com/articles/creating-an-access-token-for-command-line-use/ [manager]: https://github.com/Microsoft/Git-Credential-Manager-for-Windows From c2b56c6ba3165a6b1247ef7617974877d4e2256e Mon Sep 17 00:00:00 2001 From: RDIL Date: Sat, 9 Feb 2019 10:51:30 -0500 Subject: [PATCH 04/12] more cleanup! --- docs/git/README.md | 32 +++++++++++++--------------- docs/host-powershell/README.md | 3 ++- docs/maintainers/README.md | 20 ++++++++++------- docs/maintainers/best-practice.md | 4 ++-- docs/maintainers/issue-management.md | 10 ++++----- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/docs/git/README.md b/docs/git/README.md index 3eb29d75c13..1271dbe66dc 100644 --- a/docs/git/README.md +++ b/docs/git/README.md @@ -1,14 +1,12 @@ -Working with PowerShell repository -================================== +# Working with PowerShell repository -#### Get the code for the first time +## Get the code for the first time ```sh -git clone https://github.com/PowerShell/PowerShell.git +git clone https://github.com/PowerShell/PowerShell.git --branch=master ``` -Branches ---------- +## Branches * Don't commit your changes directly to master. It will make the collaborative workflow messy. @@ -19,13 +17,13 @@ Branches You must never EVER destroy other peoples history. You must not rebase commits other people did. Basically, if it doesn't have your sign-off on it, it's off limits: you can't rebase it, because it's not yours." -#### Understand branches +### Understand branches * **master** is the branch with the latest and greatest changes. It could be unstable. * Send your pull requests to **master**. -#### Sync your local repo +### Sync your local repo Use **git rebase** instead of **git merge** and **git pull**, when you're updating your feature-branch. @@ -39,7 +37,7 @@ git fetch --all -p git rebase origin/master ``` -#### More complex scenarios +### More complex scenarios Covering all possible git scenarios is behind the scope of the current document. Git has excellent documentation and lots of materials available online. @@ -48,16 +46,14 @@ We are leaving few links here: [Git pretty flowchart](http://justinhileman.info/article/git-pretty/): what to do, when your local repo became a mess. -[Linus]:http://thread.gmane.org/gmane.comp.video.dri.devel/34739/focus=34744 +[Linus]: http://thread.gmane.org/gmane.comp.video.dri.devel/34739/focus=34744 - -Tags ------- +## Tags If you are looking for the source code for a particular release, you will find it via **tags**. -* `git tag` will show you list of all tags. +* `git tag` will show you list of all tags. * Find the tag that corresponds to the release. * Use `git checkout ` to get this version. @@ -73,31 +69,33 @@ checkout a new branch from this DETACHED HEAD state. git checkout -b vors/hotfix ``` - -Recommended Git configurations -============================== +## Recommended Git configurations We highly recommend these configurations to help deal with whitespace, rebasing, and general use of Git. > Auto-corrects your command when it's sure (`stats` to `status`) + ```sh git config --global help.autoCorrect -1 ``` > Refuses to merge when pulling, and only pushes to branch with same name. + ```sh git config --global pull.ff only git config --global push.default current ``` > Shows shorter commit hashes and always shows reference names in the log. + ```sh git config --global log.abbrevCommit true git config --global log.decorate short ``` > Ignores whitespace changes and uses more information when merging. + ```sh git config --global apply.ignoreWhitespace change git config --global rerere.enabled true diff --git a/docs/host-powershell/README.md b/docs/host-powershell/README.md index 1f14267b2fe..70feb316261 100644 --- a/docs/host-powershell/README.md +++ b/docs/host-powershell/README.md @@ -43,4 +43,5 @@ such as the in-box `powershell.exe` in Nano Server and the Azure DSC host. For such hosting scenarios, the native host needs to bootstrap by calling [`PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext`](https://docs.microsoft.com/dotnet/api/system.management.automation.powershellassemblyloadcontextinitializer.setpowershellassemblyloadcontext). When using this API, the native host can pass in the path to the directory that contains PowerShell assemblies. -A handler will then be registered to the [`Resolving`](https://github.com/dotnet/corefx/blob/d6678e9653defe3cdfff26b2ff62135b6b22c77f/src/System.Runtime.Loader/ref/System.Runtime.Loader.cs#L38) event of the default load context to deal with the loading of assemblies from that directory. +A handler will then be registered to the [`Resolving`](https://github.com/dotnet/corefx/blob/d6678e9653defe3cdfff26b2ff62135b6b22c77f/src/System.Runtime.Loader/ref/System.Runtime.Loader.cs#L38) event of the default load context to deal with +the loading of assemblies from that directory. diff --git a/docs/maintainers/README.md b/docs/maintainers/README.md index d9795795fbe..b5d3bc2f255 100644 --- a/docs/maintainers/README.md +++ b/docs/maintainers/README.md @@ -6,8 +6,8 @@ One of their primary responsibilities is merging pull requests after all require They have [write access](https://help.github.com/articles/repository-permission-levels-for-an-organization/) to the PowerShell repositories which gives them the power to: 1. `git push` to the official PowerShell repository -1. Merge pull requests -1. Assign labels, milestones, and people to [issues](https://guides.github.com/features/issues/) +1. Merge [pull requests](https://www.thinkful.com/learn/github-pull-request-tutorial/) +1. Assign labels, milestones, and people to [issues](https://guides.github.com/features/issues/) and [pull requests](https://www.thinkful.com/learn/github-pull-request-tutorial/) ## Table of Contents @@ -20,18 +20,22 @@ They have [write access](https://help.github.com/articles/repository-permission- ## Current Repository Maintainers -- Dongbo Wang ([daxian-dbw](https://github.com/daxian-dbw)) -- Travis Plunk ([TravisEz13](https://github.com/TravisEz13)) + + - Aditya Patwardhan ([adityapatwardhan](https://github.com/adityapatwardhan)) -- Ilya Sazonov ([iSazonov](https://github.com/iSazonov)) - Andrew Menagarishvili ([anmenaga](https://github.com/anmenaga)) +- Dongbo Wang ([daxian-dbw](https://github.com/daxian-dbw)) +- Ilya Sazonov ([iSazonov](https://github.com/iSazonov)) +- Travis Plunk ([TravisEz13](https://github.com/TravisEz13)) ## Former Repository Maintainers + + +- Andy Schwartzmeyer ([andschwa](https://github.com/andschwa)) - Jason Shirk ([lzybkr](https://github.com/lzybkr)) -- Sergei Vorobev ([vors](https://github.com/vors)) - Mike Richmond ([mirichmo](https://github.com/mirichmo)) -- Andy Schwartzmeyer ([andschwa](https://github.com/andschwa)) +- Sergei Vorobev ([vors](https://github.com/vors)) ## Repository Maintainer Responsibilities @@ -39,7 +43,7 @@ Repository Maintainers enable rapid contributions while maintaining a high level If you are a Repository Maintainer, you: -1. **MUST** ensure that each contributor has signed a valid Contributor License Agreement (CLA) +1. **MUST** ensure that each contributor has signed a valid Microsoft Contributor License Agreement (CLA) 1. **MUST** verify compliance with any third party code license terms (e.g., requiring attribution, etc.) if the contribution contains third party code. 1. **MUST** make sure that [any change requiring approval from the PowerShell Committee](../community/governance.md#changes-that-require-an-rfc) has gone through the proper [RFC][RFC-repo] or approval process 1. **MUST** validate that code reviews have been conducted before merging a pull request when no code is written diff --git a/docs/maintainers/best-practice.md b/docs/maintainers/best-practice.md index 08be16fa42a..47cc304cf61 100644 --- a/docs/maintainers/best-practice.md +++ b/docs/maintainers/best-practice.md @@ -8,7 +8,7 @@ ## Review PRs - Ask the author to reword the PR title based on guidelines in [Contributing](../../.github/CONTRIBUTING.md). -- Ask the author to apply `[Feature]` tag to trigger full test builds if it's necessary. +- Ask the author to apply `[feature]` tag to trigger full test builds if it's necessary. - Label the PR with `Breaking-Change`, `Documentation Needed` and `Area-XXX` as appropriate. - When labelling a PR with `Review-Committee`, leave a detailed comment to summarize the issue you want the committee to look into. It's recommended to include examples to explain/demonstrate behaviors. @@ -21,7 +21,7 @@ - Use `Create a merge commit` for feature-work PRs **only if** the commit history of the PR is reasonably clean. After using this option, GitHub will make it your default option for merging a PR. - Do remember to change the default back to `Squash and merge`. + Do remember to change the default back to `Squash and merge` as it will be useful next time. ![Merge Commit Example](./Images/merge-commit.png)    ![Merge Confirm Example](./Images/merge-commit-confirm.png) diff --git a/docs/maintainers/issue-management.md b/docs/maintainers/issue-management.md index 7b416d6359f..aa4757a0123 100644 --- a/docs/maintainers/issue-management.md +++ b/docs/maintainers/issue-management.md @@ -4,7 +4,7 @@ If you believe that there is a security vulnerability in PowerShell Core, it **must** be reported to [secure@microsoft.com](https://technet.microsoft.com/security/ff852094.aspx) to allow for [Coordinated Vulnerability Disclosure](https://technet.microsoft.com/security/dn467923). -**Only** file an issue, if secure@microsoft.com has confirmed filing an issue is appropriate. +**Only** file an issue, if [secure@microsoft.com][https://technet.microsoft.com/security/ff852094.aspx] has confirmed filing an issue is appropriate. ## Long-living issue labels @@ -53,15 +53,15 @@ These labels describe what feature area of PowerShell that an issue affects: * `Area-HelpSystem`: anything related to the help infrastructure and formatting of help * `Area-Intellisense`: tab completion * `Area-Language`: parser, language semantics -* `Area-OMI`: omi +* `Area-OMI`: OMI * `Area-PackageManagement`: PackageManagement related issues * `Area-Performance`: a performance issue * `Area-Portability`: anything affecting script portability * `Area-PowerShellGet`: PowerShellGet related issues -* `Area-Providers`: PowerShell providers like FileSystem, Certificates, Registry, etc... +* `Area-Providers`: PowerShell providers such as FileSystem, Certificates, Registry, etc... * `Area-PSReadline`: PSReadline related issues * `Area-Remoting`: PSRP issues with any transport layer -* `Area-Security`: security related areas like [JEA](https://github.com/powershell/JEA) +* `Area-Security`: security related areas such as [JEA](https://github.com/powershell/JEA) * `Area-SideBySide`: side by side support * `Area-Test`: issues in a test or in test infrastructure @@ -80,7 +80,7 @@ The following labels are used on PRs: * `Review - Needed` : The PR is being reviewed. Please see [Pull Request - Code Review](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---code-review) * `Review - Waiting on Author` : The PR was reviewed by the team and requires changes or comments from the author before being accepted. -* `Review - Abandoned` : The PR was not updated for significant number of days (the exact number could vary over time). +* `Review - Abandoned` : The PR was not updated for a significant number of days (the exact number could vary over time). Maintainers should look into such PRs and re-evaluate them. * `Review - Committee` : The PR/Issue needs a review from [powershell-committee](../community/governance.md#powershell-committee) From c2da62a00b5aa0ba0e89f80c8700e32ed3bc92dc Mon Sep 17 00:00:00 2001 From: RDIL Date: Sat, 9 Feb 2019 10:59:06 -0500 Subject: [PATCH 05/12] markdownlint issues fixed --- docs/community/governance.md | 15 ++++++++--- docs/debugging/README.md | 24 ++++++----------- docs/dev-process/breaking-change-contract.md | 27 ++++++++++++-------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/docs/community/governance.md b/docs/community/governance.md index 98c7fcd65e1..de27747244c 100644 --- a/docs/community/governance.md +++ b/docs/community/governance.md @@ -4,15 +4,23 @@ * [**PowerShell Committee**](#powershell-committee): A committee of project owners who are responsible for design decisions, approving [RFCs][RFC-repo], and approving new maintainers/committee members * [**Repository maintainer**](#repository-maintainers): An individual responsible for merging pull requests (PRs) into `master` when all requirements are met (code review, tests, docs, and RFC approval as applicable). + Repository Maintainers are the only people with write permissions for the `master` branch. + * [**Area experts**](#area-experts): People who are experts for specific components (e.g. PSReadline, the parser) or technologies (e.g. security, performance). + Area experts are responsible for code reviews, issue triage, and providing their expertise to others. + * **Corporation**: The Corporation owns the PowerShell repository and, under extreme circumstances, reserves the right to dissolve or reform the PowerShell Committee, the Project Leads, and the Corporate Maintainer. + The Corporation for PowerShell is Microsoft. + * **Corporate Maintainer**: The Corporate Maintainer is an entity, person or set of persons, with the ability to veto decisions made by the PowerShell Committee or any other collaborators on the PowerShell project. + This veto power will be used with restraint since it is intended that the community drive the project. The Corporate Maintainer is determined by the Corporation both initially and in continuation. The initial Corporate Maintainer for PowerShell is Jeffrey Snover ([jpsnover](https://github.com/jpsnover)). + * [**RFC process**][RFC-repo]: The "review-for-comment" (RFC) process whereby design decisions get made. ## PowerShell Committee @@ -56,8 +64,7 @@ If any Committee Members feels like this behavior is large enough to warrant an As a PowerShell Committee Member: -1. **DO** reply to issues and pull requests with design opinions -(this could include offering support for good work or exciting new features) +1. **DO** reply to issues and pull requests with design opinions (this could include offering support for good work or exciting new features) 1. **DO** encourage healthy discussion about the direction of PowerShell 1. **DO** raise "red flags" on PRs that haven't followed the proper RFC process when applicable 1. **DO** contribute to documentation and best practices @@ -68,6 +75,7 @@ As a PowerShell Committee Member: 1. **DON'T** constantly raise "red flags" for unimportant or minor problems to the point that the progress of the project is being slowed 1. **DON'T** offer up your opinions as the absolute opinion of the PowerShell Committee. + Members are encouraged to share their opinions, but they should be presented as such. ### PowerShell Committee Membership @@ -108,8 +116,7 @@ If you are an Area Expert: 1. **DO** assign the [correct labels][issue-process] 1. **DO** assign yourself to issues labeled with your area of expertise 1. **DO** code reviews for issues where you're assigned or in your areas of expertise. -1. **DO** reply to new issues and pull requests that are related to your area of expertise -(while reviewing PRs, leave your comment even if everything looks good - a simple "Looks good to me" or "LGTM" will suffice, so that we know someone has already taken a look at it). +1. **DO** reply to new issues and pull requests that are related to your area of expertise (while reviewing PRs, leave your comment even if everything looks good - a simple "LGTM" will suffice, so that we know someone has taken a look at it). 1. **DO** make sure contributors are following the [contributor guidelines](../../.github/CONTRIBUTING.md). 1. **DO** ask people to resend a pull request, if it [doesn't target `master`](../../.github/CONTRIBUTING.md#lifecycle-of-a-pull-request). 1. **DO** ensure that contributors [write Pester tests][pester] for all new/changed functionality diff --git a/docs/debugging/README.md b/docs/debugging/README.md index 5e7de2b87e7..36107f1ba06 100644 --- a/docs/debugging/README.md +++ b/docs/debugging/README.md @@ -1,5 +1,4 @@ -Visual Studio Code -================== +# Visual Studio Code [Experimental .NET Core Debugging in VS Code][core-debug] enables cross-platform debugging with the [Visual Studio Code][vscode] editor. @@ -48,8 +47,7 @@ careful not to commit such a change.) [OmniSharp]: https://github.com/OmniSharp/omnisharp-vscode [vscclrdebugger]: https://aka.ms/vscclrdebugger -PowerShell -========== +## PowerShell The `Trace-Command` cmdlet can be used to enable tracing of certain PowerShell subsystems. Use `Get-TraceSource` for a list of tracers: @@ -91,8 +89,7 @@ The `-PSHost` specifies the sink, in this case the console host, so we can see the tracing messages. The `-Name` chooses the list of tracers to enable. -LLDB with SOS plug-in -===================== +## LLDB with SOS plug-in The `./tools/debug.sh` script can be used to launch PowerShell inside of LLDB with the SOS plug-in provided by .NET Core. This provides an additional way to @@ -104,14 +101,12 @@ The script is self-documented and contains a link to the [clr-debug]: https://github.com/dotnet/coreclr/blob/master/Documentation/building/debugging-instructions.md#debugging-coreclr-on-linux -corehost -======== +## `corehost` The native executable produced by .NET CLI will produce trace output if launched with `COREHOST_TRACE=1 ./powershell`. -CoreCLR PAL -=========== +## CoreCLR PAL The native code in the CLR has debug channels to selectively output information to the console. These are controlled by the @@ -123,8 +118,7 @@ you will need to narrow your scope. [header]: https://github.com/dotnet/coreclr/blob/release/1.0.0/src/pal/src/include/pal/dbgmsg.h -Debugging .NET Core -=================== +## Debugging .NET Core The .NET Core libraries downloaded from NuGet and shipped with PowerShell are release versions. This means that `PAL_DBG_CHANNELS` will not work with them, @@ -134,16 +128,14 @@ but should prove useful. They are currently written for Linux and are meant only as a shortcut means to debug. -Build and deploy CoreCLR ------------------------- +## Build and deploy CoreCLR * Clone CoreCLR: `git clone -b release/1.0.0 https://github.com/dotnet/coreclr.git` * Follow [building instructions](https://github.com/dotnet/coreclr/blob/release/1.0.0/Documentation/building/linux-instructions.md) * Wait for `./build.sh` to finish * Overwrite PowerShell libraries: `cp bin/Product/Linux.x64.Debug/*{so,dll} /path/to/powershell/` -Build and deploy CoreFX ------------------------ +## Build and deploy CoreFX * Clone CoreFX: `git clone -b release/1.0.0 https://github.com/dotnet/corefx.git` * Follow [building instructions](https://github.com/dotnet/corefx/blob/release/1.0.0/Documentation/building/unix-instructions.md) diff --git a/docs/dev-process/breaking-change-contract.md b/docs/dev-process/breaking-change-contract.md index b9124a58fb4..4ce4c6e2f16 100644 --- a/docs/dev-process/breaking-change-contract.md +++ b/docs/dev-process/breaking-change-contract.md @@ -4,29 +4,33 @@ We have a serious commitment to backwards compatibility with all earlier version Below is a summary of our approach to handing breaking changes including what kinds of things constitute breaking changes, how we categorize them, and how we decide what we're willing to take. -Note that these rules only apply to existing stable features that have shipped in a supported release. New features marked as “in preview” that are still under development may be modified from one preview release to the next. These are not considered breaking changes. +Note that these rules only apply to existing stable features that have shipped in a supported release. New features marked as “in preview” that are still under development may be modified from one preview release to the next. +These are *not* considered breaking changes. To help triage breaking changes, we classify them in to four buckets: 1. Public Contract -2. Reasonable Grey Area -3. Unlikely Grey Area -4. Clearly Non-Public +1. Reasonable Grey Area +1. Unlikely Grey Area +1. Clearly Non-Public ## Bucket 1: Public Contract Any change that is a clear violation of the public contract. -### Unacceptable changes: +### Unacceptable changes + A code change that results in a change to the existing behavior observed for a given input with an API, protocol or the PowerShell language. -+ Renaming or removing a public type, type member, or type parameter; renaming or removing a cmdlet or cmdlet parameter (note: it is possible to rename a cmdlet parameter if a parameter alias is added. This is an acceptable solution for PowerShell scripts but may break .NET code that depends on the name of the original member on the cmdlet object type.) ++ Renaming or removing a public type, type member, or type parameter; renaming or removing a cmdlet or cmdlet parameter (note: it is possible to rename a cmdlet parameter if a parameter alias is added. + +This is an acceptable solution for PowerShell scripts but may break .NET code that depends on the name of the original member on the cmdlet object type.) + + Decreasing the range of accepted values within a given parameter. + Changing the value of a public constant or enum member; changing the type of a cmdlet parameter to a more restrictive type. + Example: A cmdlet with a parameter -p1 that was previously type as [object] cannot be changed to be or a more restrictive type such as [int]. + Making an incompatible change to any protocol without increasing the protocol version number. -### Acceptable changes: +### Acceptable changes + Any existing behavior that results in an error message generally may be changed to provide new functionality. + A new instance field is added to a type (this impacts .NET serialization but not PowerShell serialization and so is considered acceptable.) @@ -44,7 +48,8 @@ Examples: + Change in parsing of input and throwing new errors (even if parsing behavior is not specified in the docs) + Example: a script may be using a JSON parser that is forgiving to minor syntactic errors in the JSON text. Changing that parser to be more rigorous in its processing would result in errors being thrown when no error was generated in the past thus breaking scripts. -Judiciously making changes in these type of features require judgement: how predictable, obvious, consistent was the behavior? In general, a significant external preview of the change would need to be done also possibly requiring an RFC to be created to allow for community input on the proposal. +Judiciously making changes in these type of features require judgement: how predictable, obvious, consistent was the behavior? +In general, a significant external preview of the change would need to be done also possibly requiring an RFC to be created to allow for community input on the proposal. ## Bucket 3: Unlikely Grey Area @@ -68,9 +73,10 @@ Examples: + Changes to internal APIs that break private reflection -It is impossible to evolve a code base without making such changes, so we don't require up-front approval for these, but we will sometimes have to go back and revisit such change if there's too much pain inflicted on the ecosystem through a popular app or library. +It is impossible to evolve a code base without making such changes, so we don't require up-front approval for these, but we will sometimes have to go back and +revisit such change if there's too much pain inflicted on the ecosystem through a popular app or library. -# What This Means for Contributors +## What This Means for Contributors + All bucket 1, 2, and 3 breaking changes require contacting team at @powershell/powershell. + If you're not sure into which bucket a given change falls, contact us as well. @@ -78,4 +84,3 @@ It is impossible to evolve a code base without making such changes, so we don't + If a change is deemed too breaking, we can help identify alternatives such as introducing a new API or cmdlet and obsoleting the old one. Request for clarifications or suggested alterations to this document should be done by opening issues against this document. - From 33d26c2247aa462265fb6efd0970044bfd123f5a Mon Sep 17 00:00:00 2001 From: RDIL Date: Sat, 9 Feb 2019 11:20:38 -0500 Subject: [PATCH 06/12] more cleanup --- docs/dev-process/coding-guidelines.md | 7 ++- docs/dev-process/resx-files.md | 17 ++++---- docs/learning-powershell/README.md | 43 +++++++------------ .../create-powershell-scripts.md | 32 ++++++++------ .../debugging-from-commandline.md | 39 ++++++++--------- .../powershell-beginners-guide.md | 24 ++++++----- .../working-with-powershell-objects.md | 27 ++++++------ .../CodeCoverageAnalysis.md | 2 +- 8 files changed, 92 insertions(+), 99 deletions(-) diff --git a/docs/dev-process/coding-guidelines.md b/docs/dev-process/coding-guidelines.md index 58a4e2f0a7f..11724b79799 100644 --- a/docs/dev-process/coding-guidelines.md +++ b/docs/dev-process/coding-guidelines.md @@ -111,8 +111,7 @@ Some general guidelines: * Avoid creating empty arrays. Instead, reuse the static ones via `Utils.EmptyArray`. -* Avoid unnecessary memory allocation in a loop. - Move the memory allocation outside the loop if possible. +* Avoid unnecessary memory allocation in a loop. Move the memory allocation outside the loop if possible. * Avoid gratuitous exceptions as much as possible. Exception handling can be expensive due to cache misses and page faults when accessing the handling code and data. @@ -152,7 +151,7 @@ such as `password`, `crypto`, `encryption`, `decryption`, `certificate`, `authen When facing a PR with such changes, the reviewers should request a designated security Subject Matter Expert (SME) to review the PR. -Currently, @PaulHigin and @TravisEz13 are our security SMEs. +Currently, [@PaulHigin](https://github.com/PaulHigin) and [@TravisEz13](https://github.com/TravisEz13) are our security SMEs. See [CODEOWNERS](../../.github/CODEOWNERS) for more information about the area experts. ## Best Practices @@ -162,7 +161,7 @@ See [CODEOWNERS](../../.github/CODEOWNERS) for more information about the area e * Avoid a method that is too long and complex. In such case, separate it to multiple methods or even a nested class as you see fit. -* Use `using` statement instead of `try/finally` if the only code in the `finally` block is to call the `Dispose` method. +* Use the `using` statement instead of `try/finally` if the only code in the `finally` block is to call the `Dispose` method. * Use of object initializers (e.g. `new Example { Name = "Name", ID = 1 }`) is encouraged for better readability, but not required. diff --git a/docs/dev-process/resx-files.md b/docs/dev-process/resx-files.md index 61bcfa4277d..ec9eace54fe 100644 --- a/docs/dev-process/resx-files.md +++ b/docs/dev-process/resx-files.md @@ -9,33 +9,32 @@ We are using our own `Start-ResGen` to generate them. Usually it's called as part of the regular build with -``` -PS C:\> Start-PSBuild -ResGen +```powershell +Start-PSBuild -ResGen ``` If you see compilation errors related to resources, try to call `Start-ResGen` explicitly. -``` -PS C:\> Start-ResGen +```powershell +Start-ResGen ``` ## Editing `.resx` files -**Don't edit** `.resx` files from Visual Studio. +**Don't edit** `.resx` files from Visual Studio. It will try to create `.cs` files for you and you will get whole bunch of hard-to-understand errors. -To edit a resource file, use any **plain text editor**. +To edit a resource file, use any **plain text editor**. A resource file is a simple XML file, and it's easy to edit. - ## Convert `.txt` resource files into `.resx` files `dotnet cli` doesn't support embedding old-fashioned `.txt` resource. You can do a one-time conversion of `.txt` resources into `.resx` files with a helper function: -``` +```powershell # example, converting all .txt resources under src\Microsoft.WSMan.Management\resources -PS C:\> Convert-TxtResourceToXml -Path src\Microsoft.WSMan.Management\resources +Convert-TxtResourceToXml -Path src\Microsoft.WSMan.Management\resources ``` `.resx` files would be placed next to `.txt` files. diff --git a/docs/learning-powershell/README.md b/docs/learning-powershell/README.md index da8c4296040..e3daa3e563f 100644 --- a/docs/learning-powershell/README.md +++ b/docs/learning-powershell/README.md @@ -1,5 +1,4 @@ -Learning PowerShell -==== +# Learning PowerShell Whether you're a Developer, a DevOps or an IT Professional, this doc will help you getting started with PowerShell. In this document we'll cover the following: @@ -10,18 +9,16 @@ You won't be a PowerShell guru at the end of reading this material but you will If you have 30 minutes now, let’s try it. - -Installing PowerShell ----- +## Installing PowerShell First you need to set up your computer working environment if you have not done so. Choose the platform below and follow the instructions. At the end of this exercise, you should be able to launch the PowerShell session. - Get PowerShell by installing package - * [PowerShell on Linux][inst-linux] - * [PowerShell on macOS][inst-macos] - * [PowerShell on Windows][inst-win] + * [PowerShell on Linux][inst-linux] + * [PowerShell on macOS][inst-macos] + * [PowerShell on Windows][inst-win] For this tutorial, you do not need to install PowerShell if you are running on Windows. You can launch PowerShell console by pressing Windows key, typing PowerShell, and clicking on Windows PowerShell. @@ -33,8 +30,8 @@ At the end of this exercise, you should be able to launch the PowerShell session [inst-win]: https://docs.microsoft.com/powershell/scripting/setup/installing-powershell-core-on-windows?view=powershell-6 [inst-macos]: https://docs.microsoft.com/powershell/scripting/setup/installing-powershell-core-on-macos?view=powershell-6 -Getting Started with PowerShell ----- +## Getting Started with PowerShell + PowerShell commands follow a Verb-Noun semantic with a set of parameters. It's easy to learn and use PowerShell. For example, `Get-Process` will display all the running processes on your system. @@ -43,8 +40,7 @@ Let's walk through with a few examples from the [PowerShell Beginner's Guide](po Now you have learned the basics of PowerShell. Please continue reading if you want to do some development work in PowerShell. -PowerShell Editor ----- +### PowerShell Editor In this section, you will create a PowerShell script using a text editor. You can use your favorite editor to write scripts. @@ -53,8 +49,7 @@ Click on the following link to create your first PowerShell script. - [Using Visual Studio Code (VS Code)](https://docs.microsoft.com/powershell/scripting/components/vscode/using-vscode?view=powershell-6) -PowerShell Debugger ----- +### PowerShell Debugger Debugging can help you find bugs and fix problems in your PowerShell scripts. Click on the link below to learn more about debugging: @@ -67,21 +62,16 @@ Click on the link below to learn more about debugging: [get-powershell]:../../README.md#get-powershell [build-powershell]:../../README.md#building-the-repository - -PowerShell Testing ----- +### PowerShell Testing We recommend using Pester testing tool which is initiated by the PowerShell Community for writing test cases. -To use the tool please read [ Pester Guides](https://github.com/pester/Pester) and [Writing Pester Tests Guidelines](https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/WritingPesterTests.md). +To use the tool please read [Pester Guides](https://github.com/pester/Pester) and [Writing Pester Tests Guidelines](https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/WritingPesterTests.md). - -Map Book for Experienced Bash users ----- +### Map Book for Experienced Bash users The table below lists the usage of some basic commands to help you get started on PowerShell faster. Note that all bash commands should continue working on PowerShell session. - | Bash | PowerShell | Description |:--------------------|:----------------------------|:--------------------- | ls |dir, Get-ChildItem |List files and folders @@ -101,8 +91,8 @@ Note that all bash commands should continue working on PowerShell session. | grep -Rin "sometext" --include="*.cs" |Get-ChildItem -Recurse -Filter *.cs
\| Select-String -Pattern "sometext" | Recursively case-insensitive search for text in files | curl https://github.com | Invoke-RestMethod https://github.com | Transfer data to or from the web -Recommended Training and Reading ----- +### Recommended Training and Reading + - Microsoft Virtual Academy: [Getting Started with PowerShell][getstarted-with-powershell] - [Why Learn PowerShell][why-learn-powershell] by Ed Wilson - PowerShell Web Docs: [Basic cookbooks][basic-cookbooks] @@ -113,10 +103,9 @@ Recommended Training and Reading - [PowerShell 5 How-To Videos][script-guy-how-to] by Ed Wilson - [PowerShell Documentation](https://docs.microsoft.com/powershell) +### Commercial Resources -Commercial Resources ----- -- [Windows PowerShell in Action][in-action] by Bruce Payette +- [Windows PowerShell in Action][in-action] by [Bruce Payette](https://github.com/brucepay) - [Introduction to PowerShell][powershell-intro] from Pluralsight - [PowerShell Training and Tutorials][lynda-training] from Lynda.com - [Learn Windows PowerShell in a Month of Lunches][learn-powershell] by Don Jones and Jeffrey Hicks diff --git a/docs/learning-powershell/create-powershell-scripts.md b/docs/learning-powershell/create-powershell-scripts.md index 0403dd70209..dced379cb9d 100644 --- a/docs/learning-powershell/create-powershell-scripts.md +++ b/docs/learning-powershell/create-powershell-scripts.md @@ -1,14 +1,14 @@ -How to Create and Run PowerShell Scripts -==== +# How to Create and Run PowerShell Scripts You can combine a series of commands in a text file and save it with the file extension '.ps1', and the file will become a PowerShell script. This would begin by opening your favorite text editor and pasting in the following example. -``` PowerShell +```powershell # Script to return current IPv4 addresses on a Linux or MacOS host $ipInfo = ifconfig | Select-String 'inet' $ipInfo = [regex]::matches($ipInfo,"addr:\b(?:\d{1,3}\.){3}\d{1,3}\b") | ForEach-Object value -foreach ($ip in $ipInfo) { +foreach ($ip in $ipInfo) +{ $ip.Replace('addr:','') } ``` @@ -16,46 +16,50 @@ foreach ($ip in $ipInfo) { Then save the file to something memorable, such as .\NetIP.ps1. In the future when you need to get the IP addresses for the node, you can simplify this task by executing the script. -``` PowerShell -PS> .\NetIP.ps1 +```powershell +.\NetIP.ps1 10.0.0.1 127.0.0.1 ``` + You can accomplish this same task on Windows. -```PowerShell +```powershell # One line script to return current IPv4 addresses on a Windows host Get-NetIPAddress | Where-Object {$_.AddressFamily -eq 'IPv4'} | ForEach-Object IPAddress ``` + As before, save the file as .\NetIP.ps1 and execute within a PowerShell environment. Note: If you are using Windows, make sure you set the PowerShell's execution policy to "RemoteSigned" in this case. See [Running PowerShell Scripts Is as Easy as 1-2-3][run-ps] for more details. -```PowerShell -PS C:\> NetIP.ps1 +```powershell +NetIP.ps1 127.0.0.1 10.0.0.1 ``` -Creating a script that can accomplish the same task on multiple operating systems ----- +## Creating a script that can accomplish the same task on multiple operating systems If you would like to author one script that will return the IP address across Linux, MacOS, or Windows, you could accomplish this using an IF statement. -```PowerShell +```powershell # Script to return current IPv4 addresses for Linux, MacOS, or Windows -$IP = if ($IsLinux -or $IsMacOS) { +$IP = if ($IsLinux -or $IsMacOS) +{ $ipInfo = ifconfig | Select-String 'inet' $ipInfo = [regex]::matches($ipInfo,"addr:\b(?:\d{1,3}\.){3}\d{1,3}\b") | ForEach-Object value foreach ($ip in $ipInfo) { $ip.Replace('addr:','') } } -else { +else +{ Get-NetIPAddress | Where-Object {$_.AddressFamily -eq 'IPv4'} | ForEach-Object IPAddress } # Remove loopback address from output regardless of platform $IP | Where-Object {$_ -ne '127.0.0.1'} ``` + [run-ps]:https://windowsitpro.com/powershell/running-powershell-scripts-easy-1-2-3 diff --git a/docs/learning-powershell/debugging-from-commandline.md b/docs/learning-powershell/debugging-from-commandline.md index 53dca76540d..f6a247ab967 100644 --- a/docs/learning-powershell/debugging-from-commandline.md +++ b/docs/learning-powershell/debugging-from-commandline.md @@ -1,11 +1,12 @@ -Debugging in PowerShell Command-line -===== +# Debugging in PowerShell Command-line -As we know, we can debug PowerShell code via GUI tools like [Visual Studio Code](https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/using-vscode?view=powershell-6#debugging-with-visual-studio-code). In addition, we can directly perform debugging within the PowerShell command-line session by using the PowerShell debugger cmdlets. This document demonstrates how to use the cmdlets for the PowerShell command-line debugging. We will cover the following topics: setting a debug breakpoint on a line of code and on a variable. +As we know, we can debug PowerShell code via GUI tools like [Visual Studio Code](https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/using-vscode?view=powershell-6#debugging-with-visual-studio-code). In addition, we can +directly perform debugging within the PowerShell command-line session by using the PowerShell debugger cmdlets. This document demonstrates how to use the cmdlets for the PowerShell command-line debugging. We will cover the following topics: +setting a debug breakpoint on a line of code and on a variable. Let's use the following code snippet as our sample script. -```PowerShell +```powershell # Convert Fahrenheit to Celsius function ConvertFahrenheitToCelsius([double] $fahrenheit) { @@ -17,32 +18,32 @@ $celsius $fahrenheit = Read-Host 'Input a temperature in Fahrenheit' $result =[int](ConvertFahrenheitToCelsius($fahrenheit)) Write-Host "$result Celsius" - ``` - - **1. Setting a Breakpoint on a Line** + 1. **Setting a Breakpoint on a Line** - Open a [PowerShell editor](README.md#powershell-editor) - Save the above code snippet to a file. For example, "test.ps1" - Go to your command-line PowerShell - Clear existing breakpoints if any -```PowerShell +```powershell PS /home/jen/debug>Get-PSBreakpoint | Remove-PSBreakpoint - ``` +``` + - Use **Set-PSBreakpoint** cmdlet to set a debug breakpoint. In this case, we will set it to line 5 -```PowerShell +```powershell PS /home/jen/debug>Set-PSBreakpoint -Line 5 -Script ./test.ps1 ID Script Line Command Variable Action -- ------ ---- ------- -------- ------ 0 test.ps1 5 ``` + - Run the script "test.ps1". As we have set a breakpoint, it is expected the program will break into the debugger at the line 5. -```PowerShell +```powershell PS /home/jen/debug> ./test.ps1 Input a temperature in Fahrenheit: 80 @@ -102,16 +103,16 @@ PS /home/jen/debug> ``` - -**2. Setting a Breakpoint on a Variable** +1. **Setting a Breakpoint on a Variable** - Clear existing breakpoints if there are any -```PowerShell +```powershell PS /home/jen/debug>Get-PSBreakpoint | Remove-PSBreakpoint ``` + - Use **Set-PSBreakpoint** cmdlet to set a debug breakpoint. In this case, we set it to line 5 -```PowerShell +```powershell PS /home/jen/debug>Set-PSBreakpoint -Variable "celsius" -Mode write -Script ./test.ps1 @@ -122,9 +123,8 @@ PS /home/jen/debug> Once hit the debug breakpoint, we can type **l** to list the source code that debugger is currently executing. As we can see line 3 has an asterisk at the front, meaning that's the line the program is currently executing and broke into the debugger as illustrated below. - Type **q** to exit from the debugging mode. The following is an example of debugging output. -```PowerShell - -PS /home/jen/debug> ./test.ps1 +```powershell +./test.ps1 Input a temperature in Fahrenheit: 80 Hit Variable breakpoint on '/home/jen/debug/test.ps1:$celsius' (Write access) @@ -167,8 +167,7 @@ PS /home/jen/debug> Now you know the basics of the PowerShell debugging from PowerShell command-line. For further learning, read the following articles. +## More Reading -More Reading -===== - [about_Debuggers](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_debuggers?view=powershell-6) - [PowerShell Debugging](https://blogs.technet.microsoft.com/heyscriptingguy/tag/debugging/) diff --git a/docs/learning-powershell/powershell-beginners-guide.md b/docs/learning-powershell/powershell-beginners-guide.md index 971f692b87a..8564dc0822a 100644 --- a/docs/learning-powershell/powershell-beginners-guide.md +++ b/docs/learning-powershell/powershell-beginners-guide.md @@ -66,20 +66,21 @@ Handles NPM(K) PM(K) WS(K) CPU(s) Id ProcessName ``` -2. `Clear-Host`: Clears the display in the host program. +1. `Clear-Host`: Clears the display in the host program. ```powershell PS /> Get-Process PS /> Clear-Host ``` + Type too much just for clearing the screen? Here is how the alias can help. -3. `Get-Alias`: Gets the aliases for the current session. +1. `Get-Alias`: Gets the aliases for the current session. ```powershell -PS /> Get-Alias +Get-Alias CommandType Name ----------- ---- @@ -100,19 +101,20 @@ Alias type -> Get-Content As you can see `cls` or `clear` is an alias of `Clear-Host`. Now try it: + ```powershell PS /> Get-Process PS /> cls ``` -4. `cd -> Set-Location`: Sets the current working location to a specified location. +1. `cd -> Set-Location`: Sets the current working location to a specified location. ```powershell PS /> Set-Location /home PS /home> ``` -5. `dir -> Get-ChildItem`: Gets the items and child items in one or more specified locations. +1. `dir -> Get-ChildItem`: Gets the items and child items in one or more specified locations. ```powershell # Get all files under the current directory: @@ -181,7 +183,7 @@ Or simply use `>` as below: The pound sign `#` above is used for comments in PowerShell. -7. `type -> Get-Content`: Gets the content of the item at the specified location. +1. `type -> Get-Content`: Gets the content of the item at the specified location. ```powershell PS /home/jen> Get-Content -Path ./test.txt @@ -190,7 +192,7 @@ PS /home/jen> type -Path ./test.txt Hello world again! ``` -8. `del -> Remove-Item`: Deletes the specified items. +1. `del -> Remove-Item`: Deletes the specified items. This cmdlet will delete the file `/home/jen/test.txt`: @@ -198,7 +200,7 @@ This cmdlet will delete the file `/home/jen/test.txt`: PS /home/jen> Remove-Item ./test.txt ``` -9. `$PSVersionTable`: Displays the version of PowerShell you are currently using. +1. `$PSVersionTable`: Displays the version of PowerShell you are currently using. Type `$PSVersionTable` in your PowerShell session, you will see something like below. "PSVersion" indicates the PowerShell version that you are using. @@ -218,10 +220,10 @@ SerializationVersion 1.1.0.1 ``` -10. `Exit`: To exit the PowerShell session, type `exit`. +1. `Exit`: To exit the PowerShell session, type `exit`. ```powershell -PS /home/jen> exit +exit ``` ## Need Help? @@ -329,7 +331,7 @@ For more details, see [Create and Run PowerShell Script Guide][create-run-script [tutorial]: https://www.computerperformance.co.uk/powershell/index.htm [to-learn]:https://blogs.technet.microsoft.com/heyscriptingguy/2015/01/04/weekend-scripter-the-best-ways-to-learn-powershell/ [ps-module]:https://msdn.microsoft.com/library/dd878324%28v=vs.85%29.aspx -[create-ps-module]:http://www.tomsitpro.com/articles/powershell-modules,2-846.html +[create-ps-module]:https://www.business.com/articles/powershell-modules/ [remoting]:https://channel9.msdn.com/Series/GetStartedPowerShell3/06 [in-depth]: https://channel9.msdn.com/events/MMS/2012/SV-B406 [remote-mgmt]:https://windowsitpro.com/powershell/powershell-basics-remote-management diff --git a/docs/learning-powershell/working-with-powershell-objects.md b/docs/learning-powershell/working-with-powershell-objects.md index adbdc3eeef6..ab127483cfe 100644 --- a/docs/learning-powershell/working-with-powershell-objects.md +++ b/docs/learning-powershell/working-with-powershell-objects.md @@ -1,5 +1,5 @@ -Working with PowerShell Objects -==== +# Working with PowerShell Objects + When cmdlets are executed in PowerShell, the output is an Object, as opposed to only returning text. This provides the ability to store information as properties. As a result, handling large amounts of data and getting only specific properties is a trivial task. @@ -7,8 +7,9 @@ As a result, handling large amounts of data and getting only specific properties As a simple example, the following function retrieves information about storage Devices on a Linux or MacOS operating system platform. This is accomplished by parsing the output of an existing command, *parted -l* in administrative context, and creating an object from the raw text by using the *New-Object* cmdlet. -```PowerShell -Function Get-DiskInfo { +```powershell +function Get-DiskInfo +{ $disks = sudo parted -l | Select-String "Disk /dev/sd*" -Context 1,0 $diskinfo = @() foreach ($disk in $disks) { @@ -27,7 +28,7 @@ The results are formatted as a table with the default view. *Note: in this example, the disks are virtual disks in a Microsoft Azure virtual machine.* -```PowerShell +```powershell PS /home/psuser> $d = Get-DiskInfo [sudo] password for psuser: PS /home/psuser> $d @@ -44,7 +45,7 @@ This is because the value of *$d* is not just text output. The value is actually an array of .Net objects with methods and properties. The properties include Device, Friendly Name, and Total Size. -```PowerShell +```powershell PS /home/psuser> $d | Get-Member @@ -63,7 +64,7 @@ Total Size NoteProperty string Total Size= 31.5GB To confirm, we can call the GetType() method interactively from the console. -```PowerShell +```powershell PS /home/psuser> $d.GetType() IsPublic IsSerial Name BaseType @@ -73,7 +74,7 @@ True True Object[] System.Array To index in to the array and return only specific objects, use the square brackets. -```PowerShell +```powershell PS /home/psuser> $d[0] Friendly Name Total Size Device @@ -89,7 +90,7 @@ True False PSCustomObject System.Object To return a specific property, the property name can be called interactively from the console. -```PowerShell +```powershell PS /home/psuser> $d.Device /dev/sda /dev/sdb @@ -97,7 +98,7 @@ PS /home/psuser> $d.Device To output a view of the information other than default, such as a view with only specific properties selected, pass the value to the *Select-Object* cmdlet. -```PowerShell +```powershell PS /home/psuser> $d | Select-Object Device, 'Total Size' Device Total Size @@ -107,10 +108,10 @@ Device Total Size ``` Finally, the example below demonstrates use of the *ForEach-Object* cmdlet to iterate through the array and manipulate the value of a specific property of each object. -In this case the Total Size property, which was given in Gigabytes, is changed to Megabytes. +In this case the Total Size property, which was given in Gigabytes, is changed to Megabytes. Alternatively, index in to a position in the array as shown below in the third example. -```PowerShell +```powershell PS /home/psuser> $d | ForEach-Object 'Total Size' 31.5GB 145GB @@ -121,4 +122,4 @@ PS /home/psuser> $d | ForEach-Object {$_.'Total Size' / 1MB} PS /home/psuser> $d[1].'Total Size' / 1MB 148480 -``` \ No newline at end of file +``` diff --git a/docs/testing-guidelines/CodeCoverageAnalysis.md b/docs/testing-guidelines/CodeCoverageAnalysis.md index 1461905b716..bee669ea747 100644 --- a/docs/testing-guidelines/CodeCoverageAnalysis.md +++ b/docs/testing-guidelines/CodeCoverageAnalysis.md @@ -1,7 +1,7 @@ # Code coverage analysis for commit [de5f69c](https://codecov.io/gh/PowerShell/PowerShell/tree/de5f69cf942a85839c907f11a29cf9c09f9de8b4/src) Code coverage runs are enabled on daily Windows builds for PowerShell Core 6. -The results of the latest build are available at: [CodeCov.io](https://codecov.io/gh/PowerShell/PowerShell) +The results of the latest build are available at [codecov.io](https://codecov.io/gh/PowerShell/PowerShell) The goal of this analysis is to find the hot spots of missing coverage. The metrics used for selection of these hot spots were: # missing lines and likelihood of code path usage. From 333a06b640a59ae762e41e70fc75b06e4f79931e Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Sat, 9 Feb 2019 15:42:15 -0500 Subject: [PATCH 07/12] Update docs/community/governance.md Co-Authored-By: RDIL --- docs/community/governance.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/community/governance.md b/docs/community/governance.md index de27747244c..4979430b216 100644 --- a/docs/community/governance.md +++ b/docs/community/governance.md @@ -64,7 +64,8 @@ If any Committee Members feels like this behavior is large enough to warrant an As a PowerShell Committee Member: -1. **DO** reply to issues and pull requests with design opinions (this could include offering support for good work or exciting new features) +1. **DO** reply to issues and pull requests with design opinions + (this could include offering support for good work or exciting new features) 1. **DO** encourage healthy discussion about the direction of PowerShell 1. **DO** raise "red flags" on PRs that haven't followed the proper RFC process when applicable 1. **DO** contribute to documentation and best practices From a24b7b416800f408e2fb748745f1d4cb28062f38 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Sat, 9 Feb 2019 15:42:20 -0500 Subject: [PATCH 08/12] Update docs/community/governance.md Co-Authored-By: RDIL --- docs/community/governance.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/community/governance.md b/docs/community/governance.md index 4979430b216..8ffef414666 100644 --- a/docs/community/governance.md +++ b/docs/community/governance.md @@ -117,7 +117,9 @@ If you are an Area Expert: 1. **DO** assign the [correct labels][issue-process] 1. **DO** assign yourself to issues labeled with your area of expertise 1. **DO** code reviews for issues where you're assigned or in your areas of expertise. -1. **DO** reply to new issues and pull requests that are related to your area of expertise (while reviewing PRs, leave your comment even if everything looks good - a simple "LGTM" will suffice, so that we know someone has taken a look at it). +1. **DO** reply to new issues and pull requests that are related to your area of expertise + (while reviewing PRs, leave your comment even if everything looks good - a simple "LGTM" will suffice, + so that we know someone has taken a look at it). 1. **DO** make sure contributors are following the [contributor guidelines](../../.github/CONTRIBUTING.md). 1. **DO** ask people to resend a pull request, if it [doesn't target `master`](../../.github/CONTRIBUTING.md#lifecycle-of-a-pull-request). 1. **DO** ensure that contributors [write Pester tests][pester] for all new/changed functionality From a0ae3862d9155028a4264e39b4e556068c03df35 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Sat, 9 Feb 2019 15:42:30 -0500 Subject: [PATCH 09/12] Update docs/dev-process/breaking-change-contract.md Co-Authored-By: RDIL --- docs/dev-process/breaking-change-contract.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev-process/breaking-change-contract.md b/docs/dev-process/breaking-change-contract.md index 4ce4c6e2f16..f33f806f7e8 100644 --- a/docs/dev-process/breaking-change-contract.md +++ b/docs/dev-process/breaking-change-contract.md @@ -5,7 +5,7 @@ We have a serious commitment to backwards compatibility with all earlier version Below is a summary of our approach to handing breaking changes including what kinds of things constitute breaking changes, how we categorize them, and how we decide what we're willing to take. Note that these rules only apply to existing stable features that have shipped in a supported release. New features marked as “in preview” that are still under development may be modified from one preview release to the next. -These are *not* considered breaking changes. +These are **not** considered breaking changes. To help triage breaking changes, we classify them in to four buckets: From 52d02d9eae1e0ca91e72517bc493b03471e437d7 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Sat, 9 Feb 2019 15:42:44 -0500 Subject: [PATCH 10/12] Update docs/dev-process/coding-guidelines.md Co-Authored-By: RDIL --- docs/dev-process/coding-guidelines.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/dev-process/coding-guidelines.md b/docs/dev-process/coding-guidelines.md index 11724b79799..47f585b4229 100644 --- a/docs/dev-process/coding-guidelines.md +++ b/docs/dev-process/coding-guidelines.md @@ -111,7 +111,8 @@ Some general guidelines: * Avoid creating empty arrays. Instead, reuse the static ones via `Utils.EmptyArray`. -* Avoid unnecessary memory allocation in a loop. Move the memory allocation outside the loop if possible. +* Avoid unnecessary memory allocation in a loop. + Move the memory allocation outside the loop if possible. * Avoid gratuitous exceptions as much as possible. Exception handling can be expensive due to cache misses and page faults when accessing the handling code and data. From 94aa542484939c5b0abcc085b7bffcf1b828c882 Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Mon, 11 Feb 2019 12:36:35 -0500 Subject: [PATCH 11/12] fixed url --- docs/maintainers/issue-management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/maintainers/issue-management.md b/docs/maintainers/issue-management.md index aa4757a0123..0590da821e0 100644 --- a/docs/maintainers/issue-management.md +++ b/docs/maintainers/issue-management.md @@ -4,7 +4,7 @@ If you believe that there is a security vulnerability in PowerShell Core, it **must** be reported to [secure@microsoft.com](https://technet.microsoft.com/security/ff852094.aspx) to allow for [Coordinated Vulnerability Disclosure](https://technet.microsoft.com/security/dn467923). -**Only** file an issue, if [secure@microsoft.com][https://technet.microsoft.com/security/ff852094.aspx] has confirmed filing an issue is appropriate. +**Only** file an issue, if [secure@microsoft.com][https://www.microsoft.com/en-us/msrc/faqs-report-an-issue?rtc=1] has confirmed filing an issue is appropriate. ## Long-living issue labels From 2a18943bb9c4c2c2f16fbc981c5a8dca872e48a2 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Mon, 11 Feb 2019 11:08:38 -0800 Subject: [PATCH 12/12] Update issue-management.md --- docs/maintainers/issue-management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/maintainers/issue-management.md b/docs/maintainers/issue-management.md index 0590da821e0..1779a3a95b5 100644 --- a/docs/maintainers/issue-management.md +++ b/docs/maintainers/issue-management.md @@ -4,7 +4,7 @@ If you believe that there is a security vulnerability in PowerShell Core, it **must** be reported to [secure@microsoft.com](https://technet.microsoft.com/security/ff852094.aspx) to allow for [Coordinated Vulnerability Disclosure](https://technet.microsoft.com/security/dn467923). -**Only** file an issue, if [secure@microsoft.com][https://www.microsoft.com/en-us/msrc/faqs-report-an-issue?rtc=1] has confirmed filing an issue is appropriate. +**Only** file an issue, if [secure@microsoft.com](https://www.microsoft.com/en-us/msrc/faqs-report-an-issue?rtc=1) has confirmed filing an issue is appropriate. ## Long-living issue labels