Add pin tests for gaps found in downstream usage - #78
Conversation
…ver lazy dynamic objects, and empty marker-interface combination Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add PinTests.cs to the WASM test project so these tests run in the browser-WASM test leg.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds four focused pin tests for runtime interface proxying, lazy dynamic collections, and marker-interface composition.
Changes:
- Tests runtime-
TypeDynamicActLikecalls. - Tests lazy dynamic
IList<int>proxy behavior. - Tests combining a proxy with an empty marker interface.
| File | Description |
|---|---|
Tests/UnitTestImpromptuInterface/PinTests.cs |
Adds four targeted tests and supporting proxy types; the file is not yet included in the WASM test project. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- DynamicActLikeWithRuntimeTypeRepeatedTest asserted only the two names, which the unwrapped ExpandoObject answers just as well: replacing the whole entry point with `=> originalDynamic` left it green. It now asserts each result is a proxy, that they are distinct instances, and that they share a proxy type - the reuse its comment claimed and nothing checked. The same mutation now fails it. - Count the factory's calls in the factory. FactoryCallCount++ sat behind the `_target == null` guard, so it could never exceed 1 whatever the proxy did, and asserting it was 1 pinned nothing. - Exercise TrySetIndex, which the fixture implements and no test reached. - PinTests.cs is linked into the wasm project, which lists its sources explicitly. It pulls in neither Moq nor IronPython, the two documented exclusions, and it is the only generic-collection-over-DynamicObject case that leg gets - the comparable ones are in the excluded Linq.cs. - The header and the "would go in SupportDefinitions" note read as a proposal to a reviewer rather than comments in a committed file; the runtime-Type gap is the public static entry point, not the behaviour, which ActLikeCaster covers heavily. Unused using removed. 207 on net8.0 and net10.0, 213 on net47, 118 on browser-wasm. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016mwfq4oeZW8SiD4HjTHYdg
|
That one is right, and it is fixed in a323270 — It belongs there rather than being excluded: the file pulls in neither Moq nor IronPython, which are the two documented reasons A cold review of the same commit turned up four other things, all in a323270 as well:
207 on net8.0 and net10.0, 213 on net47, 118 on browser-wasm. |

Why
Auditing a large downstream consumer (a separate private solution) for how it uses
ImpromptuInterfacesurfaced a few real API usage patterns that aren't exercised anywhere in this test suite. This PR adds pin tests for those specific gaps only; naming is intentionally generic (no downstream business terms).Gaps covered
Impromptu.DynamicActLike(object, params Type[])(the non-generic, runtime-Typeoverload) has no existing test coverage anywhere in the suite. Added a basic round-trip test plus a repeated-call test with the same runtimeType.ActLike<IList<T>>(a generic BCL collection interface) proxied over an object that only implements the dynamic-dispatch protocol (TryGetMember/TryInvokeMember/TryGetIndex/TrySetIndex), simulating lazy-materialized proxies (e.g.Dynamitey.DynamicObjects.Lazy). Only a non-generic array/indexer case (IStringIntIndexer) was previously tested; this exercisesCount, indexer get,Contains,Add, andGetEnumerator()all being synthesized by the proxy, plus confirms the lazy factory only runs once.typeof(...)overload.DoubleInterfacetest(existing) only combines two interfaces that both declare members; this adds coverage for a marker interface with zero members.Validation
All 207 tests pass (203 existing + 4 new).