v10 Removal of UmbracoDatabase property from IScope #12217
Replies: 2 comments 5 replies
-
I think solution 1 makes a lot of sense to me. while it might uglify a bit of the internal ,it does let the obsolete till v12 thing stand (assuming that is when it would go if this went into v10?) Most of the services will be constructed via the IOC container - so i think that shouldn't cause to many issues. the one that sprang to my mind briefly looking at the branch is the var upgrader = new Upgrader(new TranslationMigrationPlan());
upgrader.Execute(_migrationPlanExecutor, _scopeProvider, _keyValueService); (i know we now have package migrations so maybe the old-school migrations should be marked as off-limits but this would break anyone using them?) couple of examples I found on github:
Not sure if there is an intermediate step possible with this - I can't think of many other "services" that are constructed as opposed to injected maybe the pattern is wrong for this one ? also not sure what the options for this one are. |
Beta Was this translation helpful? Give feedback.
-
Also randomly, I did find one project that was creating its own IUserService, this would obviously break, but i am not sure if the expectation on something like this is that you can preserve it between versions ? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Umbraco v9 attempted to make the Umbraco.Core project less infrastructure aware by creating a new Umbraco.Infrastructure project and moving classes as appropriate to the new assembly.
Unfortunately some classes didn't end up in their ideal home, many of our application services in the Umbraco.Cms.Core namespace had to live in the Infrastructure project as they depend on our UnitOfWork IScope.
IScope in v9 exposes IUmbracoDatabase which Implements NPoco.IDatabase, but the core project has no reference to NPoco so keeping IScope in the Core assembly was difficult without refactoring.
Breaking changes in v10
To solve the issue, IScope at present in the
v10/dev
branch has lost the UmbracoDatabase property, this enables us to move the stranded application services to their correct assembly.But this causes problems for any packages or projects which expect to be able to access the database directly from IScope.
Possible solutions
The internal preference is for solution 1, we think this will make migration to v10 easier for downstream packages/projects as the existing interfaces are untouched, however there is a downside as many constructors for services in the Core project will have to have
breakingchanges introduced to switch from a dependency on IScope to ICoreScope.Whilst this approach introduces many more breaking changes it seems the lessor of two evils as the constructors are generally considered pseudo internal. It is expected that downstream projects will depend only on the abstractions and have the implementations injected by the IOC container. It is unlikely that these constructors are regularly invoked outside of the Umbraco codebase and we should work towards making this expectation align with reality by changing access modifiers to internal where appropriate moving forwards.A branch has been setup to demonstrate how this would work v10/dev...v10/feature/fix-scope-provider-friendlyness
Questions
Beta Was this translation helpful? Give feedback.
All reactions