Commit 4d5e897
committed
fix(runtime): MarshalAsAttribute gets .NET's field types and the COM enums (#1980, group G-5)
Rule-14 sweep. Field types are the contract here for the same reason G-2's
values were: these types exist to preserve managed metadata, and a field
typed as a loose integer where .NET types it as an enum lets any number be
stored where only a marshalling kind is meaningful.
Value becomes get-only (SA-8), ArraySubType becomes an UnmanagedType,
SizeParamIndex becomes a short, SafeArraySubType and IidParameterIndex arrive,
the class is sealed, and VarEnum / ComInterfaceType / ClassInterfaceType are
added. Both new enum-typed fields default to 0, which is not a declared
enumerator -- the same deliberate choice G-2 recorded for the CharSet
defaults, because .NET's fields have no initializer either.
One member stays absent deliberately: .NET types SafeArrayUserDefinedSubType
as Type?, which is reflection, and inventing a second string would look like
parity while storing something else. MarshalTypeRef survives as a
name-carrying string only because it already did.
Six mutations, all caught, four at compile time. M4 is the one worth keeping:
.NET's VarEnum jumps from VT_DECIMAL = 14 to VT_I1 = 16, and asserting those
neighbours catches a renumbering but NOT an insertion -- adding
VT_UNUSED15 = 15 went uncaught, because C++ cannot enumerate an enum's
members. The fix is an exhaustive switch with no default: the build runs
-Wall -Wextra -Werror, so -Wswitch turns any unhandled enumerator into
"error: enumeration value 'VT_UNUSED15' not handled in switch". That pins
membership, which no value assertion can, and it fails the other way too.
Fixture set 42/219 -> 43/223; site 2 is the assignment to Value that let a
caller retarget an attribute after construction. First-party migration was
one site, found by the compiler. Downstream measured: 0 sites in both.
#1980 now has G-3 alone left.
Gate: 17,515 run, 17,515 passed, 0 failed, 0 skipped across 38 executables
(+9 on 17,506; SharpRuntimeTests_Runtime 189 -> 198; no other executable
moved). Module graph unchanged at 41/93.1 parent 0bd261c commit 4d5e897
6 files changed
Lines changed: 449 additions & 9 deletions
File tree
- docs
- modules/runtime
- include/System/Runtime/InteropServices
- tests/System/Runtime
- test/consumer
Large diffs are not rendered by default.
| 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 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
Lines changed: 106 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
112 | 158 | | |
113 | 159 | | |
114 | 160 | | |
| |||
162 | 208 | | |
163 | 209 | | |
164 | 210 | | |
165 | | - | |
| 211 | + | |
| 212 | + | |
166 | 213 | | |
167 | | - | |
168 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
169 | 241 | | |
170 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
171 | 254 | | |
172 | 255 | | |
173 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
174 | 264 | | |
175 | 265 | | |
176 | | - | |
| 266 | + | |
177 | 267 | | |
178 | 268 | | |
179 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
180 | 279 | | |
181 | 280 | | |
182 | 281 | | |
| |||
0 commit comments