Skip to content

Fomat-Wide: Fix Null Reference Exception (#15964) - #15990

Merged
Rob Holt (rjmholt) merged 1 commit into
PowerShell:masterfrom
DarylGraves:master
Aug 25, 2021
Merged

Rob Holt (rjmholt) merged 1 commit into
PowerShell:masterfrom
DarylGraves:master

Conversation

@DarylGraves

Copy link
Copy Markdown
Contributor

PR Summary

If statement changed to include an additional condition. This prevents Null Reference Exceptions with Format-Wide Parent -Auto

PR Context

An issue was raised (#15964) to inform of this.

PR Checklist


sb.Append(GenerateRowField(values[k], _si.columnInfo[k].width, alignment[k], dc, addPadding));
if (values[k].Contains(ESC))
if (values[k] is not null && values[k].Contains(ESC))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (values[k] is not null && values[k].Contains(ESC))
if (values[k]?.Contains(ESC))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (values[k]?.Contains(ESC))

It is not work (can return null but bool is expected..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to do anything here? Sorry, a bit new to this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, you're fine. I misremembered how these operators work a little bit.

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Aug 25, 2021
@rjmholt
Rob Holt (rjmholt) merged commit 321b726 into PowerShell:master Aug 25, 2021
@iSazonov Ilya (iSazonov) added this to the 7.2.0-rc.1 milestone Aug 26, 2021
xtqqczze pushed a commit to xtqqczze/PowerShell-PowerShell that referenced this pull request Sep 2, 2021
@ghost

Copy link
Copy Markdown

🎉v7.3.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.2.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants