From 8be1a78eeab61e595b235ccab3d62dc1f8ba23d5 Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Thu, 14 Nov 2024 16:53:01 -0500 Subject: [PATCH 1/3] LT-21829: Properly remove excluded lex refs --- Src/xWorks/ConfiguredLcmGenerator.cs | 7 ++++++- Src/xWorks/DictionaryPublicationDecorator.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Src/xWorks/ConfiguredLcmGenerator.cs b/Src/xWorks/ConfiguredLcmGenerator.cs index 3841eb9e91..2eba40fde6 100644 --- a/Src/xWorks/ConfiguredLcmGenerator.cs +++ b/Src/xWorks/ConfiguredLcmGenerator.cs @@ -1711,7 +1711,7 @@ private static IFragment GenerateContentForSenses(ConfigurableDictionaryNode con foreach (ILexSense item in senseCollection) { Debug.Assert(item != null); - if (publicationDecorator != null && publicationDecorator.IsExcludedObject(item)) + if (publicationDecorator?.IsExcludedObject(item) ?? false) continue; filteredSenseCollection.Add(item); } @@ -2099,6 +2099,11 @@ private static IFragment GenerateCrossReferenceChildren(ConfigurableDictionaryNo if (targetInfo == null) return settings.ContentGenerator.CreateFragment(); var reference = targetInfo.Item2; + if (targetInfo.Item1 == null || !publicationDecorator.IsPublishableLexRef(reference.Hvo)) + { + return settings.ContentGenerator.CreateFragment(); + } + if (LexRefTypeTags.IsUnidirectional((LexRefTypeTags.MappingTypes)reference.OwnerType.MappingType) && LexRefDirection(reference, collectionOwner) == ":r") { diff --git a/Src/xWorks/DictionaryPublicationDecorator.cs b/Src/xWorks/DictionaryPublicationDecorator.cs index b8d16d461c..9a0c2dd7cf 100644 --- a/Src/xWorks/DictionaryPublicationDecorator.cs +++ b/Src/xWorks/DictionaryPublicationDecorator.cs @@ -525,7 +525,7 @@ private bool IsPublishableReversalEntry(IReversalIndexEntry revEntry) /// /// /// - private bool IsPublishableLexRef(int hvoRef) + public bool IsPublishableLexRef(int hvoRef) { var publishableItems = VecProp(hvoRef, LexReferenceTags.kflidTargets); int originalItemCount = BaseSda.get_VecSize(hvoRef, LexReferenceTags.kflidTargets); From c3d0a4913ae7f47d08509ff88a553b8a2c851af0 Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Thu, 14 Nov 2024 17:17:09 -0500 Subject: [PATCH 2/3] Change an access modifier to internal --- Src/xWorks/DictionaryPublicationDecorator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/xWorks/DictionaryPublicationDecorator.cs b/Src/xWorks/DictionaryPublicationDecorator.cs index 9a0c2dd7cf..69988b8821 100644 --- a/Src/xWorks/DictionaryPublicationDecorator.cs +++ b/Src/xWorks/DictionaryPublicationDecorator.cs @@ -525,7 +525,7 @@ private bool IsPublishableReversalEntry(IReversalIndexEntry revEntry) /// /// /// - public bool IsPublishableLexRef(int hvoRef) + internal bool IsPublishableLexRef(int hvoRef) { var publishableItems = VecProp(hvoRef, LexReferenceTags.kflidTargets); int originalItemCount = BaseSda.get_VecSize(hvoRef, LexReferenceTags.kflidTargets); From 1bf85daf2e9814410e1c8ae64bb5e55c7951312b Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Fri, 15 Nov 2024 16:40:30 -0500 Subject: [PATCH 3/3] Prevent null object reference exception --- Src/xWorks/ConfiguredLcmGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/xWorks/ConfiguredLcmGenerator.cs b/Src/xWorks/ConfiguredLcmGenerator.cs index 2eba40fde6..948ed017cb 100644 --- a/Src/xWorks/ConfiguredLcmGenerator.cs +++ b/Src/xWorks/ConfiguredLcmGenerator.cs @@ -2099,7 +2099,7 @@ private static IFragment GenerateCrossReferenceChildren(ConfigurableDictionaryNo if (targetInfo == null) return settings.ContentGenerator.CreateFragment(); var reference = targetInfo.Item2; - if (targetInfo.Item1 == null || !publicationDecorator.IsPublishableLexRef(reference.Hvo)) + if (targetInfo.Item1 == null || (!publicationDecorator?.IsPublishableLexRef(reference.Hvo) ?? false)) { return settings.ContentGenerator.CreateFragment(); }