Introduce IProductService as a consistently-named replacement for IItemService#729
Conversation
|
Reveiw task created: https://virtocommerce.atlassian.net/browse/VCST-1195 |
|
These changes will break custom modules that override services with |
|
Thanks @artem-dudarev for sharing your concerns. Can you please explain in more detail how that update would be backward-incompatible? Maybe I'm missing something, but I intentionally left |
1. Overriden services with
|
c56ecb6 to
27fae1f
Compare
|
Thanks, Artem, now I see these problems. The first one is relatively easy to fix - I just brought back (see the latest commit) all the constructors that originally had The other one is much more tricky, we have to take into account the possibility that either |
|
@j-mok thank you for the update, we will check the code, if all is ok, we will merge, if not I will plan to applying the breaking changes on end of September after one of the next stable release because indeed it simplify dev experience. |
|
I've added another commit that deals with backward compatibility issue with custom
Let me know if that'll work, I think this should be 100% backward compatible now, but if not, I'll give it another try. |
|
Did you try to run this code? It doesn't work for me: Also, it doesn't compile because of an error in the |
…ervice do escape constructor ambiguity in DI
|
@artem-dudarev you're right, it turned out .NET DI has some peculiar constructor resolution rules that favor constructors with the most DI-resolvable parameters, and if there is no such single constructor, the DI fails. Following Microsoft's advice, I've added another constructor overload that accepts both the obsolete and the new product CRUD service parameters, thus making it the single constructor with the most DI-resolvable parameters. This solves the problem at the cost of increased complexity and having weird-looking constructors that discard one parameter, but unfortunately there's no other simple solution, like attribute-based constructor ambiguity resolutions mechanism. So, to sum it all up, classes that originally had a constructor that accepted
I've run the platform locally after introducing the 3rd constructor and it seems to start up without problems. I must admit though a small change in naming proved to be much more nuanced than I anticipated, but that's how things are when we want to keep backward compatibility. On the bright side, after transition period, all that code can be simplified back to the original level. |
The CRUD/search service pairs in catalog follow an intuitive pattern:
ICatalogService/ICatalogSearchServiceICategoryService/ICategorySearchServiceIVideoService/IVideoSearchServiceAnd then there's this:
IItemService/IProductSearchServiceI know this may be due to historical reasons, but it's very confusing, especially for newcomers to VC.
This PR introduces
IProductServiceto replaceIItemServicefor new client code to use (implementations are renamed too). At the same timeIItemServiceandItemServiceare still available and registered in DI to provide backward compatibility, but they're marked obsolete and could be removed in the future.The JavaScript and entity layers remain unchanged and keep using the term item.