{"record":{"id":"b58828029442b255","repo":"Unity-Technologies/UnityCsReference","slug":"type","errorCode":null,"errorMessage":"type","messagePattern":"type","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetPipeline/AssetImporter.bindings.cs","lineNumber":42,"sourceCode":"    {\n        public struct SourceAssetIdentifier\n        {\n            public SourceAssetIdentifier(Object asset)\n            {\n                if (asset == null)\n                {\n                    throw new ArgumentNullException(\"asset\");\n                }\n\n                this.type = asset.GetType();\n                this.name = asset.name;\n            }\n\n            public SourceAssetIdentifier(Type type, string name)\n            {\n                if (type == null)\n                {\n                    throw new ArgumentNullException(\"type\");\n                }\n\n                if (name == null)\n                {\n                    throw new ArgumentNullException(\"name\");\n                }\n\n                if (string.IsNullOrEmpty(name))\n                {\n                    throw new ArgumentException(\"The name is empty\", \"name\");\n                }\n\n                this.type = type;\n                this.name = name;\n            }\n\n            public Type type;\n            public string name;","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetPipeline/AssetImporter.bindings.cs#L24-L60","documentation":"AssetImporter.SourceAssetIdentifier(Type type, string name) constructor throws ArgumentNullException with param name 'type' when type is null. The constructor needs a valid System.Type to populate the identifier's type field. This is the type-name overload, distinct from the Object-based constructor (error 33).","triggerScenarios":"Constructing new SourceAssetIdentifier(null, name) where the Type argument is null. This happens when type resolution fails (e.g., Type.GetType returns null for a type not in the executing assembly), or when a serialized type name cannot be resolved back to a Type object.","commonSituations":"Remap utilities that deserialize type names from external data (JSON, XML) and resolve them via Type.GetType, which returns null for types not in the calling assembly or mscorlib. Also occurs after assembly reorganization where type full names change.","solutions":["Null-check the Type: if (type != null) new SourceAssetIdentifier(type, name).","Use assembly-qualified type names and Assembly.GetType fallback when Type.GetType returns null.","Validate type resolution and log the unresolved type name for debugging."],"exampleFix":"// before\nvar t = Type.GetType(serializedTypeName);\nvar id = new SourceAssetIdentifier(t, assetName);\n\n// after\nvar t = Type.GetType(serializedTypeName);\nif (t == null)\n    t = AppDomain.CurrentDomain.GetAssemblies()\n        .Select(a => a.GetType(serializedTypeName))\n        .FirstOrDefault(x => x != null);\nif (t != null)\n    var id = new SourceAssetIdentifier(t, assetName);","handlingStrategy":"validation","validationCode":"if (type != null)\n    var id = new AssetImporter.SourceAssetIdentifier(type, name);\nelse\n    Debug.LogWarning($\"Cannot create SourceAssetIdentifier: type is null\");","typeGuard":"static bool IsValidType(Type type) => type != null;","tryCatchPattern":"try { var id = new AssetImporter.SourceAssetIdentifier(type, name); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"type\")\n{ Debug.LogWarning($\"Skipped SourceAssetIdentifier: {ex.Message}\"); }","preventionTips":["Use assembly-qualified names and fallback assembly search for Type.GetType","Validate resolved Type objects before constructing identifiers","Handle type-resolution failures gracefully with logging"],"tags":["unity","csharp","asset-pipeline","asset-importer","source-asset-identifier","type-resolution","null-check"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}