The Aspid.MVVM.Generators.Tests/ project is currently empty (no .cs files since the Global rename commit). The new auto-binder-fields pipeline introduced in PR #13 (VirtualBinderFields collector + BinderFieldsBody emitter) ships without regression coverage. This issue tracks adding it.
Required test cases
AutoBinderFields default-on: [View] over a MonoBehaviour partial that implements IView<TVm> where TVm has at least one [Bind] member not already declared on the View — generated <View>.BinderFields.g.cs contains a _<name>: MonoBinder[] field decorated with [RequireBinder(typeof(<expected>))] and [SerializeField].
AutoBinderFields = false: same input, [View(AutoBinderFields = false)] — no BinderFields.g.cs partial emitted.
ScriptableObject base: View deriving from UnityEngine.ScriptableObject — no BinderFields.g.cs partial regardless of AutoBinderFields value.
- Skip already-declared: if the View already declares
private MonoBinder[] _foo; for Foo (or inherits a binder field for it from a base [View]), it is not duplicated as a virtual field.
[Header] propagation: VM member tagged [UnityEngine.Header("X")] → generated field decorated with [Header("X")].
HeaderGroup propagation (single): VM member tagged [Aspid.MVVM.HeaderGroup("G")] → generated field decorated with [Aspid.MVVM.HeaderGroup("G")].
HeaderGroupStart / HeaderGroupEnd range: VM members between [HeaderGroupStart("G")] and [HeaderGroupEnd] → all generated fields in that range carry [HeaderGroup("G")]; the field right after HeaderGroupEnd does not.
RequireBinder types: when a VM member has multiple bindable shapes (e.g. IBindableMember<int> + IBindableMember<int?>), the generated [RequireBinder] lists each required type once, nullable suffix stripped.
Infrastructure prerequisites
The test project is xUnit + Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit but has no source files. Setting up tests requires:
- A helper that builds a
CSharpCompilation referencing Aspid.MVVM + UnityEngine stub types (ViewAttribute with AutoBinderFields property, IView<T>, IBindableMember<T>, BindAttribute, MonoBinder, IBinder, HeaderGroupAttribute / HeaderGroupStartAttribute / HeaderGroupEndAttribute, RequireBinderAttribute, UnityEngine.MonoBehaviour, SerializeField, Header, ScriptableObject).
- A
CSharpGeneratorDriver wrapper that runs ViewGenerator on a given source string and exposes runResult.Results[0].GeneratedSources for assertions.
Out of scope here
- Initialization-pipeline /
InitializeBody regression — covered separately if needed.
- Full
BindableMembersFactory coverage — only the subset reachable via VirtualBinderFields.Collect matters for this issue.
The
Aspid.MVVM.Generators.Tests/project is currently empty (no.csfiles since theGlobal renamecommit). The new auto-binder-fields pipeline introduced in PR #13 (VirtualBinderFieldscollector +BinderFieldsBodyemitter) ships without regression coverage. This issue tracks adding it.Required test cases
AutoBinderFieldsdefault-on:[View]over aMonoBehaviourpartial that implementsIView<TVm>whereTVmhas at least one[Bind]member not already declared on the View — generated<View>.BinderFields.g.cscontains a_<name>: MonoBinder[]field decorated with[RequireBinder(typeof(<expected>))]and[SerializeField].AutoBinderFields = false: same input,[View(AutoBinderFields = false)]— noBinderFields.g.cspartial emitted.ScriptableObjectbase: View deriving fromUnityEngine.ScriptableObject— noBinderFields.g.cspartial regardless ofAutoBinderFieldsvalue.private MonoBinder[] _foo;forFoo(or inherits a binder field for it from a base[View]), it is not duplicated as a virtual field.[Header]propagation: VM member tagged[UnityEngine.Header("X")]→ generated field decorated with[Header("X")].HeaderGrouppropagation (single): VM member tagged[Aspid.MVVM.HeaderGroup("G")]→ generated field decorated with[Aspid.MVVM.HeaderGroup("G")].HeaderGroupStart/HeaderGroupEndrange: VM members between[HeaderGroupStart("G")]and[HeaderGroupEnd]→ all generated fields in that range carry[HeaderGroup("G")]; the field right afterHeaderGroupEnddoes not.RequireBindertypes: when a VM member has multiple bindable shapes (e.g.IBindableMember<int>+IBindableMember<int?>), the generated[RequireBinder]lists each required type once, nullable suffix stripped.Infrastructure prerequisites
The test project is xUnit +
Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnitbut has no source files. Setting up tests requires:CSharpCompilationreferencingAspid.MVVM+UnityEnginestub types (ViewAttributewithAutoBinderFieldsproperty,IView<T>,IBindableMember<T>,BindAttribute,MonoBinder,IBinder,HeaderGroupAttribute/HeaderGroupStartAttribute/HeaderGroupEndAttribute,RequireBinderAttribute,UnityEngine.MonoBehaviour,SerializeField,Header,ScriptableObject).CSharpGeneratorDriverwrapper that runsViewGeneratoron a given source string and exposesrunResult.Results[0].GeneratedSourcesfor assertions.Out of scope here
InitializeBodyregression — covered separately if needed.BindableMembersFactorycoverage — only the subset reachable viaVirtualBinderFields.Collectmatters for this issue.