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

.Net: Enable CreateFromType/Object to work with closed generics #6218

Merged
merged 4 commits into from
May 20, 2024

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub requested a review from a team as a code owner May 13, 2024 14:11
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels May 13, 2024
@github-actions github-actions bot changed the title Enable CreateFromType/Object to work with closed generics .Net: Enable CreateFromType/Object to work with closed generics May 13, 2024
@RogerBarreto
Copy link
Member

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);
}

@stephentoub
Copy link
Member Author

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.

@stephentoub stephentoub added this pull request to the merge queue May 20, 2024
Merged via the queue into microsoft:main with commit aa0ce10 May 20, 2024
15 checks passed
@stephentoub stephentoub deleted the closedgenerics branch May 20, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants