Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StructureMap Transient Middleware Resolution #1619

Merged
merged 2 commits into from
Jan 18, 2025

Conversation

hwoodiwiss
Copy link
Member

In StructureMap the Transient lifetime is more akin to MEDI's Scoped lifetime, where a single object instance will be created for each top level call to Container.GetInstance().

Currently, the JustSayingRegistry causes a throw at startup if you don't clear and re-register these middleware as AlwaysUnique.

https://structuremap.github.io/object-lifecycle/supported-lifecycles/

In StructureMap the Transient lifetime is more akin to MEDI's Scoped lifetime, where a single object instance will be created for each top level call to `Container.GetInstance()`.

Currently, the JustSayingRegistry causes a throw at startup if you don't clear and re-register these middleware as AlwaysUnique.

https://structuremap.github.io/object-lifecycle/supported-lifecycles/
@hwoodiwiss hwoodiwiss requested a review from a team as a code owner January 18, 2025 09:45
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.36%. Comparing base (d046a44) to head (cbb0f1e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ging/Middleware/Handle/HandlerMiddlewareBuilder.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1619      +/-   ##
==========================================
- Coverage   78.56%   78.36%   -0.20%     
==========================================
  Files         141      141              
  Lines        3550     3550              
  Branches      501      501              
==========================================
- Hits         2789     2782       -7     
- Misses        512      519       +7     
  Partials      249      249              
Flag Coverage Δ
linux 78.36% <66.66%> (-0.20%) ⬇️
macos 47.07% <0.00%> (-0.29%) ⬇️
windows 47.35% <0.00%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@martincostello martincostello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write a regression test for this?

@hwoodiwiss hwoodiwiss merged commit c632bbf into main Jan 18, 2025
12 of 14 checks passed
@hwoodiwiss hwoodiwiss deleted the fix-structuremap-transient-middleware branch January 18, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants