"Fossies" - the Fresh Open Source Software Archive

Member "PowerShell-7.2.6/docs/dev-process/coding-guidelines.md" (11 Aug 2022, 12546 Bytes) of package /linux/misc/PowerShell-7.2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

C# Coding Guidelines

Coding Conventions

As a general rule, our coding convention is to follow the style of the surrounding code. So if a file happens to differ in style from conventions defined here (e.g. private members are named m_member rather than _member), the existing style in that file takes precedence.

When making changes, you may find some existing code goes against the conventions defined here. In such cases, please avoid reformatting any existing code when submitting a PR as it obscures the functional changes of the PR. A separate PR should be submitted for style-only changes. We also run the .NET code formatter tool regularly to keep consistent formatting.

Naming Conventions

Layout Conventions

Member Conventions

Commenting Conventions

Documentation comments

Performance Considerations

PowerShell has a lot of performance sensitive code as well as a lot of inefficient code. We have some guidelines that we typically apply widely even in less important code because code and patterns are copied, and we want certain inefficient code to stay out of the performance critical code.

Some general guidelines:

Security Considerations

Security is an important aspect of PowerShell and we need to be very careful about changes that may introduce security risks, such as code injection caused by the lack of input validation, privilege escalation due to the misuse of impersonation, or data privacy breach with a plain text password.

Reviewers of a PR should be sensitive to changes that may affect security. Some security related keywords may serve as good indicators, such as password, crypto, encryption, decryption, certificate, authenticate, ssl/tls and protected data.

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. See CODEOWNERS for more information about the area experts.

Best Practices

Portable Code

There are 3 primary preprocessor macros we use during builds:

Any other preprocessor defines found in the source are used for one-off custom builds, typically to help debug specific scenarios.

Here are some general guidelines for writing portable code: