Elements: Fix GetUdi() extension methods for Element entities#22873
Merged
Conversation
Adds the missing GetUdi() overloads for IElement so v18 Global Elements
produce their umb://element/{key} identifier through the same extension
surface used for documents, media and members.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds missing UDI support for IElement entities so elements (Global Elements / Library) can produce umb://element/{key} consistently via the existing GetUdi() extension surface (directly and through IContentBase / IEntity dispatch).
Changes:
- Extend
UdiGetterExtensions.GetUdi(this IContentBase)to supportIElement. - Add
GetUdi(this IElement)overload returning aGuidUdiwithConstants.UdiEntityType.Element. - Add/extend unit tests to cover element UDIs and ensure all dispatch paths return the same value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Umbraco.Core/Extensions/UdiGetterExtensions.cs | Adds IElement UDI generation and routes IContentBase.GetUdi() to it. |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/Extensions/UdiGetterExtensionsTests.cs | Adds element UDI test coverage (direct + interface dispatch) and extends container test cases. |
AndyButland
approved these changes
May 18, 2026
AndyButland
left a comment
Contributor
There was a problem hiding this comment.
Thanks @ronaldbarendse - all looks good to handle these cases.
Merged
3 tasks
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.
Prerequisites
Description
Adds the missing
GetUdi()overloads forIElement, so v18 Global Elements (Library section) can produce theirumb://element/{key}identifier through the same extension surface used for documents, media and members.The gap
UdiGetterExtensions.GetUdi(this IContentBase)switches onIContent/IMedia/IMemberand throwsNotSupportedExceptionfor anything else - includingIElement, which inherits fromIPublishableContentBase : IContentBase. The same path is reached viaGetUdi(this IEntity), which dispatchesIContentBaseinstances down to the same switch.This is part of a recurring pattern with this extension class missing new entity types - prior fixes:
EntityContainer.GetUdi()for member type containers #20840 -EntityContainer.GetUdi()for member type containersIContentBase.GetUdi()extension method to support document-blueprint entity type #16939 -IContentBase.GetUdi()for document blueprintsIWebhook.GetUdi()andIEntity.GetUdi()extension methods #15288 -IWebhook.GetUdi()andIEntity.GetUdi()Changes
UdiGetterExtensions.GetUdi(this IContentBase)- newIElementcase (cases reordered alphabetically).UdiGetterExtensions.GetUdi(this IElement)returningnew GuidUdi(Constants.UdiEntityType.Element, entity.Key)(i.e.umb://element/{key}).UdiGetterExtensionsTests- newGetUdiForElementtest covering direct,IContentBase, andIEntitydispatch;GetUdiForEntityContainerextended with anElementtest case (already worked viaEntityContainer.GetUdi(), now locked in).Testing
dotnet test --filter UdiGetterExtensionsTests- 34/34 pass.((IContentBase)element).GetUdi()no longer throwsNotSupportedException.IElement,IContentBase,IEntity) return the sameumb://element/{key}UDI.