Skip to content
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

IContentManager Unload extension method for IUrlReference can't be invoked in the 'extension' form #2507

Open
Basewq opened this issue Oct 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Basewq
Copy link
Contributor

Basewq commented Oct 27, 2024

Release Type: Official Release

Version: 4.2.0.2232 and all prior versions when IUrlReference was added.

Platform(s): All

Describe the bug
Calling the following Unload extension method with an IUrlReference on this line won't work if called like:

IContentManager contentManager =...
IUrlReference urlReference = ...
contentManager.Unload(urlReference);

public static void Unload(this IContentManager content, IUrlReference urlReference)

This is because the IContentManager.Unload(object obj) is on the 'real' interface and will always take priority.

When Unload with IUrlReference gets called this way, then the exception is thrown:
System.InvalidOperationException: 'Content not loaded through this ContentManager.'

Also, the UrlReferenceContentManagerExtenstions is incorrectly spelled (the extra t in extension).

Potential Solutions
Add void Unload(IUrlReference urlReference) on IContentManager
I don't think checking within void Unload(object obj) would be a good idea because there might potentially be a case where an UrlReference is somehow intentionally loaded/unloaded through ContentManager?

UrlReferenceContentManagerExtenstions would just be a breaking name change fix.

Workaround
Call ContentManagerExtenstions.Unload(contentManager, urlReference) or contentManager.Unload(urlReference.Url)

@Basewq Basewq added the bug Something isn't working label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant