Skip to content

Commit b206f3e

Browse files
committed
Extended Refresh() with data validation for root content type
The initial version didn't validate that the `ContentTypeDescriptor` was, in fact, the root `ContentTypeDescriptor`—i.e., the one sourced from `Root:Configuration:ContentTypes`. This addresses that by adding in a `Contract.Requires()` call.
1 parent 3e3930f commit b206f3e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

OnTopic/Metadata/ContentTypeDescriptorCollection.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public void Refresh(ContentTypeDescriptor? rootContentType) {
5353
return;
5454
}
5555

56+
Contract.Requires(
57+
rootContentType.Key.Equals("ContentTypes", StringComparison.OrdinalIgnoreCase),
58+
$"The {nameof(rootContentType)} is expected to represent the root of the content type topic graph, with a " +
59+
$"key of 'ContentTypes'. Instead, the supplied ContentTypeDescriptor has a key of '{rootContentType.Key}'."
60+
);
61+
5662
/*------------------------------------------------------------------------------------------------------------------------
5763
| Clear any existing values
5864
\-----------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)