Skip to content

Add compile-time error message when user tries to read XML into generics; resolves #614#628

Merged
liuzicheng1987 merged 6 commits intomainfrom
f/fix_xml_generic
Mar 8, 2026
Merged

Add compile-time error message when user tries to read XML into generics; resolves #614#628
liuzicheng1987 merged 6 commits intomainfrom
f/fix_xml_generic

Conversation

@liuzicheng1987
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the handling of rfl::Generic types within the XML serialization and deserialization framework. It prevents unsupported operations at compile time, explicitly enables supported ones, and improves data type parsing robustness. The changes ensure a more predictable and reliable experience when working with XML and generic data structures.

Highlights

  • Compile-time Error for XML Generic Reading: Introduced a compile-time error using static_assert to prevent users from attempting to read XML into rfl::Generic types, resolving a potential runtime issue.
  • XML Generic Writing Support: Explicitly enabled and implemented the functionality for writing rfl::Generic types to XML, ensuring that this use case is supported.
  • Improved Boolean Parsing in XML Reader: Enhanced the XML reader to correctly parse boolean values, now accepting '0' and '1' in addition to 'true' and 'false', and providing a clearer error message for invalid boolean strings.
  • Documentation Update: Updated the docs/generic.md file to reflect the current support status of rfl::Generic with XML, clarifying that reading is not supported but writing is.
  • New Test Case for XML Generic Writing: Added a dedicated test file to validate the correct serialization of rfl::Generic objects into XML format.
Changelog
  • docs/generic.md
    • Updated documentation to clarify that XML generics are supported for writing but not for reading.
  • include/rfl/xml/Parser.hpp
    • Added Generic.hpp and always_false.hpp includes.
    • Introduced a template specialization for rfl::parsing::Parser for rfl::Generic types with xml::Reader and xml::Writer.
    • Implemented a static_assert in the read method of the generic XML parser to generate a compile-time error when attempting to read XML into rfl::Generic.
    • Provided a write method for rfl::Generic to serialize generic objects to XML.
    • Added a to_schema method for rfl::Generic to generate schema for generic objects.
  • include/rfl/xml/Reader.hpp
    • Included Generic.hpp.
    • Refactored boolean parsing logic to accept '1' and '0' as valid boolean representations in addition to 'true' and 'false'.
    • Added an error return for invalid boolean string values during parsing.
  • tests/xml/test_generic.cpp
    • Added a new test file.
    • Implemented a test case to verify the correct XML serialization of an rfl::Generic::Object.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully implements a compile-time error for attempts to read XML into rfl::Generic, which is not supported. This is done using a static_assert in a specialized parser template. The PR also includes a useful improvement to boolean parsing from XML, allowing '0' and '1' as valid values, and modernizes some namespace declarations. A test is added to confirm that writing rfl::Generic to XML works as expected. The changes are well-executed. I have one minor suggestion to remove an unnecessary header include for better code hygiene.

@liuzicheng1987 liuzicheng1987 merged commit 31c056c into main Mar 8, 2026
321 of 322 checks passed
@liuzicheng1987 liuzicheng1987 deleted the f/fix_xml_generic branch March 8, 2026 15:21
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