Conversation
…ntFromContent` In reality, this method is used by the core to create a blueprint from content, and not the other way around, which doesn't need new ids. This was causing confusion, so the old name has been marked as deprecated in favor of the new name. If developers want to create content from blueprints they should use `IContentBlueprintEditingService.GetScaffoldedAsync()` instead, which is what is used by the management api.
…en creating content from a blueprint
…affoldedAsync` instead of the blueprint itself
…entFromBlueprint`
…rints-programatically
9d50a08 to
00f2ba8
Compare
…rints-programatically
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR simplifies programmatic blueprint-based content creation by returning clone scaffolds, renaming key methods for clarity, and expanding integration tests for block editors.
GetScaffoldedAsyncnow returns a cloned blueprint with reset identity.- Renamed
CreateContentFromBlueprint→CreateBlueprintFromContent, marking the old method obsolete. - Added integration tests covering block editors and extracted reusable block data type builder logic.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.cs | Added JSON serializer dependency and adjusted array initializers. |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.GetScaffold.cs | Enhanced scaffold tests for block editors; introduced new block key assertions. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/TelemetryProviderTests.cs | Updated a test to use GetScaffoldedAsync and switched to async. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ElementSwitchValidatorTests.cs | Refactored data type setup to use new CreateSimpleElementDataType. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentServiceTests.cs | Renamed test and updated calls to use CreateBlueprintFromContent. |
| tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTestWithContent.cs | Added IDataTypeService to test base class. |
| tests/Umbraco.Tests.Common/Builders/DataTypeBuilder.cs | Introduced CreateSimpleElementDataType helper and moved block configuration logic. |
| src/Umbraco.Core/Services/IContentService.cs | Renamed interface methods, added default implementation, marked old method obsolete. |
| src/Umbraco.Core/Services/ContentService.cs | Renamed and refactored content/blueprint creation methods, updated null checks. |
| src/Umbraco.Core/Services/ContentBlueprintEditingService.cs | Implemented deep-clone scaffold logic and updated notification payload. |
Comments suppressed due to low confidence (2)
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.GetScaffold.cs:88
- Initializing a List with
[]causes a type mismatch. Replace withnew List<Guid>()or use a collection expression that returns List.
List<Guid> newKeys = [];
tests/Umbraco.Tests.Common/Builders/DataTypeBuilder.cs:172
- Default switch arm returns
[]which is an empty array, not a Dictionary<string, object>. Usenew Dictionary<string, object>()instead.
_ => [],
AndyButland
approved these changes
Jun 13, 2025
Contributor
AndyButland
left a comment
There was a problem hiding this comment.
This looks fantastic, excellent work on the integration tests. I could only find one nit-pick that I've suggested, other than that all good to merge in and close off the related issue.
...tegration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.GetScaffold.cs
Outdated
Show resolved
Hide resolved
…s/ContentBlueprintEditingServiceTests.GetScaffold.cs Co-authored-by: Andy Butland <abutland73@gmail.com>
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.
Relates to #19352, but for V16.
This pull request includes the following changes:
ContentBlueprintEditingService.GetScaffoldedAsync()to return a copy of the blueprint, instead of the blueprint itself, with the identity reset. This will allow developers to simply call this method and save the content as a new item without much effort.ContentService.CreateContentFromBlueprint()toContentService.CreateBlueprintFromContent(), as this better explains its purpose (and how it is used in the core). Marked the old method as obsolete, with a message and xml docs mentioning the other methods.ElementSwitchValidatorTeststoDataTypeBuilder, so it could be re-used.