Skip to content

Commit e6d096d

Browse files
committed
'Tis the fix to be simple (or is it?)
TODO: - look at complicated cases in existing code - write unit tests - fix unit tests Change-Id: I2a612b43398e519539f37c20955fb4875fe8ce15
1 parent 0ac10b1 commit e6d096d

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

Src/Common/Controls/XMLViews/XMLViewsTests/XmlBrowseViewBaseVcTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,21 @@ public void GetHeaderLabels_ReturnsColumnSpecLabels()
178178

179179
CollectionAssert.AreEqual(new List<string> { "Ref", "Occurrence" }, columnLabels);
180180
}
181+
182+
[Test]
183+
public void IsValidColumnSpec_ValidReturnsTrue()
184+
{
185+
// set up PossibleColumnSpecs
186+
// Pass a valid node
187+
Assert.IsTrue(false);
188+
}
189+
190+
[Test]
191+
public void IsValidColumnSpec_InvalidReturnsFalse()
192+
{
193+
// set up PossibleColumnSpecs
194+
// Pass an invalid node
195+
Assert.IsFalse(true);
196+
}
181197
}
182198
}

Src/Common/Controls/XMLViews/XmlBrowseViewBaseVc.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,15 @@ internal int ListItemsClass
597597
/// <returns>True if we can't prove the column is invalid</returns>
598598
internal bool IsValidColumnSpec(XmlNode node)
599599
{
600-
List<XmlNode> possibleColumns = ComputePossibleColumns();
600+
// In the simple case, `node`s label should match a label in PossibleColumnSpecs. There may be more complicated cases.
601+
// The existing code sure seems complicated and is entirely untested.
602+
var label = XmlUtils.GetLocalizedAttributeValue(node, "label", null) ??
603+
XmlUtils.GetMandatoryAttributeValue(node, "label");
604+
var oLabel = XmlUtils.GetAttributeValue(node, "originalLabel");
605+
//MenuItem mi = new MenuItem(label, ConfigItemClicked);
606+
if (XmlViewsUtils.FindNodeWithAttrVal(ColumnSpecs, "label", label) != null ||
607+
XmlViewsUtils.FindNodeWithAttrVal(ColumnSpecs, "originalLabel", label) != null)
608+
return PossibleColumnSpecs.Contains(node);
601609
//// first, check to see if we can find some part or child node information
602610
//// to process. Eg. Custom field column nodes that refer to parts that no longer exist
603611
//// because the custom field has been removed so the parts cannot be generated
@@ -610,7 +618,7 @@ internal bool IsValidColumnSpec(XmlNode node)
610618
//bool badReversalIndex = CheckForBadReversalIndex(possibleColumns, node);
611619
//if (badReversalIndex)
612620
// return false;
613-
return true; // valid as far as we can tell.
621+
return true; // valid as far as we can tell.
614622
}
615623

616624
/// <summary>

0 commit comments

Comments
 (0)