Refactor TestClassModelBuilder into focused files (#9910)#9911
Conversation
Split the 933-line TestClassModelBuilder.cs into smaller, single-responsibility files within the same Generators namespace: - DynamicDataSourceBuilder: [DynamicData] source resolution - AttributeMaterializationHelper: attribute collection/materialization + TypedConstant conversion - DataRowBuilder: [DataRow] parsing - SymbolReferenceabilityHelper: reusable accessibility/referenceability predicates - TestMemberValidationHelper: member eligibility, unsupported-shape reporting, signature keys - SymbolDisplayFormats: shared fully-qualified SymbolDisplayFormat TestClassModelBuilder now only holds top-level orchestration. Behavior is unchanged; all files are under 300 lines. Updated the BuildAttributes call site in MSTestReflectionMetadataGenerator. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2fc1a0b3-faab-4c48-a40a-23eae6fa9386
There was a problem hiding this comment.
Pull request overview
Refactors the source-generation model builder into focused helpers while preserving behavior and API visibility.
Changes:
- Extracts dynamic data, data row, attribute, validation, and symbol logic.
- Centralizes symbol display formatting.
- Updates orchestration and assembly metadata call sites.
Show a summary per file
| File | Description |
|---|---|
TestClassModelBuilder.cs |
Retains top-level model orchestration. |
DynamicDataSourceBuilder.cs |
Handles dynamic-data resolution. |
AttributeMaterializationHelper.cs |
Handles attribute inheritance and conversion. |
TestMemberValidationHelper.cs |
Handles member validation and signatures. |
SymbolReferenceabilityHelper.cs |
Centralizes referenceability checks. |
DataRowBuilder.cs |
Handles data-row parsing. |
SymbolDisplayFormats.cs |
Shares symbol display formatting. |
MSTestReflectionMetadataGenerator.cs |
Uses the extracted attribute helper. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 0
- Review effort level: Medium
…ach filters Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2fc1a0b3-faab-4c48-a40a-23eae6fa9386
Regenerated via UpdateXlf. The last localized check-in added translations for 'GlobalTestFixtureShouldBeValidClassLayout' (fr) and 'SlowTestStillRunning' (ru) that XliffTasks rejects (placeholder mismatch), breaking the build with "xlf is out-of-date with resx". UpdateXlf resets those two units to state="new" so the build passes; they will be re-translated on the next localization pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4350f662-0e5d-4e05-b156-1ef619da3b9e
🔍 Build Failure AnalysisRoot Cause: Duplicate
|
| File | Issue | Fix |
|---|---|---|
src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf |
Duplicate <target> in GlobalTestFixtureShouldBeValidDescription |
Remove lines 581–595 |
src/Platform/.../GitHubActionsResources.ru.xlf |
Duplicate <target> in SlowTestStillRunning |
Remove line 78 |
Both issues appear to be from a OneLocBuild merge that inserted a translated <target> without removing the pre-existing state="new" placeholder.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpg
To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 360.1 AIC · ⌖ 5.2 AIC · ⊞ 6K · [◷]( · ◷)
There was a problem hiding this comment.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpg
To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 360.1 AIC · ⌖ 5.2 AIC · ⊞ 6K · ◷
Comments that could not be inline-anchored
src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/Resources/xlf/GitHubActionsResources.ru.xlf:78
Duplicate <target> element — XLF schema allows only one per <trans-unit>. The Russian translation on the line above is correct; remove this English fallback.
src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf:595
Duplicate <target> element — XLF allows only one per <trans-unit>. The French translation is in the target above (lines 566-580). Remove this duplicate English-only block.
Fixes #9910.
Summary
Splits the 933-line
src/Analyzers/MSTest.SourceGeneration/Generators/TestClassModelBuilder.csinto smaller, single-responsibility files. All new types remaininternal staticin the same...SourceGeneration.Generatorsnamespace, so there is no change to the internal or public API surface and behavior is preserved.New files (all under 300 lines)
TestClassModelBuilder.cs(slimmed)TestClassModel, delegates to helpersDynamicDataSourceBuilder.cs[DynamicData]sources (incl. theDynamicDataSourceTypeenum)AttributeMaterializationHelper.csAttributeData→ model conversionTestMemberValidationHelper.csSymbolReferenceabilityHelper.csDataRowBuilder.cs[DataRow]parsingSymbolDisplayFormats.csSymbolDisplayFormatused across the buildersThe public
BuildAttributesentry point moved toAttributeMaterializationHelper; its only external caller (MSTestReflectionMetadataGenerator) was updated accordingly.Notes
MSTest.Analyzers.Shared.SymbolAccessibilityHelper(linked from../Shared/) was not merged into, since it is a separate, cross-project concern. The builder's private referenceability predicates went into a newSymbolReferenceabilityHelperto avoid a name/namespace clash.Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.SourceGeneration.Generators.Validation
.\build.cmd— Build succeeded, 0 warnings, 0 errors.MSTest.SourceGeneration.UnitTests(net8.0) — 113/113 passed.