aspnet / LibraryManager

Other
446 stars 78 forks source link

Introduce OperationResult type #740

Closed jimmylewis closed 2 months ago

jimmylewis commented 2 months ago

This type is a clone of LibraryOperationResult, but made generic. LibraryOperationResult is similar to an Option or Maybe type, with specific metadata - whether the operation was cancelled, had errors, or was already up-to-date (all very appropriate for LibMan scenarios). It's a useful type but limited to ILibraryInstallationState. Introducing a generic allows the same semantics, but with any result type. (We could deprecate LibraryOperationResult in the future, but I wanted to keep this PR as minimal as possible.)

There is one semantic difference between OperationResult and LibraryOperationResult: in the new type, a null result is considered unsuccessful, even if there are no errors provided. That was the implied usage in LOR, but not explicit; the new type makes this explicit.

I also chose not to make an interface abstraction for this type, and to add it to the Contracts project. The interface seemed like an unnecessary burden for a simple wrapper type. I'm adding it to Contracts because I plan to use this on a new method in IProvider, so it needs to be at this level of the LibMan architecture.