Commit 80b3e1e
committed
refactor(component-model)!: six attributes get .NET's get-only shape (#2403)
Six System::ComponentModel attributes published a BARE MUTABLE PUBLIC DATA
MEMBER where .NET publishes a get-only property, and most had no Yes/No/Default
statics and no equality members at all.
WHAT MAKES THIS MORE THAN A STYLE POINT IS THAT THE PORT WAS INCONSISTENT WITH
ITSELF INSIDE ONE FILE. CategoryAttribute, BrowsableAttribute,
DisplayNameAttribute and DescriptionAttribute -- in that very header and its
neighbour -- already had the correct shape: private member, getXxxProperty(),
the static set, and Equals/GetHashCode/getIsDefaultAttributeProperty. The other
six did not:
ReadOnlyAttribute public bool IsReadOnly, Yes/No, NO Default
ImmutableObjectAttribute public bool Immutable, no statics
LocalizableAttribute public bool IsLocalizable, no statics
MergablePropertyAttribute public bool AllowMerge, no statics
NotifyParentPropertyAttribute public bool NotifyParent, no statics
RefreshPropertiesAttribute public Refresh RefreshProperties_, no statics
All six are now `final` for .NET's `sealed`, with a get-only accessor, the full
static set, and the three equality members.
REFRESHPROPERTIES BECOMES A TOP-LEVEL ENUM. .NET declares it in its own file
(RefreshProperties.cs); this port nested it as RefreshPropertiesAttribute::Refresh,
differing in BOTH the name and the scope.
THE DEFAULTS ARE NOT UNIFORM AND THAT IS .NET'S.
MergablePropertyAttribute.Default is YES (MergablePropertyAttribute.cs:12) where
the other four boolean attributes default to NO, and BrowsableAttribute.Default
is Yes too, which this port already had right. A repair that "harmonised" the
five would be wrong HERE AND NOWHERE ELSE, so the asymmetry is pinned in one
case rather than scattered as five unrelated literals.
ONE DIVERGENCE IS DELIBERATE AND IS PINNED. .NET's GetHashCode for all six is
base.GetHashCode() -- IDENTITY -- while its Equals is VALUE-based, so two equal
.NET instances can hash differently: a hash-contract violation in the reference
itself. This port does not reproduce it, and the reason is WRITTEN DOWN RATHER
THAN CHOSEN -- System/Attribute.hpp's own doc-comment states the house rule ("A
subclass that needs value equality must override BOTH Equals and GetHashCode ...
Overriding only one breaks the equals/hashCode contract") and the four
already-correct siblings use a value hash. Reproducing .NET here would
contradict the port's own stated rule and its own neighbours. MUTATION M7
ADOPTS .NET'S IDENTITY HASH AND IS CAUGHT.
THE MODULE'S WHOLE PRIOR COVERAGE FOR THESE SIX WAS CONSTRUCTOR ROUND-TRIPS
THROUGH THE PUBLIC FIELD. Nothing asserted the statics, the equality members or
the defaults, so .NET's Default values -- the actual contract of a metadata
attribute -- were unpinned. Six cases now pin them. That is the point worth
carrying: component-model HAS its own test executable, so "has tests" is not
"is covered".
Landed under SA-8 with SA-2's five conditions. NO VTABLE CHANGE: Equals,
GetHashCode and getIsDefaultAttributeProperty are already virtual on
System::Attribute, so these are overrides of existing slots, not new ones.
First-party migration: 8 sites, all in this module's own test file, every one
named by the compiler. Negative fixture with 8 sites -- a read AND A WRITE for
ReadOnlyAttribute, a read for each of the other five, and one for the enum's
scope. The WRITE earns its own site because it is the spelling a careless
migration would have kept longest: it compiled silently against the old shape
while changing the attribute's meaning. Set 49/248 -> 50/256. Downstream,
measured: zero System::ComponentModel sites in both consumers, recorded as #2404.
Seven mutations, ALL CAUGHT, three at compile time -- the only way C++ reports a
shape.
A PROCESS NOTE WORTH KEEPING. An early build of this change appeared to report
ZERO ERRORS and was nearly taken at face value. The cause: `cmake --build ... -k
200` is NOT keep-going -- `-k` must follow `--`, so CMake printed its usage
banner and exited. That is CLAUDE.md rule 2's own recorded #2395 trap in a new
form, and A MIS-PASSED -k IS WORSE THAN NONE, because it looks like success.
Gate 17,637 / 38 executables: 17,637 run, 17,637 passed, 0 failed, 0 skipped,
recounted from the per-executable logs with every executable run separately and
continuing past failures. +6 on 17,631, in SharpRuntimeTests_ComponentModel
(98 -> 104); no other executable moved. Zero build warnings at --parallel 2;
module boundaries and the generated catalogue green.1 parent c86259b commit 80b3e1e
8 files changed
Lines changed: 580 additions & 54 deletions
File tree
- docs
- modules/component-model
- include/System/ComponentModel
- tests/System/ComponentModel
- test/consumer
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
164 | 172 | | |
165 | 173 | | |
166 | 174 | | |
| 175 | + | |
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
| |||
| 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 | + | |
0 commit comments