Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LT-21760 when LangProject isn't first #301

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'

- name: Test on Windows
run: dotnet test -a "%UserProfile%\.nuget\packages\nunit3testadapter\4.5.0\build\net462" --no-restore --no-build -p:ParallelizeAssembly=false --configuration Release -- RunConfiguration.FailWhenNoTestsFound=true
run: dotnet test --test-adapter-path "%UserProfile%\.nuget\packages\nunit3testadapter\4.5.0\build\net462" --no-restore --no-build -p:ParallelizeAssembly=false --configuration Release -- RunConfiguration.FailWhenNoTestsFound=true
if: matrix.os != 'ubuntu-latest'

- name: Package
Expand Down
13 changes: 7 additions & 6 deletions src/SIL.LCModel.FixData/HomographFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ internal override void InspectElement(XElement rt)
var citationForm = rt.Element("CitationForm");
if (citationForm != null)
{
if (citationForm.Elements("AUni").Any(e => e.Attribute("ws")?.Value == m_homographWs))
{
entriesWithCitationForm.Add(guid, citationForm);
}
entriesWithCitationForm.Add(guid, citationForm);
}
break;
case "LangProject":
Expand All @@ -103,6 +100,10 @@ internal override void FinalFixerInitialization(Dictionary<Guid, Guid> owners, H
{
base.FinalFixerInitialization(owners, guids, parentToOwnedObjsur, rtElementsToDelete); // Sets base class member variables

// Filter the entriesWithCitationForm to only include those that match the homograph writing system.
var relevantCitationEntries = entriesWithCitationForm.Where(kvp =>
kvp.Value.Elements("AUni").Any(e => e.Attribute("ws")?.Value == m_homographWs)).ToDictionary(kv => kv.Key, kv => kv.Value);

// Create a dictionary with the Form and MorphType guid as the key and a list of ownerguid's as the value. This
// will show us which LexEntries should have homograph numbers. If the list of ownerguids has only one entry then
// it's homograph number should be zero. If the list of owerguids has more than one guid then the LexEntries
Expand All @@ -116,10 +117,10 @@ internal override void FinalFixerInitialization(Dictionary<Guid, Guid> owners, H
if (!m_firstAllomorphs.Contains(morphGuid))
continue;
string rtFormText;
if (entriesWithCitationForm.Keys.Contains(owners[morphGuid]))
if (relevantCitationEntries.Keys.Contains(owners[morphGuid]))
{
var entryGuid = owners[morphGuid];
var cfElement = entriesWithCitationForm[entryGuid];
var cfElement = relevantCitationEntries[entryGuid];
rtFormText = GetStringInHomographWritingSystem(cfElement);
if (string.IsNullOrWhiteSpace(rtFormText))
continue;
Expand Down
56 changes: 25 additions & 31 deletions tests/SIL.LCModel.FixData.Tests/TestData/HomographDrops/Test.fwdata
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<languageproject version="7000051">
<rt class="LangProject" guid="5c937611-0e49-491b-ad5e-b61dd01a45d4">
<HomographWs>
<Uni>enh</Uni>
</HomographWs>
<AnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</AnalysisWss>
<CurAnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</CurAnalysisWss>
<CurPronunWss>
<Uni>enh</Uni>
</CurPronunWss>
<CurVernWss>
<Uni>enh enh-x-source</Uni>
</CurVernWss>
<DateCreated val="2021-03-16 21:26:31.627" />
<DateModified val="2024-03-14 17:37:44.271" />
<HomographWs>
<Uni>enh</Uni>
</HomographWs>
<LexDb>
<objsur guid="af26d792-ea5e-11de-8f7e-0013722f8dec" t="o" />
</LexDb>
<LinkedFilesRootDir>
<Uni>%proj%\LinkedFiles</Uni>
</LinkedFilesRootDir>
<VernWss>
<Uni>enh enh-x-source</Uni>
</VernWss>
</rt>
<rt class="LexEntry" guid="5c7a2684-97dc-4cac-8b31-4e0db5855b27">
<CitationForm>
<AUni ws="enh-x-source">+</AUni>
Expand Down Expand Up @@ -154,4 +123,29 @@
<AUni ws="en">Dictionary</AUni>
</Name>
</rt>
<rt class="LangProject" guid="5c937611-0e49-491b-ad5e-b61dd01a45d4">
<AnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</AnalysisWss>
<CurAnalysisWss>
<Uni>en ru enh-x-source en-x-ref en-x-geo enh</Uni>
</CurAnalysisWss>
<CurPronunWss>
<Uni>enh</Uni>
</CurPronunWss>
<CurVernWss>
<Uni>enh enh-x-source</Uni>
</CurVernWss>
<DateCreated val="2021-03-16 21:26:31.627" />
<DateModified val="2024-03-14 17:37:44.271" />
<HomographWs>
<Uni>enh</Uni>
</HomographWs>
<LexDb>
<objsur guid="af26d792-ea5e-11de-8f7e-0013722f8dec" t="o" />
</LexDb>
<VernWss>
<Uni>enh enh-x-source</Uni>
</VernWss>
</rt>
</languageproject>
Loading