feat: add lifetime-safety diagnostics (AWT105 captive, AWT106 disposable transient, AWT107 conflicting lifetime)#14
Merged
Conversation
Test Results 18 files ± 0 18 suites ±0 33s ⏱️ +22s Results for commit d238954. ± Comparison against base commit 10975b1. This pull request removes 5 and adds 18 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
…ble transient, AWT107 conflicting lifetime) Three compile-time checks over the resolved object graph. AWT105 (error) flags a captive dependency — a singleton that depends, directly or transitively through transients, on a shorter-lived scoped service it would capture for the container's lifetime. AWT106 (warning) flags a disposable transient, whose root-resolved instances are not released until the container is disposed and so accumulate; resolving it from a scope releases it with the scope. AWT107 (error) flags an implementation registered with two different lifetimes, which coalescing into a single instance would otherwise silently reconcile to the first. Registering one implementation under several services with the same lifetime stays valid (no AWT107). Generator tests cover each diagnostic, the transitive captive case, and the same-lifetime multi-service case staying clean.
35ca5a8 to
d238954
Compare
…lias in AWT105 - AWT107: detect conflicting lifetimes even when the same service type is re-registered with a different lifetime; the per-service dedup previously skipped the conflict and silently dropped one lifetime - AWT105: name the service alias the constructor actually referenced rather than an arbitrary first service type of the captured implementation - AWT106: document that it is reported per registration, not per resolution site (advisory warning) Refactor: split the diagnostic tests out of GeneralTests into per-diagnostic DiagnosticTests partial classes (one file each) and add false-positive coverage for AWT105 (singleton->singleton, transient/scoped->scoped) and AWT106 (disposable singleton/scoped, non-disposable transient). Also tighten the test IAwaitenContainer mock's TryResolve with [NotNullWhen(true)].
d238954 to
e292ab6
Compare
|
|
This is addressed in release v0.1.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Three compile-time checks over the resolved object graph. AWT105 (error) flags a captive dependency — a singleton that depends, directly or transitively through transients, on a shorter-lived scoped service it would capture for the container's lifetime. AWT106 (warning) flags a disposable transient, whose root-resolved instances are not released until the container is disposed and so accumulate; resolving it from a scope releases it with the scope. AWT107 (error) flags an implementation registered with two different lifetimes, which coalescing into a single instance would otherwise silently reconcile to the first.
Registering one implementation under several services with the same lifetime stays valid (no AWT107). Generator tests cover each diagnostic, the transitive captive case, and the same-lifetime multi-service case staying clean.