Add ToBase64String method for URL-safe Base64 encoding and parsing for Id#21
Merged
aevitas merged 2 commits intoaevitas:masterfrom Sep 6, 2025
Conversation
…ew ObsoleteAttribute
…g parsing - Introduces efficient, URL-safe Base64 encoding for 64-bit IDs - Handles legacy ToStringIdentifier format for backward compatibility - Includes TryParseFromUrlSafeBase64 and TryParseFromLegacyBase64 helpers
aevitas
approved these changes
Sep 6, 2025
Owner
aevitas
left a comment
There was a problem hiding this comment.
Very elaborate, nice job. Thanks for picking this one up!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #20.
This PR introduces a new and efficient way to serialize Ids as URL-safe Base64 strings. It includes parsing methods that support both the new format and the legacy
ToStringIdentifier()Base64 string format, along with unit tests.Changes included:
IdExtensions.ToBase64String()for URL-safe Base64 encoding of 64-bit IDs.+and/with-and_for URL safety.=).IdExtensions.FromBase64String()to parse both new URL-safe and legacy Base64 strings.TryParseFromUrlSafeBase64()private helper for safe parsing of the new Base64 format.TryParseFromLegacyBase64()private helper to maintain compatibility withToStringIdentifier().ToStringIdentifier()to remain for legacy support and marked it as [Obsolete].Added unit tests covering:
Please let me know what you think or if any changes are needed.