PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

Investigate source generators to improve some patterns

Open SeeminglyScience opened this issue 3 years ago • 2 comments

Dependency injection and "interface everything" can be very useful patterns but they also increase maintenance and debug complexity. Source generators can help by making references actually followable (DI) or reducing manual interface upkeep (interface everything).

For example:

https://github.com/DevTeam/Pure.DI

https://github.com/beakona/AutoInterface

Far from important though, marking up for grabs

SeeminglyScience avatar Mar 14 '22 17:03 SeeminglyScience

Do you mean use this to generate the tie-ins to Omnisharp ABCs?

JustinGrote avatar Mar 14 '22 23:03 JustinGrote

Do you mean use this to generate the tie-ins to Omnisharp ABCs?

So interface everything (I'm sure the pattern has an actual name but I dunno) is a pattern where you only take interfaces as much as possible because it makes mocking easier (well, possible).

So we have PsesInternalHost which is the main class handling all execution requests. But in most places we're actually taking IExecutionService (not the real name) which PsesInternalHost implements.

But every time you want to add a method to PsesInternalHost that something else uses, you also have to add it to IExecutionService. But there are no other IExecutionService implementations, it's just that one and only for testability.

So it'd be nice if instead of editing it in both places, we could just throw an attribute on whatever new method we're adding to PsesInternalHost that we want to use everywhere.

SeeminglyScience avatar Mar 14 '22 23:03 SeeminglyScience