For C# mods, the <samp>ItemContextTagManager</samp> class simplifies working with [[Modding:Items#Context tags|item context tags]] and reduces repeated code.
+
+
This provides a few utility methods:
+
{| class="wikitable"
+
|-
+
! method
+
! effect
+
|-
+
| <code>GetBaseContextTags(id)</code>
+
| Get the base context tags for an item based on its raw data in <samp>Data/Objects</samp> or <samp>Data/BigCraftables</samp>. This doesn't include dynamic tags added that are based on instance info (like quality), which you can get using <code>item.GetContextTags()</code>.
+
|-
+
| <code>DoesTagQueryMatch(query, tags)</code>
+
| Get whether a context tag query matches the given tags. For example, <code>ItemContextTagManager.DoesTagQueryMatch("bone_item, !fossil_item", item.GetContextTags())</code> returns true if the item is a bone item but not a fossil (like the [[Bone Flute]]).
| Get whether every (<samp>DoAllTagsMatch</samp>) or at least one (<samp>DoAnyTagsMatch</samp) required tag matches the actual item tags. This supports negated required tags like <samp>"!fossil_item"</samp> too.
| Get whether a single tag matches the actual item tags. This supports negated required tags like <samp>"!fossil_item"</samp> too.
+
|-
+
| <code>SanitizeContextTag(tag)</code>
+
| ''(Specialized)'' Replace characters that may appear in item names so they're valid in context tags. For example, <code>SanitizeContextTag("Sam's Boombox")</code> returns <samp>sams_boombox</samp>.