Skip to content

feat: implement YamlIgnoreCondition handling for serialization and deserialization#9

Merged
glucaci merged 1 commit into
mainfrom
fix-ignore-condition
Jan 12, 2026
Merged

feat: implement YamlIgnoreCondition handling for serialization and deserialization#9
glucaci merged 1 commit into
mainfrom
fix-ignore-condition

Conversation

@glucaci
Copy link
Copy Markdown
Member

@glucaci glucaci commented Jan 12, 2026

This pull request enhances the handling of the YamlIgnore attribute in the YAML source generator, allowing for more nuanced control over property serialization and deserialization. The changes introduce support for conditional ignore behaviors (Always, WhenWritingNull, WhenWritingDefault, Never), ensuring that properties are ignored or included according to their specified conditions both when reading and writing YAML.

Improvements to YamlIgnore attribute support:

  • Added an IgnoreCondition enum and refactored logic to interpret the YamlIgnore attribute, supporting conditional ignore scenarios such as WhenWritingNull, WhenWritingDefault, and Never, in addition to Always.
  • Introduced new helper methods: GetIgnoreCondition, ShouldIgnorePropertyForReading, and GetWriteIgnoreCondition to determine when properties should be ignored during serialization (writing) and deserialization (reading).

Serialization logic updates:

  • Updated the GenerateWriteMethod to respect the new ignore conditions when generating serialization code, ensuring properties are skipped appropriately based on their YamlIgnore condition. [1] [2] [3]

These changes provide more flexible and standards-compliant YAML serialization/deserialization, aligning with modern usage of ignore conditions in serialization libraries.

@glucaci glucaci merged commit 5067726 into main Jan 12, 2026
1 check passed
@glucaci glucaci deleted the fix-ignore-condition branch January 12, 2026 05:38
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.

1 participant