{"record":{"id":"6d91e59bc9b50ec4","repo":"beeradmoore/dlss-swapper","slug":"unknown-gamelibrary-gamelibrary-while-setting-id","errorCode":null,"errorMessage":"Unknown GameLibrary {GameLibrary} while setting ID","messagePattern":"Unknown GameLibrary (.+?) while setting ID","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Data/Game.cs","lineNumber":233,"sourceCode":"        foreach (var invalidPathChar in PathHelpers.InvalidFileNamePathChars)\n        {\n            if (platformId.Contains(invalidPathChar))\n            {\n                platformId = platformId.Replace(invalidPathChar, '_');\n            }\n        }\n\n        ID = GameLibrary switch\n        {\n            GameLibrary.Steam => $\"steam_{platformId}\",\n            GameLibrary.GOG => $\"gog_{platformId}\",\n            GameLibrary.EpicGamesStore => $\"epicgamesstore_{platformId}\",\n            GameLibrary.UbisoftConnect => $\"ubisoftconnect_{platformId}\",\n            GameLibrary.XboxApp => $\"xboxapp_{platformId}\",\n            GameLibrary.ManuallyAdded => $\"manuallyadded_{platformId}\",\n            GameLibrary.BattleNet => $\"battlenet_{platformId}\",\n            GameLibrary.EAApp => $\"eaapp_{platformId}\",\n            _ => throw new Exception($\"Unknown GameLibrary {GameLibrary} while setting ID\"),\n        };\n    }\n\n    // Bounds how many games can be scanned for DLLs/covers at once. Every game with no previously known\n    // DLLs is re-queued for processing on every launch, so without a limit a large library fires off\n    // hundreds of concurrent recursive directory scans and UI-thread updates at startup.\n    static readonly SemaphoreSlim processGameSemaphore = new SemaphoreSlim(4);\n\n    /// <summary>\n    /// Detects DLSS and updates cover image.\n    /// </summary>\n    public void ProcessGame(bool autoSave = true, bool forceNeedsProcessing = false)\n    {\n        // If we are alreayd procssing we don't need to process again\n        if (Processing == true)\n        {\n            return;\n        }","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/beeradmoore/dlss-swapper/blob/ab9b1e2d4bb04187c48fe58eeea06c2b0ea71fbb/src/Data/Game.cs#L215-L251","documentation":"Game.SetID builds a prefixed string id (e.g. \"steam_1234\") via a switch expression over the GameLibrary enum. Every supported library is listed, so the default arm only fires when GameLibrary holds a value the switch does not know - an enum member added later or a value from a persisted settings file that predates/current code does not recognize.","triggerScenarios":"SetID is called with a Game whose GameLibrary property is an unmapped enum value: a newly added GameLibrary member missing from the switch, or a stale/int value loaded from the database or settings that maps to an undefined/unsupported library.","commonSituations":"Upgrading DLSS Swapper after a new store launcher (new GameLibrary member) was added to the enum but not to SetID's switch; corrupt or hand-edited config storing an out-of-range GameLibrary integer.","solutions":["Add the missing GameLibrary member to the switch expression in SetID with its correct id prefix (follow the existing \"$prefix_{platformId}\" pattern).","Audit the GameLibrary enum: every member must be handled in SetID's switch expression.","If the value came from persisted data, fix/refresh the stored game entry and add validation when loading GameLibrary values from disk.","Check for enum values added by a newer app version being read by an older binary; align app and data versions."],"exampleFix":"// before\nGameLibrary.EAApp => $\"eaapp_{platformId}\",\n_ => throw new Exception($\"Unknown GameLibrary {GameLibrary} while setting ID\"),\n// after\nGameLibrary.EAApp => $\"eaapp_{platformId}\",\nGameLibrary.Steam => $\"steam_{platformId}\", // add any newly introduced member\n_ => throw new InvalidOperationException($\"Unknown GameLibrary {GameLibrary} while setting ID\")","handlingStrategy":"validation","validationCode":"// Validate enum value before calling SetID\nif (Enum.IsDefined(typeof(GameLibrary), game.GameLibrary) == false ||\n    game.GameLibrary is GameLibrary.Unknown)\n{\n    throw new ArgumentException($\"GameLibrary value {game.GameLibrary} is not supported\");\n}","typeGuard":"bool IsSupportedLibrary(GameLibrary lib) =>\n    lib is GameLibrary.Steam or GameLibrary.GOG or GameLibrary.EpicGamesStore\n         or GameLibrary.UbisoftConnect or GameLibrary.XboxApp or GameLibrary.ManuallyAdded\n         or GameLibrary.BattleNet or GameLibrary.EAApp;","tryCatchPattern":"try\n{\n    game.SetID();\n}\ncatch (Exception ex) when (ex.Message.StartsWith(\"Unknown GameLibrary\"))\n{\n    logger.LogError(ex, \"Unmapped GameLibrary {Lib}; skipping game\", game.GameLibrary);\n}","preventionTips":["When adding a GameLibrary enum member, update every switch on it (compiler exhaustive switch expressions help)","Validate GameLibrary values loaded from persisted settings with Enum.IsDefined","Use switch expressions (not if/else) so the compiler warns on unhandled members"],"tags":["enum","switch-statement","game-library","identifier"],"backgroundTag":"unsupported-enum-value","analyzedSha":"ab9b1e2d4bb04187c48fe58eeea06c2b0ea71fbb","analyzedAt":"2026-09-15T05:25:32.979Z","contentChangedAt":"2026-09-15T05:25:32.979Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}