private static void HandleCategory()

in src/Core/Compiling/Policy/LlmContentSafetyCompiler.cs [72:97]


    private static void HandleCategory(ICompilationContext context, InitializerValue categoryValues,
        XElement categoriesElement)
    {
        foreach (var categoryValue in categoryValues.UnnamedValues ?? [])
        {
            if (!categoryValue.TryGetValues<ContentSafetyCategory>(out var category))
            {
                continue;
            }

            var categoryElement = new XElement("category");
            if (!categoryElement.AddAttribute(category, nameof(ContentSafetyCategory.Name), "name") ||
                !categoryElement.AddAttribute(category, nameof(ContentSafetyCategory.Threshold), "threshold"))
            {
                context.Report(Diagnostic.Create(
                    CompilationErrors.RequiredParameterNotDefined,
                    categoryValue.Node.GetLocation(),
                    "llm-content-safety.category",
                    nameof(ContentSafetyCategory)
                ));
                continue;
            }

            categoriesElement.Add(categoryElement);
        }
    }