semantic-kernel
semantic-kernel copied to clipboard
.Net: Enable CreateFromType/Object to work with closed generics
https://github.com/microsoft/semantic-kernel/pull/6206#issuecomment-2107167732
Suggest adding an example on how we can retrieve a generic in the Concepts\Functions\KernelMethod_Types.cs.
I may be trying the open generics here, but would be super nice if we could use that as well, without necessarily specifying the T at the class level.
public class MyPlugin
{
[KernelFunction]
public T GenericResult<T>(T input) => input;
[KernelFunction]
public Task<T> GenericResultAsync<T>(T input) => Task.FromResult(input);
}
I may be trying the open generics here, but would be super nice if we could use that as well, without necessarily specifying the T at the class level.
This won't work today (even with my change) and is more complicated.