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

Move extension methods in same assembly to be instance methods #5621

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Nov 11, 2024

Each of the middleware components for IChatClient / IEmbeddingGenerator currently has an additional class, each of which contains a single extension method for the corresponding builder. But they type being extended is in the same assembly; these may as well just be instance methods and avoid all the extra types (implementations in external assemblies would still use extensions, of course). Bonus, the code gets a bit cleaner as we don't have the extra arguments, arg validation, generic parameters, etc.

Microsoft Reviewers: Open in CodeFlow

Each of the middleware components for IChatClient / IEmbeddingGenerator currently has an additional class, each of which contains a single extension method for the corresponding builder. But they type being extended is in the same assembly; these may as well just be instance methods and avoid all the extra types (implementations in external assemblies would still use extensions, of course). Bonus, the code gets a bit cleaner as we don't have the extra arguments, arg validation, generic parameters, etc.
Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I often find that it's useful for a method to show up in Intellisense as an extension. It provides signal that it's a true extension as opposed to being an integral part of the type's API or something that accesses internal data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants