IContentManager Unload extension method for IUrlReference can't be invoked in the 'extension' form
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
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);
This is because the IContentManager.Unload(object obj) is on the 'real' interface and will always take priority.
https://github.com/stride3d/stride/blob/256c47ba54bb1bc072d9adac397f34541ecd3072/sources/core/Stride.Core.Serialization/Serialization/Contents/IContentManager.cs#L69
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with sources/core/Stride.Core.Serialization/Serialization/UrlReferenceContentManagerExtenstions.cs at the Unload extension and sources/core/Stride.Core.Serialization/Serialization/Contents/IContentManager.cs at Unload(object). Verify the interface and extension overload behavior for IUrlReference, then confirm the corrected API name and direct contentManager.Unload(urlReference) call no longer throws Content not loaded through this ContentManager.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100