Problem
PipelineBuilder uses ImmutableStack (LIFO) for middleware registration:
// Registration order (developer writes):
builder
.UseMiddlewareIf<PatchMiddleware>(true)
.UseMiddleware<CompressMiddleware>()
.UseMiddleware<HashMiddleware>();
// Actual LIFO execution order: Hash -> Compress -> Patch
A developer naturally expects registration order to match execution order. The LIFO semantics caused a bug in MacStrategy (fixed in #436) where the registration order was wrong because the author expected FIFO behavior.
Proposal
Change ImmutableStack to ImmutableQueue (FIFO) or List<IMiddleware> with forward iteration. This would require reversing the registration order in WindowsStrategy and LinuxStrategy (which currently depend on LIFO to get Hash executed first).
Scope
Pipeline/PipelineBuilder.cs
Strategy/WindowsStrategy.cs
Strategy/LinuxStrategy.cs
- Related PipelineBuilder tests
Priority
Low — the current code works correctly after #436, but this change would prevent future maintainers from making the same mistake.
Problem
PipelineBuilderusesImmutableStack(LIFO) for middleware registration:A developer naturally expects registration order to match execution order. The LIFO semantics caused a bug in MacStrategy (fixed in #436) where the registration order was wrong because the author expected FIFO behavior.
Proposal
Change
ImmutableStacktoImmutableQueue(FIFO) orList<IMiddleware>with forward iteration. This would require reversing the registration order in WindowsStrategy and LinuxStrategy (which currently depend on LIFO to get Hash executed first).Scope
Pipeline/PipelineBuilder.csStrategy/WindowsStrategy.csStrategy/LinuxStrategy.csPriority
Low — the current code works correctly after #436, but this change would prevent future maintainers from making the same mistake.