Change New-Guid to generate UUID v7 by default#26256
Conversation
Co-authored-by: TravisEz13 <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR updates the New-Guid cmdlet to generate UUID version 7 GUIDs by default instead of UUID version 4, providing time-ordered identifiers that offer better database performance and natural sortability while maintaining backward compatibility.
Key Changes:
- Modified default GUID generation from
Guid.NewGuid()(v4) toGuid.CreateVersion7()(v7) - Updated XML documentation to explain the UUID v7 default and how to access specific versions
- Added tests to verify UUID v7 format and time-ordered behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| NewGuidCommand.cs | Changed default GUID generation method to CreateVersion7() and updated documentation |
| New-Guid.Tests.ps1 | Added tests to verify UUID v7 format and time-ordered properties |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There seems to be a pattern of Copilot fabricating issue numbers. |
|
Should we be defaulting to v7, seems like we should take this opportunity to expose some selector to specify which version to use and keep the default at 4. If .NET ever exposes a way to do things like v5 with a namespace or if we want to expose the |
already decided in the issue. |
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
Summary
This PR updates the
New-Guidcmdlet to generate UUID version 7 GUIDs by default, replacing the previous UUID version 4 generation. This change was decided by @PowerShell/wg-powershell-cmdlets based on the belief that users ofNew-Guidare primarily looking for a GUID/UUID and don't care about the technical aspects, while technical users who need specific versions can call the .NET APIs directly.What Changed
New-Guidnow usesGuid.CreateVersion7()instead ofGuid.NewGuid()Benefits of UUID v7
UUID v7 offers several advantages over UUID v4 for modern applications:
Example:
Backward Compatibility
✅ Fully backward compatible - All existing parameters work unchanged:
-Emptyparameter continues to work as before-InputObjectparameter continues to work as beforeSystem.GuidMigration Notes
No action required for existing scripts - they will continue to work. The cmdlet interface is unchanged.
For users who need specific UUID versions:
Technical Details
Guid.CreateVersion7()was introducedOriginal prompt
Fixes #24895
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.