Empty-mock creation eagerly allocated several infrastructure objects that a
mock which is only created (never set up, invoked, or verified) never needs.
Defer them to first use:
- MockSetups and the scenario state are now lazy in MockRegistry; the Scenario
getter no longer allocates on the invocation hot path, and the method-lookup
read paths short-circuit to Array.Empty when no setups have been registered.
- FastMockInteractions._verifiedLock is allocated only on the verification path.
- The whole FastMockInteractions store is now built lazily by MockRegistry from a
stored member count (new public MockRegistry(MockBehavior, int, object?[]?)
ctor); the generator passes MemberCount instead of constructing the store up
front. HttpClient's shared-store factory path stays eager.
CreateMock for an empty interface mock drops from ~440 B / ~51 ns to
~184 B / ~18 ns (3 heap objects instead of 7).
Updates the public-API and generator-output snapshots accordingly.
Empty-mock creation eagerly allocated several infrastructure objects that a mock which is only created (never set up, invoked, or verified) never needs. Defer them all to first use:
MockSetupsand the scenario state are now lazy inMockRegistry; theScenariogetter no longer allocates on the invocation hot path, and the method-lookup read paths short-circuit toArray.Emptywhen no setups have been registered.FastMockInteractions._verifiedLockis allocated only on the verification path.FastMockInteractionsstore is now built lazily byMockRegistryfrom a stored member count (new publicMockRegistry(MockBehavior, int, object?[]?)ctor); the generator passesMemberCountinstead of constructing the store up front. HttpClient's shared-store factory path stays eager._setupsByMemberIdLock(taken only by setup-registration paths) is allocated lazily too, removing the last eager allocation.Empty interface-mock creation drops from ~440 B / ~51 ns (7 heap objects) to ~160 B / ~18 ns (2 heap objects: the mock and its
MockRegistry).The full create→setup→invoke→verify workflow benchmarks (method/property/indexer/event/callback) show no time regressions and slightly lower allocations, since each workflow no longer pays for the collaborators it doesn't touch.
Updates the public-API and generator-output snapshots accordingly.