Skip to content

Rebuild Views and kernel IDLs when their interface files change - #1266

Merged
thejambi merged 3 commits into
mainfrom
fix-views-idh-dependency
Nov 25, 2026
Merged

thejambi merged 3 commits into
mainfrom
fix-views-idh-dependency

Conversation

@thejambi

@thejambi thejambi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The native build now regenerates the preprocessed Output/<Config>/Common/ViewsTlb.idl and ViewsPs.idl when Views.idh or Render.idh changes, and regenerates those and the FwKernel IDLs when a liblcm update changes the kernel interface files. Until now, pulling a Views interface change into an already-built checkout left the managed build broken: after LT-22634 added IVwEnv.OpenWrapGroup, a developer who pulled main got four CS1061 errors such as 'IVwEnv' does not contain a definition for 'OpenWrapGroup' in XmlBrowseViewBaseVc.cs, because the generated Views.cs still described the old interface. The proxy code built into Views.dll was stale in the same way. A clean build was never affected.

Reviewer notes

Root cause. Bld/_rule.mak preprocesses Src/views/ViewsTlb.idl and Src/views/ViewsPs.idl into the output folder with cl /E, which inlines their #included .idh files. nmake's inference rule compares each output only with its source .idl, which almost never changes. ViewsInterfaces/BuildInclude.targets does rerun idlimport when Views.idh is newer than Views.cs, but it reads the stale preprocessed IDL, so the regenerated Views.cs is still missing the new methods. LT-22816 (#1168) added header tracking for C++ objects only; it does not cover IDL includes.

Deliberate rules.

  • The new line in Src/views/Views.mak lists dependencies only, with no commands, so nmake still uses the existing {src}.idl{out}.idl rule to build both files.
  • An .idh edit now also rebuilds ViewsTlb.tlb, ViewsTlb.h, the ViewsPs proxy sources and every Views object, which already depend on those outputs. dlldatax.obj picks up the regenerated ViewsPs_p.c through the existing header-dependency tracking. That is the intended cost of an interface change.
  • common.idh and the other liblcm kernel interface files are copied into Src/Kernel with the package's timestamps, which can predate the last build, so the makefiles cannot depend on them directly. Build/PackageRestore.targets now writes Src/Kernel/LcmKernelFiles.stamp with a hash of each copied file, using WriteOnlyWhenDifferent, so its timestamp moves only when a file's content does. Views.mak depends on the stamp instead of common.idh, and FwKernel.mak makes FwKernelTlb.idl and FwKernelPs.idl depend on it. A content hash rather than the package version also covers local liblcm builds. Clean deletes the stamp and git ignores it.
  • Touching the copied files after the restore was rejected: the Copy task's CopiedFiles output also lists files it skipped, and a touched file no longer matches the package, so every build would recopy, touch and rebuild.
  • Test-ViewsNativeArtifactsStale (Build/Agent/FwBuildHelpers.psm1) now scans *.idh files, so a TestViews run after an .idh-only edit rebuilds the native code first.
  • No cost on a build where nothing changed beyond hashing five small files; CI always builds from a clean checkout, so it is unaffected.

Tests. No automated test covers makefile dependencies. With the first two commits, touching Src/views/Views.idh and running .\build.ps1 -CommentHygiene -TokenHygiene regenerated the output ViewsTlb.idl, ViewsTlb.tlb, ViewsPs.idl, ViewsPs.h, ViewsPs_p.c, ViewsPs.dll and Views.cs, and rebuilt dlldatax.obj and Views.dll; the build succeeded with 0 warnings and 0 errors. Without the fix, a build after a rebase that rewrote Views.idh left both preprocessed IDLs unchanged. .\test.ps1 -TestProject TestViews -SkipManaged refreshed the native artifacts and passed 330 of 330; that run does not show *.idh detection, because a missing views.lib (see Out of scope) makes the helper report stale before it compares timestamps.

The *.idh pattern was checked separately against a throwaway folder holding every artifact the helper checks, so the timestamp comparison decides the result:

Case main This branch
All sources older than the artifacts False False
Only Src\views\Views.idh newer than the artifacts False True

The stamp was checked with four .\build.ps1 -CommentHygiene -TokenHygiene runs in a row, each with 0 warnings and 0 errors:

Run Stamp FwKernel and Views IDLs, Views.cs Time
Real package, no stamp yet created regenerated (one time) 3:18
Copy of the package with common.idh changed but its original timestamp kept changed regenerated 3:06
Real package again changed back regenerated 3:07
Nothing changed unchanged untouched 0:27

Manual tests. None beyond the build above; this changes no runtime behaviour. Release configuration was not built, but the rule uses the configuration-specific $(COM_OUT_DIR).

For developers already hit by this. Delete the stale files and rebuild:

  1. Remove-Item Output\Debug\Common\ViewsTlb.*, Output\Debug\Common\ViewsPs.*, Src\Common\ViewsInterfaces\Views.cs
  2. .\build.ps1

Out of scope. Test-ViewsNativeArtifactsStale also checks Output\<Config>\views.lib, which the build no longer writes, so it reports stale on every run; fixing that changes when TestViews skips its rebuild and is a separate change. The kernel-file Copy keeps SkipUnchangedFiles="true", which compares only size and timestamp, so a liblcm file whose content changed but whose size and timestamp match the existing copy would be skipped and the stamp would hash the old copy; the packages seen so far carry distinct timestamps for these files, and setting SkipUnchangedFiles="false" on that one Copy would close the gap if it is ever hit. No Jira ticket: this is a developer-only build change that a tester cannot see.

🤖 Generated with Claude Code


This change is Reviewable

The build preprocesses Src/views/ViewsTlb.idl into
Output/<Config>/Common/ViewsTlb.idl, inlining Views.idh, Render.idh
and common.idh. nmake only compared it against the source .idl, so
pulling an interface change to an .idh left the output stale. The
generated Views.cs then lacked the new methods, and managed code that
called them failed with CS1061 (seen with IVwEnv.OpenWrapGroup after
LT-22634).

List the three .idh files as dependencies so an edit to any of them
regenerates the output IDL, the type library, and Views.cs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

NUnit Tests

    1 files  ±0      1 suites  ±0   14m 2s ⏱️ -50s
7 420 tests ±0  7 341 ✅ ±0  79 💤 ±0  0 ❌ ±0 
7 429 runs  ±0  7 350 ✅ ±0  79 💤 ±0  0 ❌ ±0 

Results for commit a6654b5. ± Comparison against base commit 183be7c.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.92%. Comparing base (183be7c) to head (a6654b5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1266   +/-   ##
=======================================
  Coverage   40.92%   40.92%           
=======================================
  Files        1602     1602           
  Lines      360800   360800           
  Branches    42245    42245           
=======================================
+ Hits       147648   147649    +1     
  Misses     183655   183655           
+ Partials    29497    29496    -1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ViewsPs.idl inlines the same .idh files as ViewsTlb.idl, so after an
interface edit its preprocessed copy stayed stale too. dlldatax.c
builds the proxy code generated from it into Views.dll, which then
marshaled the old interface. Add it as a target of the same
dependency line.

Test-ViewsNativeArtifactsStale did not scan *.idh files, so a run of
the TestViews native tests after an .idh-only edit could skip the
native rebuild. Add *.idh to its source patterns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thejambi thejambi changed the title Rebuild ViewsTlb.idl when Views.idh or Render.idh changes Rebuild Views type library and proxy code when an .idh changes Nov 25, 2026
The restore copies common.idh and the other liblcm kernel interface
files into Src/Kernel with the package's timestamps, which can predate
the last build. Moving to a liblcm version that changes them then left
the preprocessed FwKernel and Views IDLs stale, so listing common.idh
as a dependency did not cover the case it was there for.

The restore now writes LcmKernelFiles.stamp, holding a hash of each
copied file, and rewrites it only when a hash changes. FwKernel.mak
and Views.mak depend on the stamp instead of the copied files. Clean
deletes it and git ignores it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thejambi thejambi changed the title Rebuild Views type library and proxy code when an .idh changes Rebuild Views and kernel IDLs when their interface files change Nov 25, 2026

@mark-sil mark-sil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thejambi
thejambi merged commit d36ff64 into main Nov 25, 2026
8 of 9 checks passed
@thejambi
thejambi deleted the fix-views-idh-dependency branch November 25, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants