Skip to content

Mark -NoTypeInformation as obsolete no-op and evaluate -IncludeTypeInformation by value#26719

Merged
TravisEz13 merged 2 commits into
PowerShell:masterfrom
yotsuda:fix-issue-26569-export-csv-switch-value
Jan 28, 2026
Merged

Mark -NoTypeInformation as obsolete no-op and evaluate -IncludeTypeInformation by value#26719
TravisEz13 merged 2 commits into
PowerShell:masterfrom
yotsuda:fix-issue-26569-export-csv-switch-value

Conversation

@yotsuda
Copy link
Copy Markdown
Contributor

@yotsuda yotsuda commented Jan 22, 2026

PR Summary

Make -NoTypeInformation a pure no-op obsolete parameter and evaluate -IncludeTypeInformation by its value in Export-Csv and ConvertTo-Csv.

Fixes #26569

PR Context

Problem

When specifying both -IncludeTypeInformation:$false and -NoTypeInformation:$false, PowerShell throws an error even though both switches are explicitly set to $false:

'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$false -NoTypeInformation:$false
# Error: Cannot specify both -IncludeTypeInformation and -NoTypeInformation.

This is because the code checked whether the parameters were provided, not their actual values.

Solution

Per WG-Cmdlets discussion:

  1. -IncludeTypeInformation now respects its actual value (not just presence)
  2. -NoTypeInformation is marked obsolete and treated as a pure no-op for backward compatibility
  3. No code checks the value of -NoTypeInformation - it simply triggers a deprecation warning

PR Checklist

Changes Made

1. CsvCommands.cs (-16/+6 lines)

  • Added [Obsolete] attribute to -NoTypeInformation parameter
  • Removed mutual exclusion check for -IncludeTypeInformation and -NoTypeInformation
  • Removed NoTypeInformation value adjustment logic
  • Changed type information output condition from if (NoTypeInformation == false) to if (IncludeTypeInformation)
  • Updated XML documentation for both parameters

2. Export-Csv.Tests.ps1 (-5 lines)

  • Removed test expecting mutual exclusion error

3. ConvertTo-Csv.Tests.ps1 (-5 lines)

  • Removed test expecting mutual exclusion error

Total: 3 files changed, 6 insertions(+), 26 deletions(-)

Behavior Examples

Both switches with $false

'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$false -NoTypeInformation:$false
Before After
Result Error thrown No error (warning shown)

-IncludeTypeInformation:$true

'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$true
Get-Content test.csv | Select-Object -First 1
Before After
Output #TYPE System.String #TYPE System.String

-IncludeTypeInformation:$false

'test' | Export-Csv -Path test.csv -IncludeTypeInformation:$false
Get-Content test.csv | Select-Object -First 1
Before After
Output "Length" "Length"

-NoTypeInformation (obsolete)

'test' | Export-Csv -Path test.csv -NoTypeInformation
Before After
Warning None Deprecation warning shown
Output "Length" "Length"

Testing

Test Results

Test File Passed Failed Status
Export-Csv.Tests.ps1 33 0 ✅ All pass
ConvertTo-Csv.Tests.ps1 26 0 ✅ All pass

Design Decision

The WG-Cmdlets comment mentioned moving -NoTypeInformation to a separate parameter set. However, since -NoTypeInformation is purely a no-op switch that has no effect on behavior, separating parameter sets would cause unnecessary errors when both parameters are specified together (even with $false values). Instead, this PR treats -NoTypeInformation as a truly ignored parameter that simply triggers a deprecation warning.

@yotsuda yotsuda requested a review from a team as a code owner January 22, 2026 15:16
@iSazonov
Copy link
Copy Markdown
Collaborator

@yotsuda Please open new issue in PowerShell-Docs and add reference to it in the PR description.

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 22, 2026
@iSazonov
Copy link
Copy Markdown
Collaborator

@yotsuda Thanks!
Currently, only MSFT team can merge commits. So wait indefinitely.

@iSazonov iSazonov added the Approved-LowRisk Indicate a PR has been approved and can be merged after a quick review of another maintainer. label Jan 28, 2026
@TravisEz13 TravisEz13 added WG-Cmdlets general cmdlet issues Needs-Triage The issue is new and needs to be triaged by a work group. labels Jan 28, 2026
@TravisEz13
Copy link
Copy Markdown
Member

Last time we marked something as obsolete we got a lot of push back. Marking for cmdlet working group triages.

@TravisEz13 TravisEz13 removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Jan 28, 2026
@TravisEz13
Copy link
Copy Markdown
Member

Verified with working group.

@TravisEz13 TravisEz13 merged commit 8489f8f into PowerShell:master Jan 28, 2026
41 checks passed
@yotsuda yotsuda deleted the fix-issue-26569-export-csv-switch-value branch January 28, 2026 22:44
@iSazonov iSazonov self-assigned this Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved-LowRisk Indicate a PR has been approved and can be merged after a quick review of another maintainer. CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log WG-Cmdlets general cmdlet issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-IncludeTypeInformation:$false -NoTypeInformation:$false not respected in Export-Csv/ConvertTo-Csv

3 participants