Skip to content

feat: add xsd:unsignedInt codec#72

Merged
mark-dropbear merged 1 commit intomainfrom
unsignedint
Nov 27, 2025
Merged

feat: add xsd:unsignedInt codec#72
mark-dropbear merged 1 commit intomainfrom
unsignedint

Conversation

@mark-dropbear
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mark-dropbear, 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 significantly enhances the library's datatype support by introducing a dedicated codec for xsd:unsignedInt. This new functionality allows for accurate and validated conversion of unsigned 32-bit integers between their string representation and Dart's native int type, ensuring data integrity and expanding the range of XML Schema datatypes that can be reliably processed by the library.

Highlights

  • New Codec Implementation: Introduced a new codec for the xsd:unsignedInt datatype, enabling conversion between string and Dart's int.
  • Robust Conversion Logic: Implemented robust decoding and encoding logic for xsd:unsignedInt, including validation for the 32-bit unsigned integer range (0 to 4,294,967,295).
  • Documentation and Changelog Updates: Updated the CHANGELOG.md and README.md to reflect the new xsd:unsignedInt support and its full implementation status.
  • Comprehensive Unit Testing: Added comprehensive unit tests to ensure the correctness and boundary condition handling of the xsd:unsignedInt codec for both valid and invalid inputs.
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
Contributor

@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 adds a codec for xsd:unsignedInt, which is a great addition. The implementation is correct and includes a good set of tests.

I've made a few suggestions to improve the implementation:

  • In both the encoder and decoder, I've suggested replacing the Uint32List trick for range validation with a more direct and readable comparison against the minimum and maximum values for an unsignedInt. This also avoids a small object allocation.
  • I've proposed a refactoring of the test file to use groups and remove code duplication, which improves the structure and maintainability of the tests.

Please also note that the new XsdUnsignedIntCodec is not exported from lib/src/codecs/codecs.dart, which means it won't be accessible through the main library import. This file was not part of the pull request, so I couldn't add a comment, but it's an important change to make this new codec usable.

Comment on lines +4 to +28
void main() {
test('XSD Unsigned Int Codec -> Decode', () {
const codec = XsdUnsignedIntCodec();
final decoder = codec.decoder;

expect(decoder.convert('12345'), equals(12345));
expect(decoder.convert('0'), equals(0));
expect(decoder.convert('4294967295'), equals(4294967295));
expect(() => decoder.convert('-1'), throwsFormatException);
expect(() => decoder.convert('4294967296'), throwsFormatException);
expect(() => decoder.convert('abc'), throwsFormatException);
expect(() => decoder.convert(''), throwsFormatException);
});

test('XSD Unsigned Int Codec -> Encode', () {
const codec = XsdUnsignedIntCodec();
final encoder = codec.encoder;

expect(encoder.convert(12345), equals('12345'));
expect(encoder.convert(0), equals('0'));
expect(encoder.convert(4294967295), equals('4294967295'));
expect(() => encoder.convert(-1), throwsFormatException);
expect(() => encoder.convert(4294967296), throwsFormatException);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The tests are comprehensive, which is great! To improve maintainability and reduce duplication, you can structure them using group and instantiate the codec and its decoder/encoder once outside the tests.

void main() {
  group('XSD Unsigned Int Codec', () {
    const codec = XsdUnsignedIntCodec();
    final decoder = codec.decoder;
    final encoder = codec.encoder;

    test('-> Decode', () {
      expect(decoder.convert('12345'), equals(12345));
      expect(decoder.convert('0'), equals(0));
      expect(decoder.convert('4294967295'), equals(4294967295));
      expect(() => decoder.convert('-1'), throwsFormatException);
      expect(() => decoder.convert('4294967296'), throwsFormatException);
      expect(() => decoder.convert('abc'), throwsFormatException);
      expect(() => decoder.convert(''), throwsFormatException);
    });

    test('-> Encode', () {
      expect(encoder.convert(12345), equals('12345'));
      expect(encoder.convert(0), equals('0'));
      expect(encoder.convert(4294967295), equals('4294967295'));
      expect(() => encoder.convert(-1), throwsFormatException);
      expect(() => encoder.convert(4294967296), throwsFormatException);
    });
  });
}

@mark-dropbear mark-dropbear merged commit f7c3f9f into main Nov 27, 2025
1 check passed
@mark-dropbear mark-dropbear deleted the unsignedint branch November 27, 2025 14:31
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