{"record":{"id":"717b676a748db996","repo":"Unity-Technologies/UnityCsReference","slug":"name-717b67","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs","lineNumber":159,"sourceCode":"            if (asset == null)\n            {\n                throw new ArgumentNullException(\"asset\");\n            }\n\n            this.type = asset.GetType().ToString();\n            this.name = asset.name;\n        }\n\n        public AssetIdentifier(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.ToString();\n            this.name = name;\n        }\n    }\n\n    /// <summary>\n    /// This attribute is used as a callback to set SRP specific properties from the importer.\n    /// </summary>\n    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]\n    public class MaterialSettingsCallbackAttribute : Attribute\n    {","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs#L141-L177","documentation":"Same AssetIdentifier(Type, string) constructor, second guard: the name argument cannot be null because the identifier is keyed on it for material/asset remapping, and a null name would produce an unmatchable entry. Throwing ArgumentNullException at construction makes the contract explicit instead of letting null propagate into dictionary lookups and equality comparisons.","triggerScenarios":"Calling new AssetIdentifier(someType, null); passing a name read from an asset whose .name field was never set or was explicitly cleared; feeding a name from a nullable config property that defaulted to null.","commonSituations":"Assets imported before being named; config-driven identifier creation with an optional/missing name field; refactor that changed where the name originates.","solutions":["Supply a non-null name; if the source can legitimately be missing, default it to a stable sentinel like string.Empty only if an empty name is acceptable (note: error 42 will then reject empty).","Validate name != null at the call site and surface a clear error naming the offending asset.","Ensure upstream asset naming is populated before identifiers are constructed (e.g. set asset.name during import)."],"exampleFix":"// before\nvar id = new AssetIdentifier(type, asset.name); // asset.name may be null\n\n// after\nif (asset.name == null)\n    throw new InvalidOperationException(\"Asset has no name: \" + asset);\nvar id = new AssetIdentifier(type, asset.name);","handlingStrategy":"validation","validationCode":"string RequireName(string name) {\n    if (name == null)\n        throw new InvalidOperationException(\"Asset name is null.\");\n    return name;\n}\n// then: new AssetIdentifier(type, RequireName(asset.name));","typeGuard":"static bool HasName(string name) => name != null;","tryCatchPattern":null,"preventionTips":["Ensure assets are named before constructing identifiers (set asset.name during import).","Treat a null name as an upstream data error and report the offending asset.","Avoid nullable name sources; default to a generated name at the origin."],"tags":["unity","speedtree","argument-validation","null-check","asset-pipeline"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}