Repository navigation
Commit aa1af42
committed
feat(extractor): recognise Behavior.AssociatedObject as a self-owned source (#227)
A `Behavior`-derived class subscribing to (an element reached from) its own
base-class `AssociatedObject` accessor was tiered "injected" and warned OWN001
(the MahApps TiltBehavior FP from the issue #201 sweep). A behavior is attached
to and detached from exactly one element and cannot outlive being attached, so
that element is co-lifetimed with the subscriber — the same collectable
source<->this cycle the shipped self-owned-source exemption already encodes for a
constructed field, just reached through a base-class accessor.
The exemption is deliberately narrow, within the issue's fixed guardrails:
- subscriber gate: the class must derive from `Behavior` (`IsBehaviorSubscriber`,
direct-base simple-name match, mirroring `IsProcessLivedApplication`) — the
attach/detach pairing is what guarantees co-lifetime;
- source gate: the `+=` receiver must resolve, same-class and assignment-chain-
local, to `this.AssociatedObject` (`ResolvesToAssociatedObject`) — directly, via
a `var x = ...`/`is`-pattern local (only when never reassigned), or via a field
every assignment to which resolves to `AssociatedObject` (a single injected write
denies the proof). No interprocedural guessing.
Unlike #228 a lambda handler is fine here: the source is co-lifetimed with the
behavior, so a capture just closes the collectable cycle rather than pinning a
process-lived source to a shorter-lived local.
Pinned by AssociatedObjectSourceSample.cs: three silent positives (is-pattern
field, direct `this.AssociatedObject.Event`, bare-identifier local) and the four
controls the guardrails require — the unrelated injected source in the same
OnAttached, a non-Behavior subscriber, a field also assigned an injected value,
and a resolver-bound local reassigned before the `+=` — wired into the
wpf-extractor CI job with assertions both ways.
Verified locally with the real extractor (.NET 8): the sample yields exactly the
four control warnings, all three positives silent; a full-sample-set diff of old
vs new extractor output is byte-identical (zero regression). Gates: run_tests
276/276, ruff, mypy, yaml all green.
Closes #227
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U2AWb9N2VUsby2XpdftBcu1 parent b1ee961 commit aa1af42
4 files changed
Lines changed: 326 additions & 1 deletion
File tree
- .github/workflows
- docs/notes
- frontend/roslyn
- OwnSharp.Extractor
- samples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| |||
878 | 879 | | |
879 | 880 | | |
880 | 881 | | |
881 | | - | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
882 | 913 | | |
883 | 914 | | |
884 | 915 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
535 | 542 | | |
536 | 543 | | |
537 | 544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1009 | 1009 | | |
1010 | 1010 | | |
1011 | 1011 | | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1012 | 1138 | | |
1013 | 1139 | | |
1014 | 1140 | | |
| |||
4108 | 4234 | | |
4109 | 4235 | | |
4110 | 4236 | | |
| 4237 | + | |
| 4238 | + | |
| 4239 | + | |
| 4240 | + | |
| 4241 | + | |
4111 | 4242 | | |
4112 | 4243 | | |
4113 | 4244 | | |
| |||
4140 | 4271 | | |
4141 | 4272 | | |
4142 | 4273 | | |
| 4274 | + | |
| 4275 | + | |
| 4276 | + | |
| 4277 | + | |
| 4278 | + | |
| 4279 | + | |
| 4280 | + | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
| 4284 | + | |
| 4285 | + | |
4143 | 4286 | | |
4144 | 4287 | | |
4145 | 4288 | | |
| |||
0 commit comments