-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix nullability of return types that can be non-null #15927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi there @IvovdBruggen, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
|
Realising now that this is a very small pull request, does it sound good that I also fix all the other nullability return warnings? Excluding obsolete methods that is. |
|
Hey @IvovdBruggen! Thank you for your PR to fix #15926, someone on the team will review this soon 😄 and in terms of creating a new issue, it's up to you really, you could either create a new one or add on to 15926, and then you could update your PR too 😄 And I agree, probably best to leave anything that is obsolete. |
|
@georgebid Great! I have updated the issue and PR and will commit the other fixes! |
|
Any progress on this perhaps? Came by the same issue today |
|
Hey @IvovdBruggen, sorry for the delay on this one. We are doing a cleanup of older PRs, would you mind fixing the merge conflicts then we will make sure this gets reviewed, and hopefully merged! Again, sorry for the delay! |
|
Hi, no problem! I'll get around to fixing the conflicts. |
# Conflicts: # src/Umbraco.Core/Models/Entities/EntitySlim.cs # src/Umbraco.Core/PropertyEditors/ConfigurationEditor.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs # src/Umbraco.Core/Services/FileService.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs # src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs # src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs # src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs # src/Umbraco.Web.BackOffice/Controllers/DictionaryController.cs # src/Umbraco.Web.BackOffice/Controllers/PreviewController.cs # src/Umbraco.Web.BackOffice/DependencyInjection/UmbracoBuilderExtensions.cs # src/Umbraco.Web.BackOffice/Extensions/ModelStateExtensions.cs # src/Umbraco.Web.Common/Extensions/FriendlyPublishedContentExtensions.cs
|
Hope I did the rebasing right, never did it before on a project this scale 😁 |
# Conflicts: # src/Umbraco.Core/Services/ContentEditingService.cs # src/Umbraco.Core/Webhooks/Events/Content/ContentEmptiedRecycleBinWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Content/ContentMovedToRecycleBinWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Content/ContentMovedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Content/ContentSortedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/DocumentTypeChangedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/DocumentTypeDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/DocumentTypeMovedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/DocumentTypeSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MediaTypeChangedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MediaTypeDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MediaTypeMovedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MediaTypeSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MemberTypeChangedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MemberTypeDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MemberTypeMovedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/ContentType/MemberTypeSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/DataType/DataTypeDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/DataType/DataTypeMovedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/DataType/DataTypeSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Domain/DomainDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Domain/DomainSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/PartialViewDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/PartialViewSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/ScriptDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/ScriptSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/StylesheetDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/StylesheetSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/TemplateDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/File/TemplateSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Language/LanguageDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Language/LanguageSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Member/ExportedMemberWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Member/MemberDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Member/MemberGroupDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Member/MemberGroupSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Member/MemberSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntryDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntrySavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Relation/RelationDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/Relation/RelationSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/User/AssignedUserGroupPermissionsWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/User/UserDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/User/UserGroupDeletedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/User/UserGroupSavedWebhookEvent.cs # src/Umbraco.Core/Webhooks/Events/User/UserSavedWebhookEvent.cs # src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs # src/Umbraco.PublishedCache.HybridCache/DocumentCache.cs # src/Umbraco.PublishedCache.HybridCache/MediaCache.cs # src/Umbraco.Web.Common/Extensions/FriendlyPublishedContentExtensions.cs
…property editors (whilst some property editors we know won't return null, it seems more consistent to adhere to the base class and interface nullability definition).
|
Thanks for the efforts on this @IvovdBruggen. I've had a look at resurrecting it - I know it's been a while, but there are some nice updates in here that I agree would be good to include. I've pushed a few updates in case you'd like to comment:
For the latter case this will mean breaking changes, so it'll be best to include this for Umbraco 17. I'll take this to the team in HQ to get some further opinions on how best to handle this, but assuming you agree with the changes, we could re-target this to |
|
Hi @AndyButland, thanks for taking a look! I am currently on holiday but what you say seems good. As for Umbraco 17 release, thats good. At the moment I don't work alot with Umbraco so whenever's good. |
# Conflicts: # src/Umbraco.Core/Services/AuditService.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes nullability annotations for return types across the Umbraco codebase that were incorrectly marked as nullable when they can actually return non-null values. The changes ensure proper type safety and better developer experience by correctly indicating when methods will always return non-null values.
Key changes:
- Remove nullable annotations (
?) from return types that never return null - Update method signatures in interfaces and implementations to match
- Fix inconsistencies between base classes and derived classes
Reviewed Changes
Copilot reviewed 154 out of 154 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Various webhook event classes | Remove nullable return types from ConvertNotificationToRequestPayload methods that always return objects |
| Extension classes | Remove nullable annotations from methods like Name, Children, Siblings that return non-null collections/strings |
| Service interfaces and implementations | Fix return types for methods like GetActiveServers, GetMembersByPropertyValue that return non-null collections |
| Property value converters | Correct nullability of conversion methods based on actual return behavior |
| Utility and extension classes | Update return types for helper methods that guarantee non-null results |
src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MultiUrlPickerValueConverter.cs
Outdated
Show resolved
Hide resolved
|
Thanks again @IvovdBruggen - as mentioned above, we'll merge this in but keep it for Umbraco 17 due to the minor breaking changes introduced by these nullability updates. |
|
@AndyButland Removing nullability from the abstract/virtual |
|
Thanks @ronaldbarendse - I've addressed with #20660. |
This fixes #15926
Changes
Fixes nullability of methods exposed in various Umbraco extensions.