Repository navigation
feat!: Drop CommonServiceLocator from Uno.Core.Extensions.Compatibility - #98
Conversation
BREAKING CHANGE: `Uno.IServiceLocatorProvider` and `Uno.Extensions.ServiceLocatorProviderExtensions` are removed, and consumers who substituted an `IConversionExtensions` or `IReflectionExtensions` through `ServiceLocator.SetLocatorProvider` must now assign `ExtensionsProvider.ServiceProvider` instead. PR #94 replaced CommonServiceLocator in `LogExtensionPoint` but deliberately left `Uno.Core.Extensions.Compatibility` alone, so the `Uno.Core` package still lists CommonServiceLocator among its dependencies. That package is Microsoft.Practices.ServiceLocation under the MS-PL, which the FSF classifies as GPL-incompatible, over a service locator API that predates Microsoft.Extensions.DependencyInjection. The two `IServiceLocator`-typed public types existed only to hand out a locator and have no consumer anywhere in the unoplatform org, so they are removed rather than retyped. `ExtensionsProvider` moves to `System.IServiceProvider`, matching what `LogExtensionPoint` already does. - Add `ExtensionsProvider.ServiceProvider`, an optional `IServiceProvider` used to resolve `IConversionExtensions` / `IReflectionExtensions` - Delete `IServiceLocatorProvider` and `ServiceLocatorProviderExtensions`, and their `TypeForwardedTo` entries - Drop the `CommonServiceLocator` PackageReference from `Uno.Core` and `Uno.Core.Extensions.Compatibility`, and stop packing `CommonServiceLocator.dll` into `Uno.Core.Build` `Get<TService>(Func<TService>)` also loses an operator-precedence bug: `?:` binds looser than `??`, so the `?? defaultFactory()` only ever applied to the branch that was already `null`. A locator that was set but could not resolve returned `null`. `IServiceProvider.GetService` returns `null` for an unregistered service where `IServiceLocator.GetInstance` threw, so the fallback now applies to both paths - otherwise every unregistered lookup would hand back `null`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GrFrHWth7YEzqGawxNiroK
The fixtures registered their `IConversionExtensions` / `IReflectionExtensions` through `ServiceLocator.SetLocatorProvider`, wrapping a Funq container in a `FunqAdapter : IServiceLocator`. Funq was pulled in for that adapter alone. `TestServiceProvider` replaces both. It caches each registration after the first resolve, the way Funq's default hierarchy scope did, so a test can still mutate the very instance the code under test resolves - `CustomConversionStrategyFixture` depends on that when it registers a strategy on the resolved instance. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GrFrHWth7YEzqGawxNiroK
`IsCurrency` was asserted against a hardcoded plain space. fr-FR's currency group separator is U+202F (narrow no-break space) in current locale data, so the assertion fails on any machine with an ICU new enough to carry the change. Read the separator from the culture instead. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GrFrHWth7YEzqGawxNiroK
There was a problem hiding this comment.
🟡 Changes recommended
ExtensionsProvider.Resolve<TService>() currently masks misconfigured service registrations by silently falling back when the provider returns the wrong type, which can hide wiring errors.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR removes the remaining CommonServiceLocator dependency from Uno.Core.Extensions.Compatibility by switching the ExtensionsProvider extension-resolution hook from IServiceLocator to System.IServiceProvider, and updates tests/packaging so the dependency disappears from the shipped package graph.
Changes:
- Drop
CommonServiceLocatorpackage references (and stop packingCommonServiceLocator.dll) acrossUno.Core,Uno.Core.Extensions.Compatibility, andUno.Core.Build. - Replace
ExtensionsProvider’s service-locator-based resolution with an optionalIServiceProvider(ExtensionsProvider.ServiceProvider) plus fallback behavior. - Update conversion tests to use a minimal
TestServiceProvider, remove the Funq adapter, and fix a fr-FR currency-group-separator assertion to use culture data.
File summaries
| File | Description |
|---|---|
| src/Uno.Core/Uno.Core.csproj | Removes CommonServiceLocator dependency from the core package. |
| src/Uno.Core/ForwardedTypes.cs | Removes type forwarding for deleted service-locator compatibility APIs. |
| src/Uno.Core.Tests/Validation/ValidationHelperFixture.cs | Makes fr-FR currency validation resilient to updated ICU locale data. |
| src/Uno.Core.Tests/Uno.Core.Tests.csproj | Removes Funq test dependency. |
| src/Uno.Core.Tests/Conversions/TypeConverterConversionStrategyFixture.cs | Switches test initialization from ServiceLocator to ExtensionsProvider.ServiceProvider. |
| src/Uno.Core.Tests/Conversions/TestServiceProvider.cs | Introduces a cached, minimal IServiceProvider implementation for tests. |
| src/Uno.Core.Tests/Conversions/FunqAdapter.cs | Removes the Funq→IServiceLocator adapter used only for tests. |
| src/Uno.Core.Tests/Conversions/EnumConversionStrategyFixture.cs | Switches tests to ExtensionsProvider.ServiceProvider. |
| src/Uno.Core.Tests/Conversions/DefaultConversionsExtensionsFixture.cs | Switches tests to ExtensionsProvider.ServiceProvider and TestServiceProvider. |
| src/Uno.Core.Tests/Conversions/CustomConversionStrategyFixture.cs | Switches tests to ExtensionsProvider.ServiceProvider and TestServiceProvider. |
| src/Uno.Core.Tests/Conversions/ConversionExtensionsFixture.cs | Switches tests to ExtensionsProvider.ServiceProvider. |
| src/Uno.Core.Extensions.Compatibility/Uno.Core.Extensions.Compatibility.csproj | Removes CommonServiceLocator dependency from compatibility package. |
| src/Uno.Core.Extensions.Compatibility/IServiceLocatorProvider.cs | Deletes service-locator compatibility interface. |
| src/Uno.Core.Extensions.Compatibility/Extensions/ExtensionsProvider.cs | Replaces service-locator resolution with IServiceProvider-based resolution and fallback. |
| src/Uno.Core.Build/Uno.Core.Build.csproj | Stops packing CommonServiceLocator.dll into the build assets. |
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
`Resolve<TService>` used `as TService`, so an `IServiceProvider` that answered `GetService(typeof(IConversionExtensions))` with something that is not an `IConversionExtensions` was indistinguishable from one that provided nothing, and the default implementation was used. That is the more insidious of the two failures: the custom implementation is simply ignored, silently, forever. `GetService` returning a non-assignable instance violates the `IServiceProvider` contract, so treat it as the wiring error it is. Missing still falls back. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GrFrHWth7YEzqGawxNiroK
Pins all three outcomes: no provider and a provider without the service both fall back to the default, a provided service is used as-is, and a wrong-typed one throws. The last one fails against the previous `as TService` implementation. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GrFrHWth7YEzqGawxNiroK
morning4coffe-dev
left a comment
There was a problem hiding this comment.
The dependency removal is coherent across Compatibility, the umbrella package, build payload and type forwarders. ExtensionsProvider now uses the existing IServiceProvider model, preserves supplied services, falls back for an absent provider/service, and explicitly rejects an incompatible supplied object. The factory-overload precedence correction is necessary with GetService's null-on-miss contract. The fixtures retain per-registration instance identity and cover the new fallback/error paths. The removed public locator surface is correctly called out as breaking; this has no WinUI control-engine behavior implication.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
dev.34 includes unoplatform/Uno.Core#98, which also drops CommonServiceLocator from Uno.Core.Extensions.Compatibility, so the samples' graph is clean too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01F9y6CbUwCMHTvptcqFaqfp
What
Follow-up to #94, which removed CommonServiceLocator from
LogExtensionPointbut deliberately leftUno.Core.Extensions.Compatibilityalone. That exemption is why theUno.Corepackage still lists CommonServiceLocator among its dependencies.This PR removes the last three usages, so the dependency is gone from the package graph entirely.
Why
Same reasoning as #94 — CommonServiceLocator is
Microsoft.Practices.ServiceLocation, copyright Microsoft 2008, under the MS-PL, which the FSF classifies as incompatible with the GPL. #94 stopped it shipping inside every Uno app; this one stopsUno.Coreadvertising it at all.How
ExtensionsProvider— backsConversionExtensions.ImplementationandReflectionExtensions.Implementation, letting a consumer substitute an implementation. Moved toSystem.IServiceProviderwith a settableExtensionsProvider.ServiceProvider, exactly asLogExtensionPoint.ServiceProviderworks after #94.Uno.IServiceLocatorProviderandUno.Extensions.ServiceLocatorProviderExtensions— deleted, along with theirTypeForwardedToentries. Both existed purely to hand out anIServiceLocator; neither can survive the dependency going away in any useful form. GitHub code search across the wholeunoplatformorg finds zero consumers of either,ExtensionsProviderincluded — every hit is Uno.Core's own source.Packaging — drops the
PackageReferencefromUno.CoreandUno.Core.Extensions.Compatibility, and stopsUno.Core.BuildpackingCommonServiceLocator.dllinto itsbuildfolder.One behaviour fix that comes along
Get<TService>(Func<TService>)had an operator-precedence bug:?:binds looser than??, so?? defaultFactory()only ever applied to thenullbranch — a locator that was set but could not resolve returnednull. That was survivable becauseIServiceLocator.GetInstancethrew for an unregistered service.IServiceProvider.GetServicereturns null instead, so keeping the shape would hand backnullfrom every unregistered lookup. The fallback now applies to both paths.Breaking change
Consumers who substituted an implementation via
ServiceLocator.SetLocatorProvider(...)assignExtensionsProvider.ServiceProviderinstead:Consumers of
IServiceLocatorProvider/.ServiceLocation()have no replacement — see above for why that surface is believed to be unused.Validation
Runtime —
dotnet test Uno.Core.Tests: 268 passed, 0 failed, 2 skipped.The five conversion fixtures registered their services through a
FunqAdapter : IServiceLocator; they now use a smallTestServiceProvider : IServiceProviderthat caches each registration after first resolve, the way Funq's default hierarchy scope did (CustomConversionStrategyFixtureneeds the resolved instance to be the one it mutates). Funq was pulled in for that adapter alone and is dropped.Negative control — removing the
ExtensionsProvider.ServiceProvider = _containerline fromCustomConversionStrategyFixtureturns it red, so the fixtures genuinely exercise the new resolution path rather than falling through to the defaults.Package — packed
Uno.CoreandUno.Core.Extensions.Compatibilityand read the generated.nuspec. NoCommonServiceLocatordependency in either:Unrelated commit riding along
test: Take fr-FR's group separator from the culture—ValidationHelperFixtureassertsIsCurrencyagainst a hardcoded plain space, but fr-FR's currency group separator is U+202F in current locale data. It fails onmasteron any machine with a new enough ICU, independently of this change. Happy to split it out if you'd rather.🤖 Generated with Claude Code
https://claude.ai/code/session_01GrFrHWth7YEzqGawxNiroK