Commit 6eb172d
committed
fix(extractor): exempt process-host AppDomain event subscriptions from OWN014 (mined Npgsql)
Mining npgsql/npgsql surfaced this: PoolManager's static ctor subscribes
`AppDomain.CurrentDomain.{DomainUnload,ProcessExit} += (_,_) => ClearAll()` — a deliberate
"close idle connectors on appdomain unload (web-app redeployment)" hook (#491) — and the
detector reported it as an OWN014 region escape. But subscribing to a process-host AppDomain
event is never a leak: ProcessExit/DomainUnload run at shutdown, UnhandledException /
FirstChanceException on every unhandled throw, and the AppDomain IS the process host — the
handler is MEANT to live for the whole process. Promoting the subscriber to "the AppDomain's
lifetime" is the intent, not a leak.
IsProcessLifetimeAppDomainEvent exempts these four System.AppDomain events from the OWN014
region escape (alongside the self-owned-source and static-handler exemptions). Scoped to the
event's resolved declaring type, so a project's own `AppDomain`-named type is not matched, and a
non-AppDomain process-lived static event still escapes.
Regression sample AppDomainShutdownSample.cs: ShutdownCleanup (ProcessExit/DomainUnload/
UnhandledException lambdas) stays silent; NonAppDomainSubscriber (a lambda on a non-AppDomain
static event) still raises OWN014.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgED1 parent b787ffc commit 6eb172d
3 files changed
Lines changed: 69 additions & 1 deletion
File tree
- .github/workflows
- frontend/roslyn
- OwnSharp.Extractor
- samples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
304 | 314 | | |
305 | 315 | | |
306 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
193 | 206 | | |
194 | 207 | | |
195 | 208 | | |
| |||
2065 | 2078 | | |
2066 | 2079 | | |
2067 | 2080 | | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
2068 | 2085 | | |
2069 | | - | |
| 2086 | + | |
| 2087 | + | |
2070 | 2088 | | |
2071 | 2089 | | |
2072 | 2090 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments