Skip to content

Reduce optional COM usage#904

Open
johnml1135 wants to merge 2 commits into
mainfrom
reduce-com-usage
Open

Reduce optional COM usage#904
johnml1135 wants to merge 2 commits into
mainfrom
reduce-com-usage

Conversation

@johnml1135
Copy link
Copy Markdown
Contributor

@johnml1135 johnml1135 commented May 20, 2026

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

Copilot AI review requested due to automatic review settings May 20, 2026 19:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
File Description
openspec/changes/reducing-com-usage/tasks.md Adds an implementation/validation task checklist for COM reduction slices.
openspec/changes/reducing-com-usage/specs/integration/external/encoding/spec.md Specifies the new provider seam requirement for Encoding Converters access.
openspec/changes/reducing-com-usage/specs/architecture/testing/com-reduction/spec.md Adds testing/validation requirements for COM reduction work.
openspec/changes/reducing-com-usage/specs/architecture/interop/com-contracts/spec.md Updates COM contract requirements + manifest cleanup expectations.
openspec/changes/reducing-com-usage/proposal.md Documents rationale/scope/non-goals for the COM reduction initiative.
openspec/changes/reducing-com-usage/design.md Details architectural decisions (provider seam, manifest hygiene, test gates).
openspec/changes/reducing-com-usage/COM_USAGE.md Adds a repo-specific COM usage audit within the OpenSpec change folder.
openspec/changes/reducing-com-usage/COM_FIXES_NOW.md Adds a prioritized “COM fixes now” plan within the OpenSpec change folder.
openspec/changes/reducing-com-usage/.openspec.yaml Declares OpenSpec metadata for the change directory.
Src/xWorks/xWorksStrings.resx Whitespace/formatting normalization in .resx content.
Src/Utilities/SfmToXml/Sfm2Xml.csproj Adds reference to FwUtils to consume the shared provider seam.
Src/Utilities/SfmToXml/Converter.cs Switches converter acquisition to EncodingConvertersProvider.
Src/Utilities/SfmToXml/ClsLanguage.cs Updates API to accept IEncConverters instead of concrete EncConverters.
Src/ParatextImport/SCTextEnum.cs Replaces direct EncConverters usage with provider seam (and error handling).
Src/ParatextImport/SCScriptureText.cs Wires provider seam into Paratext import enumerator creation.
Src/ParatextImport/ParatextImportTests/SCTextEnumTests.cs Updates tests to inject provider seam and adds a seam-focused test.
Src/ManagedLgIcuCollator/LgIcuCollator.cs Removes COM exposure from ManagedLgIcuCollator.
Src/LexText/Lexicon/LexEdDll.csproj Whitespace/formatting normalization.
Src/LexText/LexTextControls/SfmToTextsAndWordsMappingBaseDlg.cs Populates converter UI via provider (no direct EncConverters construction).
Src/LexText/LexTextControls/Sfm2FlexTextWords.cs Uses provider to lazily obtain converters.
Src/LexText/LexTextControls/LexImportWizardLanguage.cs Populates converter UI via provider.
Src/LexText/LexTextControls/LexImportWizard.cs Uses provider for existence check and controlled access to concrete repository.
Src/LexText/LexTextControls/DataNotebook/NotebookImportWiz.cs Uses provider and typed enumeration helper for converter names.
Src/LexText/LexTextControls/DataNotebook/ImportEncCvtrDlg.cs Populates converter UI via provider.
Src/LexText/Interlinear/LinguaLinksImportDlg.cs Uses provider for converter existence + controlled concrete access.
Src/LexText/Interlinear/LinguaLinksImport.cs Uses provider for converter repository access.
Src/Generic/ModuleEntry.h Removes dormant clipboard ownership tracking API/state.
Src/Generic/ModuleEntry.cpp Removes dormant clipboard shutdown flush logic/state.
Src/FwCoreDlgs/FwWritingSystemSetupModel.cs Replaces direct converter creation with provider seam for UI model.
Src/FwCoreDlgs/FwCoreDlgsTests/FwWritingSystemSetupModelTests.cs Updates tests to mock provider seam.
Src/FwCoreDlgs/ConverterTester.cs Uses provider for concrete converter repository access.
Src/FwCoreDlgs/CnvtrPropertiesCtrl.cs Uses provider for concrete converter repository access.
Src/FwCoreDlgs/AddCnvtrDlg.cs Uses provider (including reset) for concrete converter repository access.
Src/Common/FwUtils/Win32Wrappers.cs Removes unused OLE clipboard P/Invokes tied to dormant native logic.
Src/Common/FwUtils/FwUtilsTests/DebugProcsTests.cs Adds tests for debug transport seam and failure/disposal tolerance.
Src/Common/FwUtils/FwUtils.csproj Adds encoding-converters-core dependency for provider implementation.
Src/Common/FwUtils/EncodingConvertersProvider.cs Introduces provider seam + helpers for typed enumeration/contains.
Src/Common/FwUtils/DebugProcs.cs Adds debug transport seam and isolates COM activation behind it.
Src/Common/FieldWorks/BuildInclude.targets Removes ManagedLgIcuCollator from managed COM manifest inputs.
Src/Common/Controls/XMLViews/BulkEditBar.cs Uses provider + typed enumeration helper instead of direct EncConverters.
DistFiles/Language Explorer/Configuration/Parts/LexSenseParts.xml Whitespace normalization.
COM_USAGE.md Adds top-level repo COM audit documentation.
COM_FIXES_NOW.md Adds top-level prioritized COM fixes documentation.
Build/mkall.targets Removes excluded CLSID entry for ManagedLgIcuCollator.
Build/Src/FwBuildTasks/FwBuildTasksTests/RegFreeCreatorTests.cs Adds regression tests ensuring COM-visible=false doesn’t emit clrClass.
Build/RegFree.targets Removes 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 thread Src/Common/FwUtils/DebugProcs.cs Outdated
Comment thread Src/Common/FwUtils/DebugProcs.cs
Comment thread Src/Common/FwUtils/EncodingConvertersProvider.cs
Comment thread Src/FwCoreDlgs/FwWritingSystemSetupModel.cs
@johnml1135
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

NUnit Tests

    1 files  ±0      1 suites  ±0   12m 20s ⏱️ + 1m 12s
4 211 tests +6  4 140 ✅ +6  71 💤 ±0  0 ❌ ±0 
4 220 runs  +6  4 149 ✅ +6  71 💤 ±0  0 ❌ ±0 

Results for commit 421f157. ± Comparison against base commit b0bf8a8.

♻️ This comment has been updated with latest results.

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.

2 participants