Repository navigation
fix: support mocking types from extern-aliased references - #921
Conversation
Types from a reference that is only reachable through an extern alias do not resolve under `global::`, so the generated mock failed to compile (CS0400). The generator now qualifies such types with their alias and declares it in the generated file.
Test Results 31 files ± 0 31 suites ±0 48m 15s ⏱️ + 10m 23s Results for commit 22ade35. ± Comparison against base commit 797cfc2. This pull request removes 22 and adds 21 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsDetails
Details
Details
Details
Details
Details
|
An unresolved namespace-qualified type in a mocked member made the generator throw whenever an extern alias was present, dropping every mock. Attribute array elements ignored their kind, so non-zero enums and types inside arrays did not compile. Every output now receives the aliases explicitly so no file can miss the directive.
|
…aliased references (#921) by Valentin Breuß
…aliased references (#921) by Valentin Breuß



Types from a reference that is only reachable through an extern alias (for example
<Aliases>Legacy</Aliases>on aPackageReference/ProjectReference, typically used to consume two versions of the same assembly) do not resolve underglobal::. The generated mock therefore failed to compile with CS0400, so such types could not be mocked at all.Changes
Legacy::Ns.IFoo) instead ofglobal::. This covers mocked types, member signatures, containing types of explicit implementations, generic constraints, enum default values and attribute arguments.extern alias Legacy;) directly after the auto-generated header. Every generator output receives the alias list, so no file can use an alias without declaring it.global(a second reference without an alias, orAliases="global,Legacy") keep theglobal::qualification.new Color[]{1}, CS0266) andTypeelements as bare names (new Type[]{string}, CS1525), independent of extern aliases. Anullarray argument now becomesnull.Tests
Implementing<T>()combinations, indexers, events, enum defaults and attributes (including enum andtypeofvalues inside arrays) are qualified with the alias. Every file using the alias also declares it.global, as a separate reference and viaglobal,Alias, keepsglobal::.Type, mixedobject[]andnullvalues compile.