Commit 508285a
committed
Fix decorators not respecting ExternallyOwned on decorated service (#1402)
When a decorated service is registered as ExternallyOwned, the decorator
wrapping it was still tracked for disposal by the lifetime scope because
the dynamically-created decorator registration defaults to OwnedByLifetimeScope.
In DisposalTrackingMiddleware, when the context has a DecoratorTarget, that
target IS the underlying component registration. If that underlying registration
is ExternallyOwned, the decorator should inherit that intent and also not be
tracked for disposal — the caller has opted out of lifetime management for
the entire decorated chain.1 parent f8d4095 commit 508285a
2 files changed
Lines changed: 33 additions & 1 deletion
File tree
- src/Autofac/Core/Resolving/Middleware
- test/Autofac.Specification.Test/Features
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
675 | 675 | | |
676 | 676 | | |
677 | 677 | | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
678 | 704 | | |
679 | 705 | | |
680 | 706 | | |
| |||
0 commit comments