Code Quality Fixes: Dead Code, Access Modifiers, and Cache Leak
Internal code quality fixes: removes production rendering heuristics tied to test fixtures, eliminates dead scaffolding code, corrects access modifiers, and closes a [ThreadStatic] cache leak.
🐛 Bug fixes
-
Production snapshot heuristics removed (
ReportRenderer.cs): DeletedIsKnownAfterApplyCompatibilityScenarioandIsEphemeralOpenCompatibilityScenariohelper methods that fingerprinted test-fixture resource counts to change table formatting in production builds. The heuristics were originally added as compatibility shims and had been dead weight since the scenarios they handled were properly covered. -
ShouldUseEphemeralOpenFormattingstub removed (DefaultResourceRenderer.cs): Deleted a permanently-dead formatting scaffolding — the method always returnedfalse, making every branch it guarded unreachable. The ephemeral-open formatting path, theuseEphemeralOpenFormattingvariable, and the correspondingIsEphemeralOpenScenarioproperty onIScenarioRenderContext/ScenarioRenderContextare all gone.ResolveScenarioFormattingreturn tuple narrowed from 3 to 2 elements. -
MarkdownHelpersvisibility corrected (14 files): All 14 partial-class declarations ofMarkdownHelperswere incorrectlypublic. Changed tointernalto match the project specification.tfplan2mdis a CLI tool, not a library; the test project already hadInternalsVisibleToaccess, so no tests are affected. -
ClearLineDiffCache()cache leak fixed (MarkdownRenderer.cs): BothRender()overloads now callMarkdownHelpers.ClearLineDiffCache()in atry/finallyblock. The[ThreadStatic]LCS (Longest Common Subsequence) cache was documented to require cleanup after each render pass, but the call was inadvertently lost when the Scriban renderer was removed. Under sustained load this caused unbounded memory growth per render thread. -
ApplyViewModel()dead stubs removed (IResourceViewModelFactoryand implementations): Added a default no-op body to theIResourceViewModelFactory.ApplyViewModel()interface method, eliminating the need for pure-stub overrides. Deleted 4 stub implementations (NetworkSecurityGroupFactory,RoleAssignmentFactory,VariableGroupFactory,BuildDefinitionFactory) that contributed nothing. Real implementations (those buildingSummaryHtml/ChangedAttributesSummary) are preserved.