Enable AIFunctionFactory.Create to use Activator{Utilities}.Create#6193
Merged
stephentoub merged 2 commits intodotnet:mainfrom Mar 26, 2025
Merged
Enable AIFunctionFactory.Create to use Activator{Utilities}.Create#6193stephentoub merged 2 commits intodotnet:mainfrom
stephentoub merged 2 commits intodotnet:mainfrom
Conversation
d467c32 to
865c832
Compare
Member
I'm a fan. |
865c832 to
661b9db
Compare
Member
Author
|
Based on offline discussion with @halter73, I'm marking this as ready for review. |
661b9db to
d38a921
Compare
halter73
approved these changes
Mar 26, 2025
Member
halter73
left a comment
There was a problem hiding this comment.
It might be worth verifying that the target type gets disposed at the end of the invocation.
…es}.Create Adds a Create overload that takes a target type and a MethodInfo. Each invocation of the AIFunction will create/dispose of a new instance, from DI if an IServiceProvider is provided, or via new() otherwise.
eiriktsarpalis
approved these changes
Mar 26, 2025
93fbe0a to
7d1f864
Compare
Member
Author
Done |
eerhardt
reviewed
Mar 26, 2025
eerhardt
reviewed
Mar 26, 2025
7d1f864 to
ce26e55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Create overload that takes a target type and a MethodInfo. Each invocation of the AIFunction will create/dispose of a new instance, from DI if an IServiceProvider is provided, or via new() otherwise.
@halter73, @eiriktsarpalis, @SteveSandersonMS, how do we feel about this approach? This is based on folks asking for a capability this enables in https://github.com/modelcontextprotocol/csharp-sdk.
If we want to proceed with it, I'll add tests.
Microsoft Reviewers: Open in CodeFlow