Umbraco Helper: Align GetDictionaryValue nullability with behaviour (closes #21145)#21372
Merged
AndyButland merged 1 commit intoJan 13, 2026
Conversation
…ring when no dictionary item is found for the provided key).
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request corrects the return type nullability annotations for dictionary value methods to match their actual implementation behavior. The methods have always returned empty strings instead of null when dictionary items are not found, but the type signatures incorrectly declared nullable return types.
Changes:
- Changed
ICultureDictionaryindexer return type fromstring?tostring - Changed
UmbracoHelper.GetDictionaryValuemethod return types fromstring?tostring - Updated XML documentation to explicitly state that empty strings are returned instead of null
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Umbraco.Core/Dictionary/ICultureDictionary.cs | Updated interface indexer return type to non-nullable string and improved XML documentation |
| src/Umbraco.Web.Common/UmbracoHelper.cs | Updated GetDictionaryValue method return types to non-nullable string and clarified documentation |
Comments suppressed due to low confidence (1)
src/Umbraco.Web.Common/UmbracoHelper.cs:113
- The XML documentation summary is incorrect. This method returns the dictionary value for the specified key, not the dictionary value with a default fallback. The summary should match the behavior described in the returns tag. Consider: "Returns the dictionary value for the key specified".
/// <summary>
/// Returns the dictionary value for the key specified, and if empty returns the specified default fall back value
GetDictionaryValue nullability with behaviour
GetDictionaryValue nullability with behaviourGetDictionaryValue nullability with behaviour
GetDictionaryValue nullability with behaviourGetDictionaryValue nullability with behaviour (closes #21145)
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.
Description
#21145 raised a concern about a change in behaviour of the
GetDictionaryValuemethod, retuning empty string instead of null. This doesn't seem to be the case and it's consistent going back to Umbraco 13. However the signature suggests null can be returned, even though the implementation will never return null.So to align behaviour with the signature I've changed the nullability such that it's clear a null string will never be returned.
Change Summary
ICultureDictionaryindexer andUmbracoHelper.GetDictionaryValuemethods with actual behaviourstring?Testing
Visual inspection should suffice here, but you can verify the method still works as expected using an existing and non-existing key: