Skip to content

Reduce optional COM usage - #904

Merged
johnml1135 merged 1 commit into
mainfrom
reduce-com-usage
Jun 5, 2026
Merged

Reduce optional COM usage#904
johnml1135 merged 1 commit into
mainfrom
reduce-com-usage

Conversation

@johnml1135

@johnml1135johnml1135 commented May 20, 2026

Copy link
Copy Markdown
Contributor

Scope

This PR reduces optional COM usage and centralizes Encoding Converters access without changing the required FieldWorks native COM boundaries.

Included in this PR:

  • Remove ManagedLgIcuCollator COM visibility and its class-specific reg-free manifest/build plumbing.
  • Remove dormant native OLE clipboard ownership cleanup and unused managed OLE clipboard P/Invokes while leaving managed clipboard and TSF IDataObject behavior unchanged.
  • Isolate debug-only DebugProcs COM activation behind an injectable transport seam; COM remains the debug fallback rather than leaking through general managed code.
  • Add IEncodingConvertersProvider / EncodingConvertersProvider and migrate product-level direct new EncConverters() construction behind that FieldWorks-owned provider.
  • Add/update focused tests and OpenSpec docs for the COM-reduction plan.

Explicitly out of scope:

  • No RootBox, Views/FwKernel, Graphite, TSF, MSAA, IPicture, IStream, or UnknownProp ABI rewrite.
  • No global COM registration or registry workaround.
  • No replacement of the encoding-converters-core runtime; this PR creates the provider boundary only.
  • No removal of Linux-era ViewInputManager / ManagedVwWindow shims; that work was split to branch retire-linux-era-view-shims.

Validation

  • ./build.ps1
  • ./build.ps1 -BuildTests / broader managed validation during implementation
  • ./test.ps1 -TestProject ManagedLgIcuCollatorTests
  • ./test.ps1 -TestProject FiltersTests
  • ./test.ps1 -TestProject LexEdDllTests
  • ./test.ps1 -TestProject FwBuildTasksTests -TestFilter "FullyQualifiedName~RegFreeCreator"
  • ./test.ps1 -TestProject SimpleRootSiteTests -TestFilter "FullyQualifiedName~EditingHelperTests"
  • ./test.ps1 -SkipManaged -TestProject TestGeneric
  • ./test.ps1 -TestProject FwUtilsTests -TestFilter "FullyQualifiedName~DebugProcs"
  • ./test.ps1 -TestProject ParatextImportTests
  • ./test.ps1 -TestProject FwCoreDlgsTests
  • ./test.ps1 -TestProject Sfm2XmlTests
  • ./test.ps1 -TestProject LexTextControlsTests
  • ./test.ps1 -TestProject XMLViewsTests
  • ./test.ps1 -TestProject ITextDllTests
  • VS Code task CI: Whitespace check
  • VS Code task CI: Commit messages

Follow-up / Merge Notes

  • Branch now has one commit on top of origin/main: 61579e344 Reduce optional COM usage.
  • Linux-era Views shim retirement is intentionally separate in branch retire-linux-era-view-shims.
  • Manual clipboard smoke and external CLSID compatibility sign-off should be confirmed before merge.

This change is Reviewable

CopilotAI review requested due to automatic review settings May 20, 2026 19:01

CopilotAI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR reduces optional COM exposure and centralizes SIL Encoding Converters usage behind a FieldWorks-owned provider seam, while updating OpenSpec documentation and tests to enforce the new boundaries.

Changes:

  • Remove COM visibility/build-manifest inputs for ManagedLgIcuCollator, and remove dormant native OLE clipboard shutdown cleanup.
  • Introduce IEncodingConvertersProvider / EncodingConvertersProvider and migrate call sites away from direct new EncConverters() construction.
  • Isolate DebugProcs COM activation behind a debug-only transport seam and add characterization tests.

Reviewed changes

Copilot reviewed 43 out of 47 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
openspec/changes/reducing-com-usage/tasks.mdAdds an implementation/validation task checklist for COM reduction slices.
openspec/changes/reducing-com-usage/specs/integration/external/encoding/spec.mdSpecifies the new provider seam requirement for Encoding Converters access.
openspec/changes/reducing-com-usage/specs/architecture/testing/com-reduction/spec.mdAdds testing/validation requirements for COM reduction work.
openspec/changes/reducing-com-usage/specs/architecture/interop/com-contracts/spec.mdUpdates COM contract requirements + manifest cleanup expectations.
openspec/changes/reducing-com-usage/proposal.mdDocuments rationale/scope/non-goals for the COM reduction initiative.
openspec/changes/reducing-com-usage/design.mdDetails architectural decisions (provider seam, manifest hygiene, test gates).
openspec/changes/reducing-com-usage/COM_USAGE.mdAdds a repo-specific COM usage audit within the OpenSpec change folder.
openspec/changes/reducing-com-usage/COM_FIXES_NOW.mdAdds a prioritized “COM fixes now” plan within the OpenSpec change folder.
openspec/changes/reducing-com-usage/.openspec.yamlDeclares OpenSpec metadata for the change directory.
Src/xWorks/xWorksStrings.resxWhitespace/formatting normalization in .resx content.
Src/Utilities/SfmToXml/Sfm2Xml.csprojAdds reference to FwUtils to consume the shared provider seam.
Src/Utilities/SfmToXml/Converter.csSwitches converter acquisition to EncodingConvertersProvider.
Src/Utilities/SfmToXml/ClsLanguage.csUpdates API to accept IEncConverters instead of concrete EncConverters.
Src/ParatextImport/SCTextEnum.csReplaces direct EncConverters usage with provider seam (and error handling).
Src/ParatextImport/SCScriptureText.csWires provider seam into Paratext import enumerator creation.
Src/ParatextImport/ParatextImportTests/SCTextEnumTests.csUpdates tests to inject provider seam and adds a seam-focused test.
Src/ManagedLgIcuCollator/LgIcuCollator.csRemoves COM exposure from ManagedLgIcuCollator.
Src/LexText/Lexicon/LexEdDll.csprojWhitespace/formatting normalization.
Src/LexText/LexTextControls/SfmToTextsAndWordsMappingBaseDlg.csPopulates converter UI via provider (no direct EncConverters construction).
Src/LexText/LexTextControls/Sfm2FlexTextWords.csUses provider to lazily obtain converters.
Src/LexText/LexTextControls/LexImportWizardLanguage.csPopulates converter UI via provider.
Src/LexText/LexTextControls/LexImportWizard.csUses provider for existence check and controlled access to concrete repository.
Src/LexText/LexTextControls/DataNotebook/NotebookImportWiz.csUses provider and typed enumeration helper for converter names.
Src/LexText/LexTextControls/DataNotebook/ImportEncCvtrDlg.csPopulates converter UI via provider.
Src/LexText/Interlinear/LinguaLinksImportDlg.csUses provider for converter existence + controlled concrete access.
Src/LexText/Interlinear/LinguaLinksImport.csUses provider for converter repository access.
Src/Generic/ModuleEntry.hRemoves dormant clipboard ownership tracking API/state.
Src/Generic/ModuleEntry.cppRemoves dormant clipboard shutdown flush logic/state.
Src/FwCoreDlgs/FwWritingSystemSetupModel.csReplaces direct converter creation with provider seam for UI model.
Src/FwCoreDlgs/FwCoreDlgsTests/FwWritingSystemSetupModelTests.csUpdates tests to mock provider seam.
Src/FwCoreDlgs/ConverterTester.csUses provider for concrete converter repository access.
Src/FwCoreDlgs/CnvtrPropertiesCtrl.csUses provider for concrete converter repository access.
Src/FwCoreDlgs/AddCnvtrDlg.csUses provider (including reset) for concrete converter repository access.
Src/Common/FwUtils/Win32Wrappers.csRemoves unused OLE clipboard P/Invokes tied to dormant native logic.
Src/Common/FwUtils/FwUtilsTests/DebugProcsTests.csAdds tests for debug transport seam and failure/disposal tolerance.
Src/Common/FwUtils/FwUtils.csprojAdds encoding-converters-core dependency for provider implementation.
Src/Common/FwUtils/EncodingConvertersProvider.csIntroduces provider seam + helpers for typed enumeration/contains.
Src/Common/FwUtils/DebugProcs.csAdds debug transport seam and isolates COM activation behind it.
Src/Common/FieldWorks/BuildInclude.targetsRemoves ManagedLgIcuCollator from managed COM manifest inputs.
Src/Common/Controls/XMLViews/BulkEditBar.csUses provider + typed enumeration helper instead of direct EncConverters.
DistFiles/Language Explorer/Configuration/Parts/LexSenseParts.xmlWhitespace normalization.
COM_USAGE.mdAdds top-level repo COM audit documentation.
COM_FIXES_NOW.mdAdds top-level prioritized COM fixes documentation.
Build/mkall.targetsRemoves excluded CLSID entry for ManagedLgIcuCollator.
Build/Src/FwBuildTasks/FwBuildTasksTests/RegFreeCreatorTests.csAdds regression tests ensuring COM-visible=false doesn’t emit clrClass.
Build/RegFree.targetsRemoves ManagedLgIcuCollator from managed COM manifest inputs.
Comments suppressed due to low confidence (1)

Src/ParatextImport/SCTextEnum.cs:1

  • SCTextEnum is a public class and previously exposed a protected IEncConverters m_encConverters field; changing it to a private provider removes subclass access and is a breaking change for any derived types outside this PR. If inheritance is intended/supported, consider restoring a protected accessor (e.g., a protected property exposing IEncodingConvertersProvider or IEncConverters) to preserve extensibility while still preventing direct new EncConverters() usage at call sites.

Comment threadSrc/Common/FwUtils/DebugProcs.cs Outdated
Comment threadSrc/Common/FwUtils/DebugProcs.cs Outdated
Comment threadSrc/Common/FwUtils/EncodingConvertersProvider.cs Outdated
Comment threadSrc/FwCoreDlgs/FwWritingSystemSetupModel.cs
@johnml1135

Copy link
Copy Markdown
ContributorAuthor

Also addressed Copilot's low-confidence SCTextEnum extensibility note in 7f7aa13 by adding protected accessors for the provider and repository without reintroducing direct EncConverters construction at call sites.

@github-actions

github-actionsBot commented May 20, 2026

Copy link
Copy Markdown

NUnit Tests

1 files ±0 1 suites ±0 10m 11s ⏱️ - 1m 12s
4 204 tests ±0 4 133 ✅ ±0 71 💤 ±0 0 ❌ ±0 
4 213 runs ±0 4 142 ✅ ±0 71 💤 ±0 0 ❌ ±0 

Results for commit e29374c. ± Comparison against base commit 25e5bf0.

♻️ This comment has been updated with latest results.

@jasonleenaylor

Copy link
Copy Markdown
Contributor

Clipbloard cleanup and managedlgicucollator are good, the rest are not adding immediate value and make some code more complicated for no benefit.

@johnml1135

Copy link
Copy Markdown
ContributorAuthor

Jason, I reduced this PR to the requested scope: the clipboard cleanup plus the ManagedLgIcuCollator COM visibility/manifest cleanup. The broader COM-reduction/OpenSpec work is out of the branch now.

I created LT-22528 for the optional future work and copied the COM-reduction markdown/OpenSpec notes into that Jira issue so it is easy to pick up later if it becomes worth doing.

@johnml1135

Copy link
Copy Markdown
ContributorAuthor

@jasonleenaylor - what is still needed here?

@jasonleenaylor

Copy link
Copy Markdown
Contributor

Src/Common/FwUtils/Win32Wrappers.cs line 2856 at r2 (raw file):

#endregion#regionOle32.dll

region can go too.

@jasonleenaylorjasonleenaylor 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:

I would like to see the empty region cleaned up either now or in a follow up.

@jasonleenaylor reviewed 47 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on johnml1135).

@johnml1135
johnml1135 merged commit 846c123 into mainJun 5, 2026
7 checks passed
@johnml1135
johnml1135 deleted the reduce-com-usage branch June 5, 2026 17:04
jasonleenaylor added a commit that referenced this pull request Jun 10, 2026
Commit 846c123 ("Reduce optional COM usage", #904) stopped emitting the
reg-free COM manifest ManagedLgIcuCollator.manifest, but the base release
still ships it. WiX 3 pyro then fails the patch build with PYRO0305 because
files cannot be removed in a patch.
Add the manifest to the RescuePatching target's RemovedSinceLastBase list so
a zero-byte placeholder is staged into the build output. The file is then
present in both the Master and Update harvests, so pyro treats it as changed
rather than removed. This mirrors the existing ManagedVwWindow.manifest and
SimpleRootSite.manifest entries.
Also document the error and this fix in FLExInstaller/AGENTS.md for future
occurrences.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
johnml1135 added a commit that referenced this pull request Jul 6, 2026
- VersionInfoProvider: copyright year no longer freezes at whatever year the
constant was last edited, ApplicationVersion resolves from the correct
assembly instead of always falling back to the entry assembly, and
MajorVersion/ParseInformationalVersion index defensively instead of
assuming a fixed part count. Covered by new VersionInfoProviderTests.cs.
- RegFree.targets: removes a dangling ManagedVwWindow.dll entry; the project
was already retired in #904/#906, so the entry pointed at nothing.
- opsx-*.prompt.md: replace inlined instructions with delegation to the
existing .claude/skills/openspec-*/SKILL.md files, per this repo's
skills-over-inline-prompts convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
johnml1135 added a commit that referenced this pull request Aug 12, 2026
- VersionInfoProvider: copyright year no longer freezes at whatever year the
constant was last edited, ApplicationVersion resolves from the correct
assembly instead of always falling back to the entry assembly, and
MajorVersion/ParseInformationalVersion index defensively instead of
assuming a fixed part count. Covered by new VersionInfoProviderTests.cs.
- RegFree.targets: removes a dangling ManagedVwWindow.dll entry; the project
was already retired in #904/#906, so the entry pointed at nothing.
- opsx-*.prompt.md: replace inlined instructions with delegation to the
existing .claude/skills/openspec-*/SKILL.md files, per this repo's
skills-over-inline-prompts convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
johnml1135 added a commit that referenced this pull request Aug 14, 2026
- VersionInfoProvider: copyright year no longer freezes at whatever year the
constant was last edited, ApplicationVersion resolves from the correct
assembly instead of always falling back to the entry assembly, and
MajorVersion/ParseInformationalVersion index defensively instead of
assuming a fixed part count. Covered by new VersionInfoProviderTests.cs.
- RegFree.targets: removes a dangling ManagedVwWindow.dll entry; the project
was already retired in #904/#906, so the entry pointed at nothing.
- opsx-*.prompt.md: replace inlined instructions with delegation to the
existing .claude/skills/openspec-*/SKILL.md files, per this repo's
skills-over-inline-prompts convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
johnml1135 added a commit that referenced this pull request Aug 26, 2026
- VersionInfoProvider: copyright year no longer freezes at whatever year the
constant was last edited, ApplicationVersion resolves from the correct
assembly instead of always falling back to the entry assembly, and
MajorVersion/ParseInformationalVersion index defensively instead of
assuming a fixed part count. Covered by new VersionInfoProviderTests.cs.
- RegFree.targets: removes a dangling ManagedVwWindow.dll entry; the project
was already retired in #904/#906, so the entry pointed at nothing.
- opsx-*.prompt.md: replace inlined instructions with delegation to the
existing .claude/skills/openspec-*/SKILL.md files, per this repo's
skills-over-inline-prompts convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
johnml1135 added a commit that referenced this pull request Sep 1, 2026
…, thin opsx prompts (#978)
* chore: small fixes pulled off from PR #964
- VersionInfoProvider: copyright year no longer freezes at whatever year the
constant was last edited, ApplicationVersion resolves from the correct
assembly instead of always falling back to the entry assembly, and
MajorVersion/ParseInformationalVersion index defensively instead of
assuming a fixed part count. Covered by new VersionInfoProviderTests.cs.
- RegFree.targets: removes a dangling ManagedVwWindow.dll entry; the project
was already retired in #904/#906, so the entry pointed at nothing.
- opsx-*.prompt.md: replace inlined instructions with delegation to the
existing .claude/skills/openspec-*/SKILL.md files, per this repo's
skills-over-inline-prompts convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Drop stale ManagedVwWindow.dll references from RegFree build files
ManagedVwWindow.dll was retired with the Linux-era view shims (#906). The
RegFree.targets fallback entry was removed earlier in this PR, but
BuildInclude.targets pre-populates ManagedComAssemblies explicitly for
FieldWorks.exe (bypassing that fallback), so the "Could not find file"
warning kept firing for the main product. Also drops the matching stale
CLSID exclusion in mkall.targets.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* style: use ASCII punctuation in new prompt/doc/test prose
This branch's new content used em-dashes and a Unicode "<=" sign in a
few places (opsx-explore.prompt.md, opsx-onboard.prompt.md, AGENTS.md,
VersionInfoProviderTests.cs), which render poorly in some git tooling.
Switch them to the ASCII "--" and "<=" forms the rest of the repo's
prose and comments already use.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Address review comments on VersionInfoProvider
Shorten the comment blocks flagged over the 200-character cap
(MajorVersion 241, CopyrightString 214, ApplicationVersion 204) and
rewrite the four that narrated repo history, named callers, or restated
the member name.
Guard the one line in this file that could actually throw:
Convert.ToInt32(versionParts[1]) raised FormatException on a non-numeric
token, out of a property getter the splash screen and About box read.
int.TryParse leaves date at 0, which the existing date > 0 check already
treats as no date, so the fallback path is unchanged. This matches
BaseBuildNumber, which already uses int.TryParse in the same file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011arsbDno5H5y2pLGqGgb9L
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for freeto 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

@johnml1135@jasonleenaylor