xtqqczze
3ba61069b8
Enable IDE0054: Use compound assignment ( #13546 )
...
* Autofix IDE0054
https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0054-ide0074
2020-11-05 09:48:13 +05:00
xtqqczze
20401c9583
Enable IDE1005: InvokeDelegateWithConditionalAccess ( #13911 )
...
* Enable IDE1005: InvokeDelegateWithConditionalAccess
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide1005
2020-10-28 22:35:51 +05:00
xtqqczze
88e706f3d7
Autofix RCS1068: Simplify logical negation ( #13555 )
2020-09-04 08:40:05 +05:00
xtqqczze
859890374a
Use read-only auto-implemented properties ( #13507 )
...
* Autofix RCS1170: Use read-only auto-implemented property
2020-09-02 08:11:16 +05:00
Dongbo Wang
44bb5861cb
Avoid multiple enumerations of an IEnumerable<Expression> instance in Compiler.cs ( #13491 )
2020-08-21 10:28:16 -07:00
Dongbo Wang
63cf0c330c
Allow explicitly specified named parameter to supersede the same one from hashtable splatting ( #13162 )
...
Allow explicitly specified named parameter to supersede the same one from hashtable splatting.
The work is done in parameter binder, so that parameters can be resolved to cover a parameter's official name, alias name, and unambiguous partial prefix name.
The changes covers covers Hashtable splatting in 3 scenarios:
- Cmdlet or advanced script invocation;
- Simple function invocation;
- ScriptBlock.GetPowerShell(...), where the script block contains command invocation only and uses Hashtable splatting.
Some code refactoring is done to ParameterBinderController to avoid redundant code being duplicated in CmdletParameterBinderController and ScriptParameterBinderController.
2020-08-05 10:59:53 +05:00
xtqqczze
4597b41396
Use is not syntax where appropriate and remove unnecessary parentheses ( #13323 )
2020-07-31 16:41:59 -07:00
Dongbo Wang
4b9b0788ed
Revert "Use is null syntax ( #13277 )" ( #13322 )
...
This reverts commit 6c03776d74 .
2020-07-30 16:06:38 -07:00
xtqqczze
6c03776d74
Use is null syntax ( #13277 )
...
Replace `== null` with `is null`
2020-07-30 18:04:03 +05:00
xtqqczze
bd90f1921f
Code performance fixes ( #12956 )
...
* RCS1080: Use 'Count/Length' property instead of 'Any' method
* RCS1077: Optimize LINQ method call
* RCS1235: Optimize method call
2020-06-25 11:30:40 +05:00
xtqqczze
0d5d017f0f
Code redundancy fixes ( #12916 )
...
* Autofix `RCS1036: Remove redundant empty line`
* Autofix `RCS1037: Remove trailing white-space`
* Autofix `RCS1033: Remove redundant boolean literal`
* Autofix: `RCS1038: Remove empty statement`
* Autofix `RCS1041: Remove empty initializer`
* Autofix `RCS1097: Remove redundant 'ToString' call
* Autofix: `RCS1420: Operator is unnecessary`
2020-06-11 11:25:35 +05:00
xtqqczze
e93381e73e
Add readonly modifier to internal static members ( #11777 )
...
# PR Summary
* Add readonly modifier to internal static members.
## PR Context
## PR Checklist
- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress ).
- If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes )**
- [x] None
- **OR**
- [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md )
- [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
- [x] Not Applicable
- **OR**
- [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
- [x] N/A or can only be tested interactively
- **OR**
- [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting )
- **Tooling**
- [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
- **OR**
- [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
- Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices ) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell ) for VSCode (which runs in a different PS Host).
- Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
- Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer ) (which provides linting & formatting in the editor extensions).
- Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax ) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
2020-05-31 05:10:22 +00:00
xtqqczze
05cab7fa5a
Formatting: Add empty line between declarations ( #12824 )
...
# PR Summary
Automated fixes:
* RCS0013: Add empty line between single-line declarations of different kind
* RCS010: Add empty line between declarations
## PR Context
## PR Checklist
- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress ).
- If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes )**
- [x] None
- **OR**
- [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md )
- [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
- [x] Not Applicable
- **OR**
- [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
- [x] N/A or can only be tested interactively
- **OR**
- [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting )
- **Tooling**
- [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
- **OR**
- [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
- Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices ) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell ) for VSCode (which runs in a different PS Host).
- Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
- Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer ) (which provides linting & formatting in the editor extensions).
- Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax ) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
2020-05-29 04:56:33 +00:00
xtqqczze
9212aac0fa
Use nameof operator ( #12716 )
...
# PR Summary
Using *Roslynator Command Line Tool version 0.1.0.4*
* Fix RCS1015:
* `"argument"` → `nameof(argument)`
* `enum.ToString()` → `nameof(enum)`
[RCS1015.log](https://github.com/PowerShell/PowerShell/files/4646102/RCS1015.log )
## PR Context
<!-- Provide a little reasoning as to why this Pull Request helps and why you have opened it. -->
## PR Checklist
- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress ).
- If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes )**
- [x] None
- **OR**
- [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md )
- [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
- [x] Not Applicable
- **OR**
- [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission )
- [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
- [x] N/A or can only be tested interactively
- **OR**
- [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting )
- **Tooling**
- [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
- **OR**
- [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
- Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices ) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell ) for VSCode (which runs in a different PS Host).
- Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
- Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer ) (which provides linting & formatting in the editor extensions).
- Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax ) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
2020-05-19 18:57:52 +00:00
Robert Holt
3dfd95a09f
Ensure null-coalescing LHS is evaluated only once ( #12667 )
2020-05-16 21:36:15 +05:00
Joel Sallow (/u/ta11ow)
7bc2617fe3
Fix string parameter binding for BigInteger numeric literals ( #11634 )
2020-05-12 16:31:37 -07:00
Steve Lee
b7cb335f03
Update copyright notice to latest guidance ( #12190 )
2020-03-24 11:08:37 -07:00
xtqqczze
a34d0f3e80
Reformat code according to EditorConfig rules ( #11681 )
2020-01-31 14:56:22 -08:00
Dongbo Wang
a4c32bc337
Revert the PRs that made DBNull.Value and NullString.Value treated as $null ( #11648 )
2020-01-29 14:13:05 -08:00
Steve Lee
ed1f6e3144
Make approved features non-experimental ( #11303 )
2019-12-10 15:41:43 -08:00
Aditya Patwardhan
2579c00a20
Support null-conditional operators ?. and ?[] in PowerShell language ( #10960 )
2019-11-15 16:39:53 -08:00
Robert Holt
ad12b14517
Stop blindly setting $? to true for ParenExpression, SubExpression and ArrayExpression ( #11040 )
2019-11-15 11:57:45 -08:00
Ilya
89c66030ba
Cleanup style issues in Compiler.cs ( #10368 )
2019-10-22 13:46:12 +05:00
Robert Holt
2f4ed146ae
Fix pure expressions setting $? in pipeline chains ( #10836 )
2019-10-18 14:57:56 -07:00
Robert Holt
2a518fcfe2
Support the pipeline chain operators && and || in PowerShell language ( #9849 )
2019-10-17 14:43:46 -07:00
Aditya Patwardhan
425bc36a6f
Implement Null Coalescing and Null Coalescing assignment operators ( #10636 )
2019-10-17 10:21:24 -07:00
Dongbo Wang
5069c7d6a6
Support ternary operator in PowerShell language ( #10367 )
2019-09-04 13:22:33 -07:00
Kirk Munro
8b9f4124ce
Add support to ActionPreference.Break to break into debugger ( #8205 )
2019-08-23 10:34:10 -07:00
Ilya
bd6fdae735
Cleanup: sort usings ( #9490 )
2019-04-30 10:25:11 +05:00
Staffan Gustafsson
42c289fc8e
Improve formatting performance by having better primitives on PSObject ( #8785 )
...
By not doing excessive amounts of extra work, formatting can be sped up quite significantly (about 8x faster).
The main change comes from adding new, more efficient, primitive to query an object for the existence of an instance member.
The formatting system has been checking for if an object has properties other than some decorated properties added by PS remoting, and it doesn't this by retrieving all properties which results in heavy allocations and wasted cycles.
By adding `GetFirstOrDefault` to `PSObject` and similar primitives to the underlying Adapters, we are able to return early, without having to get all properties back.
2019-03-20 18:43:52 -07:00
Ilya
ba60904350
Get MethodInfo from .NET public type with explicit parameter types ( #9029 )
2019-03-09 19:05:10 -08:00
Ilya
759c4abde8
Use Type.EmptyTypes and Array.Empty<T>() to replace our custom code of the same functionality ( #9042 )
2019-03-09 17:53:31 -08:00
Travis Plunk
8a877d6160
Merge branch 'release/v6.2.0-rc.1' into master
...
# Conflicts:
# src/System.Management.Automation/engine/parser/Compiler.cs
2019-03-05 11:13:22 -08:00
Ilya
7ed35e3494
Remove unused cached types from CachedReflectionInfo ( #9019 )
2019-03-01 23:08:44 +05:00
Aditya Patwardhan
b2a8a733de
Remove unused cached types ( #9015 )
...
These types are not used in PowerShell code base and should be removed.
## PR Context
The dotnet 3.0.100-preview3-010406 version added overloads to `string.get_Chars` and hence we cannot resolved which overload to load. Thus, we get an type load exception.
Since we are no using this type, it is better to remove it.
2019-02-28 17:28:44 -08:00
Aditya Patwardhan
cae9e952b5
Remove unused cached types ( #9015 )
...
These types are not used in PowerShell code base and should be removed.
## PR Context
The dotnet 3.0.100-preview3-010406 version added overloads to `string.get_Chars` and hence we cannot resolved which overload to load. Thus, we get an type load exception.
Since we are no using this type, it is better to remove it.
2019-02-28 17:13:39 -08:00
Steve Lee
9793ed2c68
Change hashtable to use OrdinalIgnoreCase to be case-insensitive in all Cultures ( #8566 )
...
Ubuntu18.04 seems to default to C.UTF-8 for LANG (representing InvariantCulture) which results in a case-sensitive hashtable since CurrentCultureIgnoreCase doesn't work for that culture. Fix is to use OrdinalIgnoreCase instead.
2019-01-10 09:11:43 +05:00
Ilya
dfd2f69369
Style: Change 'String.' to 'string.' ( #8568 )
2018-12-31 20:44:16 +05:00
Ilya
7207db6360
Style: Convert to upper first char in <param> and <exception> doc tags ( #8556 )
2018-12-29 08:25:49 +05:00
Ilya
479fc64aff
Style: Add period before </param> and </exception> doc tags ( #8553 )
2018-12-28 16:39:06 +05:00
Ilya
871ce5696d
Style: Add period before returns doc tag ( #8535 )
...
- add period before "</returns>" doc tag
- remove extra space before "</returns>" doc tag
- convert first char after "<returns>" doc tag to upper case
2018-12-25 21:43:03 +05:00
Steve Lee
4af3068566
Code cleanup: Add space after closing brace where needed ( #8530 )
...
* Update TestService
* Update WebListener
* Update Controllers
* Update ExpTest
* Update MyApp
* Update Logic
* Update Logic
* Update MyApp
* Update Microsoft.Management.Infrastructure.CimCmdlets
* Update Microsoft.PowerShell.Commands.Diagnostics
* Update Microsoft.PowerShell.ScheduledJob
* Update Microsoft.WSMan.Management
* Update Microsoft.WSMan.Runtime
* Update ResGen
* Update TypeCatalogGen
* Update commands
* Update Eventing
* Update Reader
* Update utility
* Update ShowCommand
* Update trace
* Update WebCmdlet
* Update Common
* Update CoreCLR
* Update common
* Update format-object
* Update format-wide
* Update out-file
* Update out-printer
* Update out-string
* Update OutGridView
* Update LocalAccounts
* Update Commands
* Update security
* Update CoreCLR
* Update DscSupport
* Update engine
* Update help
* Update logging
* Update namespaces
* Update security
* Update utils
* Update config
* Update perfCounters
* Update tracing
* Update cmdletization
* Update other
* Update cim
* Update xml
* Update CoreCLR
* Update common
* Update DefaultFormatters
* Update out-console
* Update out-textInterface
* Update DisplayDatabase
* Update Utilities
* Update COM
* Update ComInterop
* Update CommandCompletion
* Update debugger
* Update ExperimentalFeature
* Update hostifaces
* Update interpreter
* Update lang
* Update Modules
* Update parser
* Update runtime
* Update client
* Update commands
* Update common
* Update fanin
* Update server
* Update WireDataFormat
* Update Binding
* Update Operations
* Update interface
* Update cmdletization
* Update cim
* Update management
* Update WindowsTaskbarJumpList
* Update msh
2018-12-24 11:20:06 +05:00
Dongbo Wang
289981a017
Change 'String' to 'string' for simple references ( #8519 )
2018-12-22 14:26:06 +05:00
Dongbo Wang
2bfbcd4f07
Remove empty lines; correct space on closing square brackets, negative signs, and generic brackets ( #8508 )
2018-12-21 12:23:04 +05:00
Dongbo Wang
c4f569e758
Remove space character after '!' ( #8507 )
2018-12-21 11:51:15 +05:00
Staffan Gustafsson
877b9a9fbf
Add cmdlet 'Join-String' for creating text from pipeline input ( #7660 )
...
The cmdlet syntax is as follows:
```
Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]
Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-SingleQuote] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]
Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-DoubleQuote] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]
Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-FormatString <string>] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]
```
2018-11-14 13:52:44 -08:00
Dongbo Wang
86469bda33
Handle operations with ByRef-like types gracefully in PowerShell ( #7533 )
...
ByRef-like types are supposed to be used on stack only, so we need to fail gracefully when accessing properties, calling methods, or creating objects related to ByRef-like types.
2018-08-26 12:50:58 -07:00
Ilya
4ee1973d97
Fix some style issues in engine code ( #7246 )
...
The PR resolves some style issues in engine code. (Moved from PR #7242 . )
2018-08-13 17:03:27 -07:00
Dongbo Wang
41111a15e6
Update 'Utils.IsComObject' to use 'Marshal.IsComObject' since CAS is no longer supported in .NET Core ( #7344 )
...
A comment from the existing `Utils.IsComObject` mentions that: "We can't use System.Runtime.InteropServices.Marshal.IsComObject(obj) since it doesn't work in partial trust."
Partial trust is a concept of Code Access Security (CAS)/Security-Transparent. CAS and Security-Transparent are no longer supported in .NET Core, so we should use `Marshal.IsComObject` instead.
2018-07-26 09:59:07 -07:00
Dongbo Wang
87d8fc969c
Fix sequence point update for switch/if/for/while/do-while/do-until statements ( #7305 )
...
- Make switch-statement report correct error position when it fails to evaluate the condition.
- Make for-statement report correct error position when it fails to evaluate the initializer.
- For the condition of `if/for/while/do-while/do-until` statements, the sequence point update is either duplicate in some cases (for `if/for/while`) which causes debugger to stop at the condition twice before moving forward, or missing (for `do-while/do-until`) which causes debugger to skip the condition. They are fixed.
2018-07-25 09:56:32 -07:00