{"record":{"id":"777555388f14290b","repo":"Unity-Technologies/UnityCsReference","slug":"required-property-name-not-set","errorCode":null,"errorMessage":"Required property 'name' not set","messagePattern":"Required property 'name' not set","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Scripting/ScriptCompilation/CustomScriptAssembly.cs","lineNumber":124,"sourceCode":"        public static CustomScriptAssemblyData FromJsonNoFieldValidation(string json)\n        {\n            var assemblyData = new CustomScriptAssemblyWithLegacyData();\n            assemblyData.autoReferenced = true;\n            UnityEngine.JsonUtility.FromJsonOverwrite(json, assemblyData);\n\n            UpdateRenamedReferences(assemblyData);\n            assemblyData.UpdateLegacyData();\n\n            if (assemblyData == null)\n                throw new System.Exception(\"Json file does not contain an assembly definition\");\n\n            return assemblyData;\n        }\n\n        public void ValidateFields()\n        {\n            if (string.IsNullOrEmpty(name))\n                throw new System.Exception(\"Required property 'name' not set\");\n\n            if ((excludePlatforms != null && excludePlatforms.Length > 0) &&\n                (includePlatforms != null && includePlatforms.Length > 0))\n                throw new System.Exception(\"Both 'excludePlatforms' and 'includePlatforms' are set.\");\n\n            if (autoReferenced && UnityCodeGenHelpers.IsCodeGen(name))\n            {\n                throw new Exception($\"Assembly '{name}' is a CodeGen assembly and cannot be Auto Referenced\");\n            }\n        }\n\n        public static string ToJson(CustomScriptAssemblyData data)\n        {\n            return UnityEngine.JsonUtility.ToJson(data, true);\n        }\n\n        static void UpdateRenamedReferences(CustomScriptAssemblyData data)\n        {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/ScriptCompilation/CustomScriptAssembly.cs#L106-L142","documentation":"Thrown by CustomScriptAssembly.ValidateFields: an assembly definition (.asmdef) is valid only if its 'name' field is a non-empty string. A missing or blank name is rejected before the assembly is registered.","triggerScenarios":"Loading a .asmdef whose 'name' field is null or empty, then calling ValidateFields().","commonSituations":"A hand-edited or generated .asmdef missing the name field, a malformed JSON, or a renamed asmdef that lost its name.","solutions":["Open the .asmdef referenced in the error and add a non-empty \"name\" field.","Validate .asmdef JSON before import (the editor will surface the file path)."],"exampleFix":"// before\n{ \"references\": [] }\n// after\n{ \"name\": \"MyCompany.MyFeature\", \"references\": [] }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(data.name))\n    throw new FormatException(\"Assembly definition is missing the required 'name' field.\");","typeGuard":"static bool HasName(CustomScriptAssemblyData d) =>\n    !string.IsNullOrEmpty(d?.name);","tryCatchPattern":"try { asm.ValidateFields(); }\ncatch (Exception ex) when (ex.Message.Contains(\"'name'\"))\n{ /* open the .asmdef and add a non-empty name */ }","preventionTips":["Always set a unique, non-empty \"name\" in every .asmdef.","Validate generated/templated .asmdef JSON before importing."],"tags":["asmdef","script-compilation","validation","config"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}