{"record":{"id":"2c598ceff53f8ca5","repo":"Unity-Technologies/UnityCsReference","slug":"unknown-opt-out-decision-type","errorCode":null,"errorMessage":"Unknown opt out decision type","messagePattern":"Unknown opt out decision type","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/EditorDialog.cs","lineNumber":110,"sourceCode":"            int sessionResult = SessionState.GetInt(prefixedKey, -1);\n\n            // We never store a result of -1 in the SessionState, so if we get -1 back, it means no result has been set.\n            return sessionResult == -1 ? null : (DialogResult)sessionResult;\n        }\n\n        private static void SetOptOutResultForKey(string key, DialogResult result, DialogOptOutDecisionType decisionType)\n        {\n            string prefixedKey = PrefixedKey(key);\n            switch (decisionType)\n            {\n                case DialogOptOutDecisionType.ForThisSession:\n                    SessionState.SetInt(prefixedKey, (int)result);\n                    break;\n                case DialogOptOutDecisionType.ForThisUser:\n                    EditorPrefs.SetInt(prefixedKey, (int)result);\n                    break;\n                default:\n                    throw new NotImplementedException(\"Unknown opt out decision type\");\n            }\n        }\n\n        private static string GetOptOutCheckboxLabel(DialogOptOutDecisionType optOutDecisionType)\n        {\n            switch (optOutDecisionType)\n            {\n                case DialogOptOutDecisionType.ForThisSession:\n                    return L10n.Tr(\"Don't ask again for this session\");\n                case DialogOptOutDecisionType.ForThisUser:\n                    return L10n.Tr(\"Don't ask again on this computer\");\n                default:\n                    throw new NotImplementedException(\"Unknown opt out decision type\");\n            }\n        }\n\n        private static string AdjustTitleText(string titleText)\n        {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/EditorDialog.cs#L92-L128","documentation":"Thrown by EditorDialog.SetOptOutResultForKey in the default branch of its switch on DialogOptOutDecisionType. The switch only handles ForThisSession and ForThisUser; note ForThisMachine is declared as an alias 'ForThisMachine = ForThisUser' (same integer value), so it routes to the ForThisUser branch and does NOT hit this default. The throw is therefore a defensive guard for a future-added enum member that has not been wired up. NotImplementedException signals incomplete coverage.","triggerScenarios":"Passing a DialogOptOutDecisionType value that is neither ForThisSession nor ForThisUser (nor the ForThisMachine alias) — only achievable today by an invalid cast from an out-of-range integer, e.g. (DialogOptOutDecisionType)42. Currently unreachable through normal API use.","commonSituations":"Reflection or serialization that reconstructs the enum from an arbitrary int; a future Unity version adding a new decision type before updating this switch; misuse via unsafe enum casting.","solutions":["Validate the enum value is defined before calling: if (!Enum.IsDefined(typeof(DialogOptOutDecisionType), decisionType)) reject it.","If you are extending the enum, also add the case here and in GetOptOutCheckboxLabel.","For callers, stick to the named constants (ForThisSession / ForThisUser / ForThisMachine) and never cast raw ints."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(DialogOptOutDecisionType), decisionType))\n    throw new ArgumentOutOfRangeException(nameof(decisionType));","typeGuard":"static bool IsKnownDecision(DialogOptOutDecisionType d) =>\n    d == DialogOptOutDecisionType.ForThisSession || d == DialogOptOutDecisionType.ForThisUser;","tryCatchPattern":null,"preventionTips":["Use only named DialogOptOutDecisionType constants; never cast raw ints.","Validate enums reconstructed from serialized data with Enum.IsDefined.","When adding a new enum member, update every switch over it."],"tags":["editor","dialog","enum","notimplemented","defensive"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}