Skip to content

Placing TypeCacheTarget attribute on generic type should fill the type cache for all instances of the generic type #1

@lgarczyn

Description

@lgarczyn
[TypeCacheTarget]
public interface IInterface<T> { }

will cause

GetTypesDerivedFrom<IInterface<SomeTag>>()

to return an empty array.

The workaround is to add a parent interface, get its children, and then filter said children by the generic interface instance.

It would be nice if it was possible to get children types of generic type instances as well as generic type definitions.

Additionally, we've faced a couple different bugs caused by either forgetting a TypeCacheTarget attribute or misunderstanding what exactly will be cached by the attribute. If GetTypesDerivedFrom could optionally log a warning that it will fail in builds, it would make this situation a lot easier.

Finally, I'm often left after builds with a dead reference to the type cache asset in project settings, that I have to clear by hand.

Sub-issues

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions