OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

added better description for partname being null

Open brunoAltinet opened this issue 1 year ago • 6 comments

I'm seeing a lot of these errors when developing with orchard and there's not much help about it. So i decided to add a safeguard and some context when error is thrown

image

I also refactored a lot of this repetitive code into one method.

brunoAltinet avatar Aug 02 '22 12:08 brunoAltinet

I realize that this refactor might not be what you want to see since it's a critical part of the system, so let me know if i went overboard:)

brunoAltinet avatar Aug 02 '22 12:08 brunoAltinet

You may want to create an issue and explain the exact issue and how to reproduce it.

MikeAlhayek avatar Aug 03 '22 00:08 MikeAlhayek

From my understanding, this happens when a content type has a part whose definition is either missing or has been removed from the system.

brunoAltinet avatar Aug 03 '22 06:08 brunoAltinet

I also noticed slight inconsistency in how some of these methods were previously implemented. Some of them fetch the part like this image while other do it like this: image ie. one is using part type, the other is using the part name. I think that content type part name is more correct

brunoAltinet avatar Aug 03 '22 07:08 brunoAltinet

Looks good to me. We’ll see how the member feel about the change. I like the refactoring part, but, I am sure some will dislike it.

MikeAlhayek avatar Aug 08 '22 16:08 MikeAlhayek

thanks. Do note about that discrepancy that i considered a bug where OnActivated a part is fetched with var part = context.ContentItem.Get(activator.Type, partName) as ContentPart; while most of them do it with var part = context.ContentItem.Get(activator.Type, typePartDefinition.Name) as ContentPart;

so i used the same private method and went with typePardDefinition.Name

brunoAltinet avatar Aug 08 '22 16:08 brunoAltinet

This file has been changed tremendously since this PR

sebastienros avatar Dec 29 '22 18:12 sebastienros