ava-innersource / Liquid-Application-Framework-1.0-deprecated

Liquid is a framework to speed up the development of microservices
MIT License
25 stars 14 forks source link

Refactor WorkBench #140

Open bruno-brant opened 4 years ago

bruno-brant commented 4 years ago

There's a large number of issues with Liquid's service locator, WorkBench:

I think a redesign is in order.

bruno-brant commented 4 years ago

Another thing to add is the enum that defines the possible services. Well, the enum doesn't prevent us from doing a mismatch.

Take a look, for instance, here, AddToCache:

https://github.com/Avanade/Liquid-Application-Framework/blob/72349eace2d177d8f722aaea9c42584475d53504/src/Liquid.Base/WorkBench.cs#L50

What prevents us from, let's say:

ILightRepository repo = null;
AddToCache(WorkBenchServiceType.Event, repo)

Nothing (also, nothing prevents us to insert a null there, since null checking isn't done).

So this shouldn't be a public interface if we want to actually restrict what a user can insert there. But then again, this is just because #39, right? We shouldn't be really restricting stuff this way.

And this flaw happens here as well:

https://github.com/Avanade/Liquid-Application-Framework/blob/f2b5da239bd9f411386344053989609abcb4f1ce/src/Liquid.Base/HealthCheck/LightHealth%20.cs#L73

Inside this code, there's a (T)service, a code that can very easily fail.

So, one more vote to remove this class once and for all.