-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/FilterByAttribute-key-validation' into develop
Previously, a common scenario for using the `[FilterByAttribute()]` attribute was to filter by content type. As `ContentType` is no longer stored as an attribute (4a9f5b7), this no longer works. To mitigate this, we previously introduced the new `[FilterByContentType()]` attribute (105cfdd). Legacy implementations that previously used `[FilterByAttribute("ContentType", …)]`, however, would not get an error. In fact, it might even appear that it is working if their database contains legacy values for `ContentType` in `Topic.Attributes`. To help avoid errors and confusion, while offering better guidance for migrations, the `[FilterByAttribute()]` attribute has been updated to throw an `ArgumentException` if the implementation attempts to set the `Key` to `ContentType`. In this case, it will advise migrating to `[FilterByContentType()]` instead. Unfortunately, this doesn't offer design-time feedback, but it will offer runtime guidance that the existing behavior isn't working.
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*============================================================================================================================== | ||
| Author Ignia, LLC | ||
| Client Ignia, LLC | ||
| Project Topics Library | ||
\=============================================================================================================================*/ | ||
using OnTopic.Mapping.Annotations; | ||
using OnTopic.ViewModels; | ||
using OnTopic.ViewModels.Collections; | ||
|
||
namespace OnTopic.Tests.ViewModels { | ||
|
||
/*============================================================================================================================ | ||
| VIEW MODEL: FILTERED TOPIC (INVALID) | ||
\---------------------------------------------------------------------------------------------------------------------------*/ | ||
/// <summary> | ||
/// Provides a strongly-typed data transfer object for testing views properties annotated with the <see cref=" | ||
/// FilterByAttributeAttribute"/>. Includes an invalid <see cref="FilterByAttributeAttribute"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is a sample class intended for test purposes only; it is not designed for use in a production environment. | ||
/// </remarks> | ||
public class FilteredInvalidTopicViewModel { | ||
|
||
[FilterByAttribute("ContentType", "Page")] | ||
public TopicViewModelCollection<TopicViewModel> Children { get; } = new(); | ||
|
||
} //Class | ||
} //Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters