{"record":{"id":"21a19179e5b5a415","repo":"stride3d/stride","slug":"at-least-one-profile-must-be-specified","errorCode":null,"errorMessage":"At least one profile must be specified.","messagePattern":"At least one profile must be specified\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Serialization/YamlSerializerFactoryAttribute.cs","lineNumber":27,"sourceCode":"{\n    /// <summary>\n    /// Attribute use to tag a class that is implementing a <see cref=\"IYamlSerializable\"/> or <see cref=\"IYamlSerializableFactory\"/>\n    /// and will be used for asset serialization.\n    /// </summary>\n    [AttributeUsage(AttributeTargets.Class)]\n    public class YamlSerializerFactoryAttribute : Attribute\n    {\n        private readonly string[] profiles;\n        /// <summary>\n        /// The name of the default profile. Any serializer factory that lacks this attribute will be considered to be part of the default profile.\n        /// </summary>\n        public const string Default = \"Default\";\n\n        public YamlSerializerFactoryAttribute(params string[] profiles)\n        {\n            if (profiles == null || profiles.Length == 0)\n            {\n                throw new ArgumentException(\"At least one profile must be specified.\");\n            }\n            this.profiles = profiles;\n        }\n\n        public IReadOnlyList<string> Profiles => profiles;\n\n        public bool ContainsProfile(string profile)\n        {\n            return profiles.Any(x => string.Equals(x, profile, StringComparison.Ordinal));\n        }\n\n        /// <summary>\n        /// Identifies if two profiles are equal.\n        /// </summary>\n        /// <param name=\"profile1\">The first profile to compare.</param>\n        /// <param name=\"profile2\">The second profile to compare.</param>\n        /// <returns>True if profiles are equal, false otherwise.</returns>\n        public static bool AreProfilesEqual(string profile1, string profile2)","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Serialization/YamlSerializerFactoryAttribute.cs#L9-L45","documentation":"The YamlSerializerFactoryAttribute constructor requires at least one serializer profile name. It throws ArgumentException when constructed with a null array or an empty params list, because a factory attribute with no profiles could never match any serializer factory.","triggerScenarios":"Writing [YamlSerializerFactory] (or [YamlSerializerFactory(null)]) on a class without passing any profile string.","commonSituations":"Refactoring away a profile name but leaving the bare attribute; typo of Default profile constant and removing the argument entirely.","solutions":["Pass at least one profile name, e.g. [YamlSerializerFactory(\"Default\")]","Use the YamlSerializerFactoryAttribute.Default constant for the standard profile","Remove the attribute entirely if no custom serializer profile is needed"],"exampleFix":"// before\n[YamlSerializerFactory]\npublic class MyData {}\n// after\n[YamlSerializerFactory(YamlSerializerFactoryAttribute.Default)]\npublic class MyData {}","handlingStrategy":"validation","validationCode":"if (profiles == null || profiles.Length == 0) throw new InvalidOperationException(\"YamlSerializerFactoryAttribute requires at least one profile\");","typeGuard":"null","tryCatchPattern":"// Attribute usage is compile-time; caught as runtime ArgumentException only via reflection-based activation\ntry { var attr = (YamlSerializerFactoryAttribute)Attribute.GetCustomAttribute(t, typeof(YamlSerializerFactoryAttribute)); } catch (ArgumentException ex) { /* report missing profile */ }","preventionTips":["Always pass YamlSerializerFactoryAttribute.Default explicitly","Lint attribute usage in code reviews","Never remove a profile argument without adding a replacement"],"tags":["yaml","serialization","attribute","argument"],"backgroundTag":"missing-required-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}