Skip to content

Commit aef9a5a

Browse files
committed
Reverted ItemListElement to match schema.org type ordering; fixed up unit tests to reflect semantics.
1 parent d76993c commit aef9a5a

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

Source/Schema.NET/core/ItemList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public partial interface IItemList : IIntangible
1414
/// Text values are best if the elements in the list are plain strings. Existing entities are best for a simple, unordered list of existing things in your data. ListItem is used with ordered lists when you want to provide additional context about the element in that list or when the same item might be in different places in different lists.<br/><br/>
1515
/// Note: The order of elements in your mark-up is not sufficient for indicating the order or elements. Use ListItem with a 'position' property in such cases.
1616
/// </summary>
17-
Values<IThing, string, IListItem>? ItemListElement { get; set; }
17+
Values<IListItem, string, IThing>? ItemListElement { get; set; }
1818

1919
/// <summary>
2020
/// Type of ordering (e.g. Ascending, Descending, Unordered).
@@ -46,7 +46,7 @@ public partial class ItemList : Intangible, IItemList
4646
/// </summary>
4747
[DataMember(Name = "itemListElement", Order = 206)]
4848
[JsonConverter(typeof(ValuesJsonConverter))]
49-
public Values<IThing, string, IListItem>? ItemListElement { get; set; }
49+
public Values<IListItem, string, IThing>? ItemListElement { get; set; }
5050

5151
/// <summary>
5252
/// Type of ordering (e.g. Ascending, Descending, Unordered).

Source/Schema.NET/core/combined/CreativeWorkAndItemListAndListItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public abstract partial class CreativeWorkAndItemListAndListItem : Intangible, I
389389
/// </summary>
390390
[DataMember(Name = "itemListElement", Order = 257)]
391391
[JsonConverter(typeof(ValuesJsonConverter))]
392-
public Values<IThing, string, IListItem>? ItemListElement { get; set; }
392+
public Values<IListItem, string, IThing>? ItemListElement { get; set; }
393393

394394
/// <summary>
395395
/// Type of ordering (e.g. Ascending, Descending, Unordered).

Tests/Schema.NET.Test/core/BreadcrumbListTest.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ public void Deserializing_BreadcrumbListJsonLd_ReturnsBreadcrumbList()
7979
{
8080
var breadcrumbList = JsonConvert.DeserializeObject<BreadcrumbList>(this.json, TestDefaults.DefaultJsonSerializerSettings);
8181

82+
List<IThing> things = breadcrumbList.ItemListElement;
8283
List<IListItem> listItems = breadcrumbList.ItemListElement;
83-
Assert.Equal(2, listItems.Count);
84-
var listItem1 = listItems.First();
85-
var listItem2 = listItems.Last();
84+
Assert.Equal(2, things.Count);
85+
Assert.Empty(listItems);
86+
var thing1 = things.First();
87+
var thing2 = things.Last();
88+
var listItem1 = (IListItem)thing1;
89+
var listItem2 = (IListItem)thing2;
8690
Assert.Equal(1, listItem1.Position);
8791
Assert.Equal(2, listItem2.Position);
8892
var book = listItem1.Item.OfType<IBook>().FirstOrDefault();

Tests/Schema.NET.Test/core/ItemListTest.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ public void Deserializing_ItemListJsonLd_ReturnsItemList()
195195
Assert.Equal(2, itemList.ItemListElement.Value.Count);
196196
var listItems = (List<IListItem>)itemList.ItemListElement.Value;
197197
var things = (List<IThing>)itemList.ItemListElement.Value;
198-
Assert.Equal(2, listItems.Count);
199-
Assert.Empty(things);
200-
var listItem1 = listItems.First();
201-
var listItem2 = listItems.Last();
198+
Assert.Empty(listItems);
199+
Assert.Equal(2, things.Count);
200+
var thing1 = things.First();
201+
var thing2 = things.Last();
202+
var listItem1 = (IListItem)thing1;
203+
var listItem2 = (IListItem)thing2;
202204
Assert.Equal(1, listItem1.Position);
203205
Assert.Equal(2, listItem2.Position);
204206
var recipe1 = Assert.IsType<Recipe>(listItem1.Item.Single());

0 commit comments

Comments
 (0)