Fix IDE0019: InlineAsTypeCheck#27406
Open
xtqqczze wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes IDE0019 (“InlineAsTypeCheck”) occurrences by converting as-casts + null checks into C# pattern matching across System.Management.Automation/namespaces.
Changes:
- Replaced
x as T+!= nullchecks withx is T tpattern matching in multiple providers. - Simplified type-checking flows using
is notpatterns for argument validation. - Reduced temporary variables in a few places by scoping pattern variables to conditionals.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/System.Management.Automation/namespaces/VariableProvider.cs | Uses pattern matching for SetVariable result and variable type checks (introduces a behavioral change). |
| src/System.Management.Automation/namespaces/ProviderBase.cs | Pattern matching for PSObject and NavigationCmdletProvider checks. |
| src/System.Management.Automation/namespaces/LocationGlobber.cs | Pattern matching for provider capability casts. |
| src/System.Management.Automation/namespaces/FunctionProvider.cs | Pattern matching for PSObject, ScriptBlock, FunctionInfo, and string checks. |
| src/System.Management.Automation/namespaces/FileSystemSecurity.cs | Uses is not pattern to validate FileSystemSecurity type. |
| src/System.Management.Automation/namespaces/FileSystemProvider.cs | Pattern matching for various dynamic parameter types and FileSystemInfo extraction. |
| src/System.Management.Automation/namespaces/FileSystemContentStream.cs | Pattern matching for object[] content lines. |
| src/System.Management.Automation/namespaces/EnvironmentProvider.cs | Uses is not string pattern to validate/coerce values. |
| src/System.Management.Automation/namespaces/CoreCommandContext.cs | Pattern matching for MshCommandRuntime extraction. |
| src/System.Management.Automation/namespaces/AliasProvider.cs | Pattern matching for AliasInfo and string checks. |
Fix IDE0019: InlineAsTypeCheck in `src/System.Management.Automation/namespaces/*`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix IDE0019: InlineAsTypeCheck in
src/System.Management.Automation/namespaces/*