// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Text.Json.Serialization; #pragma warning disable CA2227 // Change 'x' to be read-only by removing the property setter namespace EpicGames.Horde.Issues { /// /// Fingerprint for an issue. Can be embedded into a structured log event under the "$issue" property to guide how Horde should group the event. /// public class IssueFingerprint : IIssueFingerprint { /// /// The type of issue, which defines the handler to use for it /// [JsonPropertyName("type")] public string Type { get; set; } = "None"; /// /// Template string for the issue summary /// [JsonPropertyName("summary")] public string SummaryTemplate { get; set; } = String.Empty; /// /// List of keys which identify this issue. /// [JsonIgnore] public HashSet Keys { get; set; } = new HashSet(); IReadOnlySet IIssueFingerprint.Keys => Keys; /// /// Set of keys which should trigger a negative match /// [JsonPropertyName("rejectKeys")] public HashSet? RejectKeys { get; set; } IReadOnlySet? IIssueFingerprint.RejectKeys => RejectKeys; /// /// Collection of additional metadata added by the handler /// [JsonIgnore] public HashSet Metadata { get; set; } = new HashSet(); IReadOnlySet IIssueFingerprint.Metadata => Metadata; /// /// Filter for changes that touch files which should be included in this issue /// [JsonPropertyName("filter")] public string ChangeFilter { get; set; } = "..."; /// /// Keys set which is null when empty /// [JsonPropertyName("keys")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public HashSet? SerializedKeys { get => (Keys.Count == 0) ? null : Keys; set => Keys = value ?? new HashSet(); } /// /// Metadata set which is null when empty /// [JsonPropertyName("meta")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public HashSet? SerializedMetadata { get => (Metadata.Count == 0) ? null : Metadata; set => Metadata = value ?? new HashSet(); } /// /// Default constructor /// public IssueFingerprint() { } /// /// Constructor /// public IssueFingerprint(string type, string summaryTemplate) { Type = type; SummaryTemplate = summaryTemplate; } } }