Creating an unowned CmPossibilityList issues no PropChanged
还没有人认领这个 Issue。
评估
调研方向
从 UnitOfWorkService.cs、Virtuals.cs、CmObject.cs 和 FactoryAdditions.cs 开始,将 LexEntry 和 Text 的 virtual-notification 实现与 CreateUnowned 路径进行比较。跟踪 SetDefaultValuesAfterInit 和 OnBeforeObjectDeleted,包括 bootstrap guard,然后验证创建或删除无所有者的 CmPossibilityList 是否会产生预期的 PropChanged 通知,以及是否使用了无所有者的 Factory 初始化路径。
由索引模型根据 Issue 内容生成。
描述
Gap
IUnitOfWorkService.RegisterObjectAsCreated (src/SIL.LCModel/Infrastructure/Impl/UnitOfWorkService.cs:583) records creation as an LcmStateChangeObjectCreation (src/SIL.LCModel/Infrastructure/Impl/LcmStateChangingClasses.cs:279). That class derives from LcmStateChangeBase and does not implement ILcmPropertyChanged. UnitOfWork.GetPropChangeInformation (src/SIL.LCModel/Infrastructure/Impl/UnitOfWork.cs:621) yields only from actions that implement ILcmPropertyChanged, so object creation by itself produces no ChangeInformation.
For an owned object the PropChanged arrives from the owning property's LcmVectorPropertyChanged / LcmAtomicRefPropertyChanged. An unowned object has no owning property, so no IVwNotifyChange.PropChanged is issued at all. This is the open TODO at UnitOfWorkService.cs:599:
// (TODO: What needs to be done for unowned objects?)
ICmPossibilityListFactory.CreateUnowned (src/SIL.LCModel/DomainImpl/FactoryAdditions.cs:1560) hits this. The new CmPossibilityList is registered in the IdentityMap, is returned by ICmPossibilityListRepository.AllInstances(), and is persisted as a UOW newbie — but no client receives a PropChanged, so nothing that caches a view of the lists is told to reload.
Proposed fix
Apply the pattern already used for the other unowned classes:
LexEntry.RegisterVirtualsModifiedForObjectCreation(src/SIL.LCModel/DomainImpl/OverridesLing_Lex.cs:854) →Virtuals.LexDbEntriesText.RegisterVirtualsModifiedForObjectCreation/...ForObjectDeletion(src/SIL.LCModel/DomainImpl/OverridesLing_Wfi.cs:1713and:1746) →Virtuals.LangProjTexts
-
Add a
Virtualsaccessor forLangProject.AllPossibilityLists, which already exists as a virtual property (src/SIL.LCModel/DomainImpl/OverridesLangProj.cs:83, declared[VirtualProperty(CellarPropertyType.ReferenceCollection, "CmPossibilityList")]). Model it onVirtuals.LangProjTexts(src/SIL.LCModel/DomainImpl/Virtuals.cs:205). -
On
CmPossibilityList, overrideRegisterVirtualsModifiedForObjectCreationandRegisterVirtualsModifiedForObjectDeletion(src/SIL.LCModel/DomainImpl/CmObject.cs:1758and:1769) to calluow.RegisterVirtualCollectionAsModifiedfor that flid onCache.LangProject, and invoke them fromSetDefaultValuesAfterInit/OnBeforeObjectDeletedthe wayTextdoes. -
Make
CmPossibilityListFactory.CreateUnownedcall((ICmObjectInternal)result).InitializeNewOwnerlessCmObjectWithPresetGuid()before returning, matching the generated ownerlessCmPossibilityListFactory.Create(Guid)(src/SIL.LCModel/DomainImpl/GeneratedFactoryImplementations.cs:320-327). Without this,SetDefaultValuesAfterInitnever runs on theCreateUnownedpath and the hook added in step 2 would not fire.
ChangeReconciler.ReconcileForeignChanges already calls RegisterVirtualsModifiedForObjectCreation on each foreign newby (src/SIL.LCModel/Infrastructure/Impl/ChangeReconciler.cs:212), so step 2 also covers Send/Receive and second-window reconciliation.
Note that SetDefaultValuesAfterInit also runs during bootstrap and data migration, where Cache.LangProject may not be resolvable; LexEntry and Text carry the same exposure, so follow whatever guard they rely on.
Out of scope
Custom field metadata is a separate mechanism with no notification path at all: LcmMetaDataCache.AddCustomField / UpdateCustomField / DeleteCustomField mutate m_metaFieldRecords in place, and FieldDescription.UpdateCustomField registers affected objects as modified but registers no metadata change. Clients must continue to be notified manually after adding a custom field.
- 主要语言
- C#
- 星标
- 3
- 派生
- 15
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sillsdev/liblcm 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 38/100
-
License mismatch未关闭
难度 2/5 1-3 小时 新手友好度 55/100
-
Enable Nullable reference types可能重新可做 @hahn-kev 于 126 天前认领,目前没有进行中的 PR。 未关闭engineering
相似的 Issue
-
enhancement needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/microsoft-ui-reactor#1460 ·
维护者通常 1 天内回复
-
t/bug
难度 2/5 1-3 小时 新手友好度 75/100
dotnet/maui#39950 · 1 个 reaction ·
维护者通常 1 天内回复
-
The server's default HttpClient fails on plain http and on HTTPS servers without HTTP/2可能已有人在做 @yasmoradi 今天认领。 未关闭area / templates
难度 2/5 1-3 小时 新手友好度 73/100
bitfoundation/bitplatform#14659 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
CommunityToolkit/Datasync#600 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
NimblePros/deviq-hugo#121 ·
维护者通常 1 天内回复