[Parked] V9: Removal of Composers.cs, various composition attributes and IUserComposer #10900
Replies: 6 comments 28 replies
-
@p-m-j so in Vendr, we have our own eventing system as we don't want to rely on Umbraco's implementation and so if anyone wants to hook into Vendr's events, they are going to need to wait until Vendr is installed. This is pretty straight forward for people modifying I guess the thing to consider here is do we want to support "automatic install" whilst at the same time allow devs to define our custom events, which if we do, we will need composers and compose after in order to maintain sequencing. The alternative is, we say "if you want to extend Vendr, then you MUST use |
Beta Was this translation helpful? Give feedback.
-
Similar to @mattbrailsford - we've moved everything into IBuilderExtension methods. This does mean If someone needs uSync the can We do still trigger the builder extension in a composer - so people don't have to change startup.cs, not everyone installing our packages will be also changing the core code of the site. (maybe with v9 that is a change that is going to happen). |
Beta Was this translation helpful? Give feedback.
-
We can probably get rid of the These are very similar, but have (at least) the following differences:
So I guess the main reason for having the |
Beta Was this translation helpful? Give feedback.
-
Hi @p-m-j 👋 Quick answers to your questions, from my own usage as a package dev...
I'd like to make a note about Composer usage...
With v9/netcore, I can see from a dev perspective that |
Beta Was this translation helpful? Give feedback.
-
I had a quick catch up with @mattbrailsford on Monday to discuss his setup, not intending to keep discussions behind closed doors rather because it was expedient to do so. Matt had some excellent points which are as follows.
On the first point inspecting the ServiceCollection in the UmbracoBuilder and conditionally registering should work for most scenarios.
public class MyEcommerceComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
if (builder.Services.Any(x => x.ServiceType == typeof(IOrderNumberGenerator)))
{
return;
}
builder.Services.AddUnique<IOrderNumberGenerator, DefaultOrderNumberGenerator>();
}
} It's worth noting that if a user is able to implement the IOrderNumberGenerator interface here it is also seems likely that they could easily order calls in Startup.ConfigureServices. Composers are intended for low code setups and for more complicated technical packages there will be times where it makes more sense for users to just write some code, however an argument can be made that another package developer might like to add an extension to Vendr e.g. Our.Vendr.SomeERPVendor with low code support. On the second point, during previous discussions I have to admit I hadn't considered package developers own CollectionBuilders. I personally have an issue with the name of the class Composers which composers Composers (implementations of IComposer) as it makes communication harder than it needs to be, but a rename here could resolve this along with perhaps a little cleanup of the way state is managed inside the class. On the flip side I can argue that those who wish to have fine grained control over the order in which pipelines are constructed should be doing so in code where they have absolute control over ordering in a more transparent way than searching for composer implementations in various packages which may alter the setup. To handle collection builder setup in low code environments I have two possible workarounds.
Any feedback on the above would be sincerely appreciated. |
Beta Was this translation helpful? Give feedback.
-
Thanks everyone for contributing to the discussion! I think it’s clear that making these changes would cause unnecessary pain for package developers and so it will be parked until a better solution can be found, perhaps something like this #8653 (comment) from @lars-erik which looks like a great idea but probably isn’t feasible for v9 release any more but could make its way into v10.
builder.UsyncPipeline().Add<MyDependentPipelineThing>().DependsOn<AnotherPackagesPipelineThing>() Whilst there don’t seem to be any major concerns with the loss of IUserComposer I think it makes sense to mark it as obsolete and remove in a future version as it doesn’t cause any harm lingering a little longer. |
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.
-
Morning all,
There is a PR waiting to get merged which removes Composers.cs and the ordering/disabling attributes (not the concept of composers or the IComposer interface but the class which is responsible for ordering them). This can be found at #10881
Ordering composers used to be much more important, if you wished to replace a service in core you could ensure you implemented IUserComposer which would always run after ICoreComposer instances or use the ComposeAfter/ComposeBefore attributes.
Compose order controlled component initialization order, which was important for ensuring dependencies would be running before your code (Examine etc).
After the various refactors for v9, those dependencies Examine etc will start as required and be available without worrying about composition order. Additionally, we have the EventAggregator setup which should make it easy for packages to add lifecycle events that other packages can hook onto.
Composers are still around for use in packages but are never used by core, they will always run after core has added all of its service registrations. Composers are still useful in low/no code environments so it’s often worthwhile to support both Composers and Startup.ConfigureServices for registering your services either by providing another library with a Composer, or by conditionally exiting out of a composer if everything is already configured by other means (thanks @KevinJump for the idea here).
We would like to know if you have any use cases for ComposeAfter/ComposeBefore so that we can discuss alternatives and find any problems we have yet to think about.
The PR also removes IUserComposer, this would be a find and replace (to IComposer) fix in any packages that make use of the interface but we have also discussed bringing the interface back with an obsolete attribute if this is a concern for people?
I think if there are major objections, we are willing to hold off and just add obsolete messaging before rolling out changes in the next major version, but it’d be really nice to bite the bullet to clean up some of our legacy.
Beta Was this translation helpful? Give feedback.
All reactions