Skip to content

Conversation

@kzu
Copy link
Member

@kzu kzu commented Oct 20, 2025

Configuration-driven sections can change case when a subsequent provider overrides a section value but uses a different casing (since config is inherently case-insensitive). This means we may end up with a client ID with an unexpected casing at run-time.

In order to solve this, we register both clients and agents using an alternative ServiceKey object which performs a comparer-aware comparison (defaults to ordinal ignore case).

Users would need to look for this alternative key explicitly, since we don't want to pollute the container with additional string-only registrations. But to improve discoverability of this case-insensitive lookup, we provide GetChatClient and GetAIAgent extension methods for IServiceProvider.

@kzu kzu added the enhancement New feature or request label Oct 20, 2025
@kzu kzu force-pushed the dev/caseinsensitive branch from 3b93ae5 to 695e473 Compare October 20, 2025 20:06
@kzu
Copy link
Member Author

kzu commented Oct 20, 2025

21 passed 21 passed 18 skipped

🧪 Details on Ubuntu 24.04.3 LTS

from dotnet-retest v1.0.0 on .NET 9.0.10 with 💜 by @devlooped

@kzu kzu force-pushed the dev/caseinsensitive branch 2 times, most recently from 1de9934 to 63d7d52 Compare October 20, 2025 20:12
Configuration-driven sections can change case when a subsequent provider overrides a section value but uses a different casing (since config is inherently case-insensitive). This means we may end up with a client ID with an unexpected casing at run-time.

In order to solve this, we register both clients and agents using an alternative ServiceKey object which performs a comparer-aware comparison (defaults to ordinal ignore case).

Users would need to look for this alternative key explicitly, since we don't want to pollute the container with additional string-only registrations. But to improve discoverability of this case-insensitive lookup, we provide GetChatClient and GetAIAgent extension methods for IServiceProvider.
@kzu kzu force-pushed the dev/caseinsensitive branch from 63d7d52 to d01ac12 Compare October 20, 2025 20:13
@kzu kzu enabled auto-merge (rebase) October 20, 2025 20:14
@kzu kzu merged commit b2ff66d into main Oct 20, 2025
7 checks passed
@kzu kzu deleted the dev/caseinsensitive branch October 20, 2025 20:15
@devlooped devlooped locked and limited conversation to collaborators Nov 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants