Skip to content

Ensure NULL string value is written as quoted string in YAML #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 2, 2025

Conversation

adityapatwardhan
Copy link
Member

@adityapatwardhan adityapatwardhan commented Jul 2, 2025

PR Summary

This pull request introduces a new feature to handle NULL values in YAML serialization by quoting them, along with corresponding updates to tests and serializers. The most important changes include adding a custom event emitter for quoting NULL strings, updating the YAML serializer to use this emitter, and adding tests to validate the new behavior.

YAML Serialization Enhancements:

  • Custom Event Emitter for Quoting NULL: Added a new class QuotedNullStringEventEmitter that ensures NULL values are serialized as 'NULL' in YAML. This class overrides the Emit method to handle NULL strings explicitly. (src/YamlWriter/QuotedNullStringEventEmitter.cs)
  • Updated YAML Serializer: Modified the YamlUtils class to use the new QuotedNullStringEventEmitter in the YAML serializer configuration. (src/Common/YamlUtils.cs)

Testing Updates:

  • New Test for NULL Handling: Added a test case in Export-YamlCommandHelp to verify that NULL values are correctly quoted as 'NULL' in the serialized YAML output. (test/Pester/ExportYamlCommandHelp.Tests.ps1)
  • Updated Asset Counts in Tests: Adjusted expected counts in MeasurePlatyPSMarkdown tests to reflect the addition of new test assets. (test/Pester/MeasurePlatyPSMarkdown.Tests.ps1)

PR Context

Fixes #758

@adityapatwardhan
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adityapatwardhan
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@sdwheeler sdwheeler left a comment

Choose a reason for hiding this comment

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

LGTM

@adityapatwardhan
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adityapatwardhan
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adityapatwardhan adityapatwardhan merged commit cafeb17 into v2 Jul 2, 2025
8 checks passed
@adityapatwardhan adityapatwardhan deleted the YamlStrNull branch July 2, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants