Skip to content

Commit 87dcd3e

Browse files
Copilotjohnml1135
andcommitted
Shorten 7 more COPILOT.md files - FieldWorks through LexTextControls
Co-authored-by: johnml1135 <13733556+johnml1135@users.noreply.github.com>
1 parent b87351f commit 87dcd3e

7 files changed

Lines changed: 65 additions & 780 deletions

File tree

Src/AppCore/COPILOT.md

Lines changed: 9 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -98,124 +98,28 @@ C++ native header-only library. Headers and implementation files are designed to
9898
No COM/PInvoke boundaries. Pure native C++ code consumed via `#include` directives. Provides RAII wrappers around Windows GDI HANDLEs to ensure proper cleanup via destructors. Debug builds track GDI resource allocations (s_cDCs, s_cFonts) to detect leaks via static counters.
9999

100100
## Threading & Performance
101-
Thread-agnostic code. GDI resources (DCs, fonts, brushes) have thread affinity and require careful handling in multi-threaded scenarios; AppCore does not enforce thread safety. Smart wrapper classes use RAII for deterministic cleanup within a single thread. Performance notes: AfGdi tracking adds overhead in debug builds via counters and optional logging; release builds should disable tracking. ColorTable maintains global singleton (g_ct) initialized at startup.
101+
Thread-agnostic; GDI resources have thread affinity. RAII wrappers ensure cleanup. Debug tracking adds overhead; global ColorTable singleton.
102102

103103
## Config & Feature Flags
104-
Debug-only resource tracking controlled by static flags:
105-
- `AfGdi::s_fShowDCs`: When true, logs DC allocation/deallocation to debug output
106-
- `AfGdi::s_fShowFonts`: When true, logs font allocation/deallocation to debug output
107-
No runtime configuration files.
104+
Debug flags: AfGdi::s_fShowDCs, AfGdi::s_fShowFonts for allocation logging. No runtime config.
108105

109106
## Build Information
110-
- No standalone project file; this is a header-only library consumed via include paths
111-
- Build using the top-level FieldWorks.sln (Visual Studio/MSBuild)
112-
- Consumer projects (Kernel.vcxproj, views.vcxproj) reference AppCore via NMakeIncludeSearchPath
113-
- Do not attempt to build AppCore in isolation; it is included directly into consumer C++ projects
107+
Header-only library consumed via include paths. Build using FieldWorks.sln. Consumer projects reference via NMakeIncludeSearchPath.
114108

115109
## Interfaces and Data Models
116-
117-
- **AfGfx** (AfGfx.h/cpp)
118-
- Purpose: Static utility class providing Windows GDI helper functions
119-
- Inputs: HDC, COLORREF, Rect, HBITMAP, resource IDs
120-
- Outputs: Modified DC state, drawn graphics, created GDI objects
121-
- Notes: All methods are static; acts as namespace for GDI utilities
122-
123-
- **AfGdi** (AfGfx.h)
124-
- Purpose: Tracked wrappers for GDI resource lifecycle with leak detection
125-
- Inputs: Same parameters as native Windows GDI APIs
126-
- Outputs: GDI HANDLEs (HDC, HFONT, HBRUSH, HPEN, HRGN)
127-
- Notes: Debug builds maintain counters (s_cDCs, s_cFonts); check at shutdown for leaks
128-
129-
- **SmartDc** (AfGfx.h)
130-
- Purpose: RAII wrapper for device context automatic cleanup
131-
- Inputs: Constructor takes HWND or creates compatible DC
132-
- Outputs: Provides HDC via conversion operator; releases DC in destructor
133-
- Notes: Non-copyable; use for automatic GetDC/ReleaseDC pairing
134-
135-
- **SmartPalette** (AfGfx.h)
136-
- Purpose: RAII wrapper for palette selection with automatic restore
137-
- Inputs: HDC, HPALETTE
138-
- Outputs: Selects and realizes palette; restores previous palette in destructor
139-
- Notes: Non-copyable; use when temporarily changing palette
140-
141-
- **Smart GDI object wrappers** (AfGfx.h)
142-
- FontWrap, BrushWrap, PenWrap, RgnWrap, ClipRgnWrap
143-
- Purpose: RAII wrappers for SelectObject/RestoreObject pairing
144-
- Inputs: HDC, HGDIOBJ (font, brush, pen, region)
145-
- Outputs: Selects object; restores previous object in destructor
146-
- Notes: Non-copyable; use for automatic GDI object restoration
147-
148-
- **FwStyledText::ComputeInheritance** (FwStyledText.h/cpp)
149-
- Purpose: Merges base and override text properties to compute effective properties
150-
- Inputs: ITsTextProps* pttpBase, ITsTextProps* pttpOverride
151-
- Outputs: ITsTextProps** ppttpEffect (computed effective properties)
152-
- Notes: Implements inheritance logic for text properties (soft/hard formatting)
153-
154-
- **FwStyledText::DecodeFontPropsString** (FwStyledText.h/cpp)
155-
- Purpose: Parses BSTR font property string into structured data
156-
- Inputs: BSTR bstr (encoded font properties), bool fExplicit
157-
- Outputs: Vectors of WsStyleInfo, ChrpInheritance, writing system IDs
158-
- Notes: Complex parsing logic for writing system-specific font properties
159-
160-
- **FwStyledText::EncodeFontPropsString** (FwStyledText.h/cpp)
161-
- Purpose: Encodes structured font properties into BSTR format
162-
- Inputs: Vector<WsStyleInfo> vesi, bool fForPara
163-
- Outputs: StrUni (encoded font property string)
164-
- Notes: Inverse of DecodeFontPropsString; produces compact encoding
165-
166-
- **ChrpInheritance** (FwStyledText.h)
167-
- Purpose: Tracks inheritance state of character rendering properties
168-
- Inputs: Constructed from base and override ITsTextProps
169-
- Outputs: Fields indicate kxInherited/kxExplicit/kxConflicting for each property
170-
- Notes: Used by formatting dialogs to show soft vs. hard formatting
171-
172-
- **WsStyleInfo** (FwStyledText.h)
173-
- Purpose: Stores per-writing-system style information
174-
- Inputs: Writing system ID, font properties (name, size, bold, italic, etc.)
175-
- Outputs: Structured representation used in encoding/decoding
176-
- Notes: Part of complex writing system style inheritance system
177-
178-
- **ColorTable** (AfColorTable.h/cpp)
179-
- Purpose: Manages application color table with 40 predefined colors
180-
- Inputs: Color index (0-39), COLORREF values
181-
- Outputs: COLORREF, string resource IDs, palette entries
182-
- Notes: Global singleton g_ct; palette created in constructor for legacy hardware
183-
184-
- **ColorTable::RealizePalette** (AfColorTable.h/cpp)
185-
- Purpose: Maps logical palette to system palette for quality drawing
186-
- Inputs: HDC
187-
- Outputs: HPALETTE (old palette, or NULL if device doesn't support palettes)
188-
- Notes: Only relevant for legacy hardware with <16-bit color depth
110+
AfGfx (GDI utilities), AfGdi (tracked wrappers), Smart RAII wrappers (SmartDc, SmartPalette, FontWrap, etc.), FwStyledText (property inheritance), ColorTable (40 color palette).
189111

190112
## Entry Points
191-
- Included via `#include "AfGfx.h"`, `#include "FwStyledText.h"`, `#include "AfColorTable.h"` in consumer C++ code
192-
- Primary consumer: views/Main.h includes Res/AfAppRes.h for resource IDs
193-
- Kernel and views projects reference AppCore via NMakeIncludeSearchPath
194-
- ColorTable global singleton `g_ct` available after static initialization
113+
Included via #include directives. Primary consumer: views/Main.h. Global ColorTable singleton g_ct.
195114

196115
## Test Index
197-
No tests found in this folder. Tests may be in consumer projects (views, Kernel) or separate test assemblies.
116+
No tests in this folder. Tests may be in consumer projects (views, Kernel).
198117

199118
## Usage Hints
200-
- Include AfGfx.h for Windows GDI utilities and RAII wrappers
201-
- Include FwStyledText.h for writing system style inheritance and font property encoding/decoding
202-
- Include AfColorTable.h for access to predefined color table and global `g_ct` singleton
203-
- Use smart wrappers (SmartDc, SmartPalette, FontWrap, etc.) for automatic GDI resource cleanup
204-
- Enable `AfGdi::s_fShowDCs` or `AfGdi::s_fShowFonts` in debug builds to log resource allocation
205-
- Check `AfGdi::s_cDCs` and `AfGdi::s_cFonts` counters at shutdown to detect GDI leaks
206-
- Use `g_ct` global ColorTable to map color indices to RGB values and string resource IDs
207-
- Use FwStyledText namespace functions to compute style inheritance for multi-writing-system text
119+
Include AfGfx.h (GDI utilities), FwStyledText.h (style inheritance), AfColorTable.h (color table). Use smart wrappers for automatic cleanup.
208120

209121
## Related Folders
210-
- **views/**: Primary consumer; includes AfAppRes.h for resource IDs
211-
- **Kernel/**: References AppCore in include search paths; provides low-level infrastructure
212-
- **Generic/**: Peer utilities folder; provides base types, vectors, smart pointers
122+
views (primary consumer), Kernel (low-level infrastructure), Generic (base types).
213123

214124
## References
215-
- **Project files**: None (header-only library)
216-
- **Key C++ files**: AfColorTable.cpp (195 lines), AfGfx.cpp (1340 lines), FwStyledText.cpp (1483 lines)
217-
- **Key headers**: AfColorTable.h (110 lines), AfDef.h (196 lines), AfGfx.h (702 lines), FwStyledText.h (218 lines), Res/AfAppRes.h (454 lines)
218-
- **Total lines of code**: 4698
219-
- **Include search paths**: Referenced by Kernel.vcxproj and views.vcxproj (..\AppCore)
220-
- **Consumer references**: Src/views/Main.h includes "../../../Src/AppCore/Res/AfAppRes.h"
221-
- **Global singleton**: ColorTable g_ct (declared extern in AfColorTable.h, defined in AfColorTable.cpp)
125+
Header-only library (4698 lines). Key files: AfColorTable.cpp, AfGfx.cpp, FwStyledText.cpp, AfGfx.h, FwStyledText.h, Res/AfAppRes.h. Global singleton: ColorTable g_ct. See `.cache/copilot/diff-plan.json` for details.

Src/Common/FieldWorks/COPILOT.md

Lines changed: 10 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,7 @@ C# Windows executable (WinExe) targeting .NET Framework 4.8.x. Main entry point
8989
- **PaComplexFormInfo** (PaComplexFormInfo.cs): Complex form relationships
9090

9191
## Technology Stack
92-
- C# .NET Framework 4.8.x (target framework: net48)
93-
- OutputType: WinExe (Windows executable with UI)
94-
- Windows Forms for UI (System.Windows.Forms)
95-
- System.Runtime.Serialization for ProjectId serialization
96-
- Windows Installer API integration (WindowsInstallerQuery)
97-
- Inter-process communication for multi-instance coordination
92+
C# .NET Framework 4.8.x (WinExe), Windows Forms, System.Runtime.Serialization, Windows Installer API, inter-process communication.
9893

9994
## Dependencies
10095

@@ -120,114 +115,28 @@ C# Windows executable (WinExe) targeting .NET Framework 4.8.x. Main entry point
120115
- **COM/P/Invoke**: Windows Installer API via WindowsInstallerQuery
121116

122117
## Threading & Performance
123-
- **UI thread marshaling**: FieldWorksManager.ExecuteAsync() uses ThreadHelper.InvokeAsync for UI thread invocation
124-
- **Synchronization**: Application lifecycle methods coordinate across multiple FwApp instances
125-
- **Performance**: Singleton pattern (FieldWorks class) ensures single instance per process
126-
- **Dialog responsiveness**: ApplicationBusyDialog provides cancellation and progress feedback
118+
UI thread marshaling via ThreadHelper.InvokeAsync; lifecycle synchronization across FwApp instances; singleton per process.
127119

128120
## Config & Feature Flags
129-
- **App.config**: Application configuration file
130-
- **BuildInclude.targets**: MSBuild custom targets for build configuration
131-
- No explicit feature flags detected in source
121+
App.config, BuildInclude.targets; no explicit feature flags detected.
132122

133123
## Build Information
134-
- **Project file**: FieldWorks.csproj (.NET Framework 4.8.x, WinExe)
135-
- **Test project**: FieldWorksTests/FieldWorksTests.csproj
136-
- **Output**: FieldWorks.exe (main executable), FieldWorks.xml (documentation)
137-
- **Icon**: BookOnCube.ico (multiple variants: BookOnCube, CubeOnBook, versions, sizes)
138-
- **Build**: Via top-level FieldWorks.sln or: `msbuild FieldWorks.csproj /p:Configuration=Debug`
139-
- **Run tests**: `dotnet test FieldWorksTests/FieldWorksTests.csproj` or Visual Studio Test Explorer
140-
- **Auto-generate binding redirects**: Enabled for assembly version resolution
124+
Build via FieldWorks.sln or `msbuild FieldWorks.csproj`. Test project: FieldWorksTests. Output: FieldWorks.exe, FieldWorks.xml.
141125

142126
## Interfaces and Data Models
143-
144-
- **IFieldWorksManager** (implemented by FieldWorksManager)
145-
- Purpose: Pass-through facade for FieldWorks application access
146-
- Inputs: FwApp instances, Forms, Actions
147-
- Outputs: LcmCache, window creation, async execution
148-
- Notes: Ensures single FieldWorks instance per process
149-
150-
- **IProjectIdentifier** (implemented by ProjectId)
151-
- Purpose: Contract for project identification
152-
- Inputs: Project name, type
153-
- Outputs: Project identity for opening/management
154-
- Notes: Supports serialization for inter-process communication
155-
156-
- **ProjectId** (ProjectId.cs)
157-
- Purpose: Represents FW project identification (existing or potential)
158-
- Inputs: name (string), type (BackendProviderType or inferred)
159-
- Outputs: Serializable project identity
160-
- Notes: Implements ISerializable for marshaling across process boundaries
161-
162-
- **FieldWorksManager.ChooseLangProject** (FieldWorksManager.cs)
163-
- Purpose: User selects language project; opens in existing or new process
164-
- Inputs: FwApp app, Form dialogOwner
165-
- Outputs: Opens project in appropriate FieldWorks process
166-
- Notes: Coordinates multi-instance scenarios via RemoteRequest
167-
168-
- **ILexicalProvider, ILexicalServiceProvider** (LexicalProvider/ILexicalProvider.cs)
169-
- Purpose: Contracts for lexicon service integration
170-
- Inputs: Lexical queries (entries, senses, glosses)
171-
- Outputs: LexicalEntry, LexSense, LexGloss data
172-
- Notes: Enables external tools to query FW lexicon
173-
174-
- **PaObjects namespace classes** (PaObjects/*.cs)
175-
- Purpose: Data transfer objects for Phonology Assistant integration
176-
- Inputs: FW lexical data (entries, senses, pronunciations, variants)
177-
- Outputs: Serializable objects for PA consumption
178-
- Notes: Facilitates data exchange between FieldWorks and Phonology Assistant
179-
180-
- **ApplicationBusyDialog** (ApplicationBusyDialog.cs)
181-
- Purpose: Modal or modeless busy indicator during long operations
182-
- Inputs: WaitFor option (Cancel, NoCancel, TimeLimit, Cancelled)
183-
- Outputs: User interaction (cancel request) or timeout
184-
- Notes: Provides responsiveness during database/file operations
185-
186-
- **WindowsInstallerQuery** (WindowsInstallerQuery.cs)
187-
- Purpose: Query Windows Installer for installed FieldWorks components
188-
- Inputs: Product codes, component identifiers
189-
- Outputs: Installation status, versions
190-
- Notes: Used for upgrade/installation checks
127+
IFieldWorksManager (pass-through facade), IProjectIdentifier (project identity), ProjectId (serializable project ID), ILexicalProvider/ILexicalServiceProvider (lexicon service contracts), PaObjects namespace (Phonology Assistant DTOs), ApplicationBusyDialog (busy indicator), WindowsInstallerQuery (installer checks).
191128

192129
## Entry Points
193-
- **Main executable**: FieldWorks.exe (OutputType=WinExe)
194-
- **FieldWorks singleton**: Application entry point managing lifecycle
195-
- **FieldWorksManager**: Facade for external access to FieldWorks instance
196-
- **WelcomeToFieldWorksDlg**: Startup dialog for project selection (Open, New, Import)
197-
- **ILexicalProvider**: Service interface for external lexical queries
130+
FieldWorks.exe (WinExe); FieldWorks singleton (lifecycle), FieldWorksManager (facade), WelcomeToFieldWorksDlg (startup).
198131

199132
## Test Index
200-
- **Test project**: FieldWorksTests (FieldWorksTests.csproj)
201-
- **Test files**: FieldWorksTests.cs, PaObjectsTests.cs, ProjectIDTests.cs, WelcomeToFieldWorksDlgTests.cs
202-
- **Run tests**: `dotnet test FieldWorksTests/FieldWorksTests.csproj` or Visual Studio Test Explorer
203-
- **Coverage**: Unit tests for ProjectId serialization, PA objects, welcome dialog, core infrastructure
133+
Test project: FieldWorksTests. Run via `dotnet test` or Test Explorer.
204134

205135
## Usage Hints
206-
- **Launch FieldWorks**: Run FieldWorks.exe; WelcomeToFieldWorksDlg appears for project selection
207-
- **Access from code**: Use FieldWorksManager facade to interact with FieldWorks singleton
208-
- **Open project programmatically**: Use FieldWorksManager.ChooseLangProject() or OpenNewWindowForApp()
209-
- **Lexical service integration**: Implement ILexicalProvider for external tool access to FW lexicon
210-
- **PA integration**: Use PaObjects namespace for data exchange with Phonology Assistant
211-
- **Multi-instance coordination**: ProjectId and RemoteRequest handle opening projects in existing processes
136+
Run FieldWorks.exe for startup dialog. Use FieldWorksManager facade for programmatic access. Implement ILexicalProvider for external lexicon queries.
212137

213138
## Related Folders
214-
- **Common/Framework/**: Application framework (FwApp, IFwMainWnd) used by FieldWorks
215-
- **Common/FwUtils/**: FieldWorks utilities (IFieldWorksManager, ThreadHelper) consumed by FieldWorks
216-
- **XCore/**: Framework components integrating FieldWorks infrastructure
217-
- **xWorks/**: Main FLEx application consumer of FieldWorks infrastructure
218-
- **LexText/**: Uses FieldWorks for project management and application lifecycle
139+
Common/Framework (FwApp base), Common/FwUtils (utilities), XCore (framework), xWorks (main consumer), LexText (project management).
219140

220141
## References
221-
- **Project files**: FieldWorks.csproj (net48, WinExe), FieldWorksTests/FieldWorksTests.csproj, BuildInclude.targets
222-
- **Target frameworks**: .NET Framework 4.8.x (net48)
223-
- **Key dependencies**: SIL.LCModel, SIL.LCModel.Utils, DesktopAnalytics, System.Windows.Forms
224-
- **Key C# files**: FieldWorks.cs, FieldWorksManager.cs, ProjectId.cs, ApplicationBusyDialog.cs, WelcomeToFieldWorksDlg.cs, MoveProjectsDlg.cs, FwRestoreProjectSettings.cs, WindowsInstallerQuery.cs, RemoteRequest.cs
225-
- **LexicalProvider files**: ILexicalProvider.cs, LexicalProviderImpl.cs, LexicalServiceProvider.cs, LexicalProviderManager.cs
226-
- **PaObjects files**: PaLexEntry.cs, PaLexSense.cs, PaCmPossibility.cs, PaMediaFile.cs, PaMultiString.cs, PaRemoteRequest.cs, PaVariant.cs, PaVariantOfInfo.cs, PaWritingSystem.cs, PaLexPronunciation.cs, PaLexicalInfo.cs, PaComplexFormInfo.cs
227-
- **Designer files**: ApplicationBusyDialog.Designer.cs, MoveProjectsDlg.Designer.cs, WelcomeToFieldWorksDlg.Designer.cs
228-
- **Resources**: ApplicationBusyDialog.resx, MoveProjectsDlg.resx, WelcomeToFieldWorksDlg.resx, Properties/Resources.resx
229-
- **Icons**: BookOnCube.ico, CubeOnBook.ico, variants (Large, Small, Version)
230-
- **Configuration**: App.config
231-
- **Total lines of code**: 8685
232-
- **Output**: Output/Debug/FieldWorks.exe, Output/Debug/FieldWorks.xml
233-
- **Namespace**: SIL.FieldWorks, SIL.FieldWorks.LexicalProvider, SIL.FieldWorks.PaObjects
142+
Project files: FieldWorks.csproj (net48, WinExe), FieldWorksTests, BuildInclude.targets. Key files (8685 lines): FieldWorks.cs, FieldWorksManager.cs, ProjectId.cs, LexicalProvider/, PaObjects/. See `.cache/copilot/diff-plan.json` for file details.

0 commit comments

Comments
 (0)