Skip to content

Commit 9902dc2

Browse files
committed
Add some code documentation
1 parent 6ee5ab1 commit 9902dc2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Castle.Core/DynamicProxy/Contributors/CompositeTypeContributor.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ public MembersCollectorSink(MetaType model, CompositeTypeContributor contributor
148148
this.contributor = contributor;
149149
}
150150

151+
// You may have noticed that most contributors do not query `MetaType` at all,
152+
// but only their own collections. So perhaps you are wondering why collected
153+
// type elements are added to `model` at all, and not just to `contributor`?
154+
//
155+
// TL;DR: This prevents member name collisions in the generated proxy type.
156+
//
157+
// `MetaType` uses `TypeElementCollection`s internally, which switches members
158+
// to explicit implementation whenever a name collision with a previously added
159+
// member occurs.
160+
//
161+
// It would be pointless to do this at the level of the individual contributor,
162+
// because name collisions could still occur across several contributors. This
163+
// is why they all share the same `MetaType` instance.
164+
151165
public void Add(MetaEvent @event)
152166
{
153167
model.AddEvent(@event);

0 commit comments

Comments
 (0)