{"id":16554567,"url":"https://github.com/tyrrrz/cogwheel","last_synced_at":"2025-10-04T00:32:01.315Z","repository":{"id":66154742,"uuid":"79841751","full_name":"Tyrrrz/Cogwheel","owner":"Tyrrrz","description":"Library for managing application settings","archived":false,"fork":false,"pushed_at":"2024-05-22T18:01:29.000Z","size":153,"stargazers_count":21,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-22T18:15:38.821Z","etag":null,"topics":["configuration","dotnet","dotnet-core","dotnet-standard","json","settings"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tyrrrz.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Tyrrrz","patreon":"Tyrrrz","custom":["buymeacoffee.com/Tyrrrz","tyrrrz.me/donate"]}},"created_at":"2017-01-23T19:53:15.000Z","updated_at":"2024-05-31T02:00:41.400Z","dependencies_parsed_at":"2024-04-28T17:22:58.579Z","dependency_job_id":"a5e912a8-e218-4713-8a9f-c9e23891befd","html_url":"https://github.com/Tyrrrz/Cogwheel","commit_stats":{"total_commits":81,"total_committers":6,"mean_commits":13.5,"dds":"0.49382716049382713","last_synced_commit":"fd875f3ef824c023ac44a8579ab85ff491bcf8d8"},"previous_names":["tyrrrz/settings"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyrrrz%2FCogwheel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyrrrz%2FCogwheel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyrrrz%2FCogwheel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyrrrz%2FCogwheel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tyrrrz","download_url":"https://codeload.github.com/Tyrrrz/Cogwheel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235208520,"owners_count":18952998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","dotnet","dotnet-core","dotnet-standard","json","settings"],"created_at":"2024-10-11T19:51:48.610Z","updated_at":"2025-10-04T00:31:56.011Z","avatar_url":"https://github.com/Tyrrrz.png","language":"C#","funding_links":["https://github.com/sponsors/Tyrrrz","https://patreon.com/Tyrrrz","buymeacoffee.com/Tyrrrz","tyrrrz.me/donate"],"categories":[],"sub_categories":[],"readme":"# Cogwheel\n\n[![Status](https://img.shields.io/badge/status-active-47c219.svg)](https://github.com/Tyrrrz/.github/blob/master/docs/project-status.md)\n[![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://tyrrrz.me/ukraine)\n[![Build](https://img.shields.io/github/actions/workflow/status/Tyrrrz/Cogwheel/main.yml?branch=master)](https://github.com/Tyrrrz/Cogwheel/actions)\n[![Coverage](https://img.shields.io/codecov/c/github/Tyrrrz/Cogwheel/master)](https://codecov.io/gh/Tyrrrz/Cogwheel)\n[![Version](https://img.shields.io/nuget/v/Cogwheel.svg)](https://nuget.org/packages/Cogwheel)\n[![Downloads](https://img.shields.io/nuget/dt/Cogwheel.svg)](https://nuget.org/packages/Cogwheel)\n[![Discord](https://img.shields.io/discord/869237470565392384?label=discord)](https://discord.gg/2SUWKFnHSm)\n[![Fuck Russia](https://img.shields.io/badge/fuck-russia-e4181c.svg?labelColor=000000)](https://twitter.com/tyrrrz/status/1495972128977571848)\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd width=\"99999\" align=\"center\"\u003eDevelopment of this project is entirely funded by the community. \u003cb\u003e\u003ca href=\"https://tyrrrz.me/donate\"\u003eConsider donating to support!\u003c/a\u003e\u003c/b\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"favicon.png\" alt=\"Icon\" /\u003e\n\u003c/p\u003e\n\n**Cogwheel** (formerly [**Tyrrrz.Settings**](https://nuget.org/packages/Tyrrrz.Settings)) is a simple library for storing and retrieving settings in desktop applications.\nIt serves as a replacement for the built-in [`System.Configuration.SettingsBase`](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.settingsbase) class, and offers more customization and flexibility.\n\n## Terms of use\u003csup\u003e[[?]](https://github.com/Tyrrrz/.github/blob/master/docs/why-so-political.md)\u003c/sup\u003e\n\nBy using this project or its source code, for any purpose and in any shape or form, you grant your **implicit agreement** to all the following statements:\n\n- You **condemn Russia and its military aggression against Ukraine**\n- You **recognize that Russia is an occupant that unlawfully invaded a sovereign state**\n- You **support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas**\n- You **reject false narratives perpetuated by Russian state propaganda**\n\nTo learn more about the war and how you can help, [click here](https://tyrrrz.me/ukraine). Glory to Ukraine! 🇺🇦\n\n## Install\n\n- 📦 [NuGet](https://nuget.org/packages/Cogwheel): `dotnet add package Cogwheel`\n\n## Usage\n\nTo define your own application settings, create a class that inherits from `SettingsBase`:\n\n```csharp\nusing Cogwheel;\n\npublic class MySettings() : SettingsBase(\"path/to/settings.json\")\n{\n    public string StringSetting { get; set; } = \"foo\";\n\n    public int IntSetting { get; set; } = 42;\n}\n```\n\nUsing an instance of this class, you can load, modify, and save settings:\n\n```csharp\nvar settings = new MySettings();\n\nsettings.Load();\n\nsettings.StringSetting = \"bar\";\nsettings.IntSetting = 1337;\n\nsettings.Save();\n```\n\nYou can also restore settings to their default values:\n\n```csharp\nvar settings = new MySettings();\n\nsettings.StringSetting = \"bar\";\nsettings.IntSetting = 1337;\n\nsettings.Reset();\n\n// settings.StringSetting == \"foo\"\n// settings.IntSetting == 42\n```\n\n### Customizing behavior\n\nUnder the hood, **Cogwheel** uses [`System.Text.Json`](https://docs.microsoft.com/en-us/dotnet/api/system.text.json) to serialize and deserialize settings.\nYou can use various attributes defined in that namespace to customize the serialization behavior:\n\n```csharp\nusing Cogwheel;\nusing System.Text.Json.Serialization;\n\npublic class MySettings() : SettingsBase(\"path/to/settings.json\")\n{\n    [JsonPropertyName(\"string_setting\")]\n    public string StringSetting { get; set; } = \"foo\";\n\n    [JsonIgnore]\n    public int IntSetting { get; set; } = 42;\n}\n```\n\nYou can also provide a custom `JsonSerializerOptions` instance to further customize the serialization process:\n\n```csharp\nusing Cogwheel;\nusing System.Text.Json;\n\npublic class MySettings() : SettingsBase(\n    \"path/to/settings.json\",\n    new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }\n)\n{\n    public string StringSetting { get; set; } = \"foo\";\n\n    public int IntSetting { get; set; } = 42;\n}\n```\n\n### Compile-time serialization\n\nIf you want to use compile-time serialization as opposed to relying on reflection, you need to provide a valid `IJsonTypeInfoResolver` instance.\nYou can provide it either directly or as part of a `JsonSerializerOptions` instance:\n\n```csharp\nusing Cogwheel;\nusing System.Text.Json.Serialization;\n\npublic class MySettings() : SettingsBase(\n    \"path/to/settings.json\",\n    MyJsonSerializerContext.Default\n    // Or:\n    // new JsonSerializationOptions { TypeInfoResolver = MyJsonSerializerContext.Default }\n)\n{\n    public string StringSetting { get; set; } = \"foo\";\n\n    public int IntSetting { get; set; } = 42;\n}\n\n// Define a custom JSON serialization context for auto-generated code\n[JsonSerializable(typeof(MySettings))]\ninternal partial class MyJsonSerializerContext : JsonSerializerContext;\n```\n\n\u003e **Note**:\n\u003e To learn more about compile-time serialization in `System.Text.Json`, see the [official documentation](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyrrrz%2Fcogwheel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyrrrz%2Fcogwheel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyrrrz%2Fcogwheel/lists"}