{"record":{"id":"ee9d6f8bca110d95","repo":"Unity-Technologies/UnityCsReference","slug":"value-cannot-be-null-parameter-additionalcompil","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'additionalCompilerArguments')","messagePattern":"Value cannot be null\\. \\(Parameter 'additionalCompilerArguments'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayerSettings.bindings.cs","lineNumber":1112,"sourceCode":"                throw new ArgumentNullException(nameof(defines));\n\n            SetScriptingDefineSymbols(buildTarget, ScriptingDefinesHelper.ConvertScriptingDefineArrayToString(defines));\n        }\n\n        [StaticAccessor(\"GetPlayerSettings().GetEditorOnlyForUpdate()\")]\n        [NativeMethod(\"SetUserScriptingDefineSymbols\", ThrowsException = true)]\n        private static extern void SetScriptingDefineSymbolsInternal(string buildTargetName, string defines);\n\n        [StaticAccessor(\"GetPlayerSettings().GetEditorOnly()\")]\n        [NativeMethod(\"GetAdditionalCompilerArguments\", ThrowsException = true)]\n        private static extern string[] GetAdditionalCompilerArgumentsInternal(string buildTargetName);\n        public static string[] GetAdditionalCompilerArguments(NamedBuildTarget buildTarget) =>\n            GetAdditionalCompilerArgumentsInternal(buildTarget.TargetName);\n\n        public static void SetAdditionalCompilerArguments(NamedBuildTarget buildTarget, string[] additionalCompilerArguments)\n        {\n            if (additionalCompilerArguments == null)\n                throw new ArgumentNullException(nameof(additionalCompilerArguments));\n\n            SetAdditionalCompilerArgumentsInternal(buildTarget.TargetName, additionalCompilerArguments);\n        }\n\n        [StaticAccessor(\"GetPlayerSettings().GetEditorOnlyForUpdate()\")]\n        [NativeMethod(\"SetAdditionalCompilerArguments\", ThrowsException = true)]\n        private static extern void SetAdditionalCompilerArgumentsInternal(string buildTargetName, string[] additionalCompilerArguments);\n\n        [StaticAccessor(\"GetPlayerSettings().GetEditorOnly()\")]\n        [NativeMethod(\"GetPlatformArchitecture\", ThrowsException = true)]\n        private static extern int GetArchitectureInternal(string buildTargetName);\n        public static int GetArchitecture(NamedBuildTarget buildTarget) => GetArchitectureInternal(buildTarget.TargetName);\n\n        [StaticAccessor(\"GetPlayerSettings().GetEditorOnlyForUpdate()\")]\n        [NativeMethod(\"SetPlatformArchitecture\", ThrowsException = true)]\n        private static extern void SetArchitectureInternal(string buildTargetName, int architecture);\n        public static void SetArchitecture(NamedBuildTarget buildTarget, int architecture) =>\n            SetArchitectureInternal(buildTarget.TargetName, architecture);","sourceCodeStart":1094,"sourceCodeEnd":1130,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayerSettings.bindings.cs#L1094-L1130","documentation":"Thrown by PlayerSettings.SetAdditionalCompilerArguments(NamedBuildTarget buildTarget, string[] additionalCompilerArguments) when the array is null. The method forwards compiler arguments to the native SetAdditionalCompilerArgumentsInternal, which requires a valid (possibly empty) array. An empty array clears existing arguments; null is not a valid sentinel.","triggerScenarios":"Calling SetAdditionalCompilerArguments with a null string[] — for instance when a configuration source returns null for 'no additional arguments' instead of an empty array.","commonSituations":"Build pipeline scripts reading compiler arguments from config files that may be absent; CI/CD scripts that pass null when a feature flag is off; deserialization of compiler argument lists that are null by default.","solutions":["Pass Array.Empty<string>() instead of null when you want no additional compiler arguments.","Null-coalesce at the call site: SetAdditionalCompilerArguments(target, args ?? Array.Empty<string>()).","Initialize the collection eagerly: var args = new List<string>(); then convert with .ToArray() which is never null."],"exampleFix":"// before\nPlayerSettings.SetAdditionalCompilerArguments(target, null);\n\n// after\nPlayerSettings.SetAdditionalCompilerArguments(target, args ?? Array.Empty<string>());","handlingStrategy":"validation","validationCode":"PlayerSettings.SetAdditionalCompilerArguments(target, args ?? Array.Empty<string>());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass Array.Empty<string>() instead of null when no additional compiler arguments are needed.","Initialize argument collections eagerly so .ToArray() is never null.","Null-coalesce at the call site for safety."],"tags":["unity-editor","player-settings","compiler-arguments","null-reference","argument-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}