{"id":21534631,"url":"https://github.com/danesparza/feature","last_synced_at":"2025-04-10T01:43:28.536Z","repository":{"id":144199566,"uuid":"112239554","full_name":"danesparza/feature","owner":"danesparza","description":":seedling: Feature flag helpers for .NET","archived":false,"fork":false,"pushed_at":"2018-02-21T15:44:48.000Z","size":57,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T03:24:01.684Z","etag":null,"topics":["configuration","csharp","dotnet","feature","feature-flags","feature-toggles","flags","json-string","nuget","utility","variants"],"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/danesparza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2017-11-27T19:33:39.000Z","updated_at":"2023-11-30T13:20:00.000Z","dependencies_parsed_at":"2023-06-03T03:30:39.705Z","dependency_job_id":null,"html_url":"https://github.com/danesparza/feature","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danesparza%2Ffeature","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danesparza%2Ffeature/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danesparza%2Ffeature/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danesparza%2Ffeature/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danesparza","download_url":"https://codeload.github.com/danesparza/feature/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767225,"owners_count":20992545,"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","csharp","dotnet","feature","feature-flags","feature-toggles","flags","json-string","nuget","utility","variants"],"created_at":"2024-11-24T03:12:07.546Z","updated_at":"2025-04-10T01:43:28.509Z","avatar_url":"https://github.com/danesparza.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# feature [![Build status](https://ci.appveyor.com/api/projects/status/e8b6qyp05k3jk730?svg=true)](https://ci.appveyor.com/project/danesparza/feature) [![NuGet](https://img.shields.io/nuget/v/Feature.svg)](https://www.nuget.org/packages/Feature/)\n\nFeature flag helpers (based on [etsy/feature](http://github.com/etsy/feature) and reddit's [config/feature](https://github.com/reddit/reddit/tree/master/r2/r2/config/feature))\n\n### Quick Start\n\nInstall the [NuGet package](https://www.nuget.org/packages/Feature/) from the package manager console:\n\n```powershell\nInstall-Package Feature\n```\n\n### What are feature flags?\n\nThink of feature flags as another configuration item for your app with some special sauce.  You can guard your code with a feature flag check and then turn parts of your code on/off based on the feature flag status.  \n\nFrom [etsy's docs](https://github.com/etsy/feature#feature-api) on the subject:\n\n\u003e The Feature API is how we selectively enable and disable features at a very fine grain as well as enabling features for a percentage of users for operational ramp-ups and for A/B tests. A feature can be completely enabled, completely disabled, or something in between and can comprise a number of related variants.\n\n### How do I use this?\n\nThese tools help you use your existing configuration system to see if a feature is enabled for a given user/group/network, see what variant (if any) a user should get, and get \u0026 store Feature flags as JSON data.\n\nIt doesn't matter if your config system is [built in to .NET](https://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings(v=vs.110).aspx), uses tools like [Consul](https://www.consul.io/api/kv.html) or [Centralconfig](https://github.com/cagedtornado/centralconfig), or is custom built -- you can use this for feature flags.\n\nIn short: Store your feature flags in your configuration system as a JSON string and use these utilities to interact with your feature flags.\n\n#### See if a feature is enabled\n\nA simple example\n```csharp\nusing FeatureFlags.Library;\n\nif(Feature.IsEnabled(featureFlag))\n{\n  //  The feature is enabled.\n  //  Perform whatever needs to be done for the feature\n}\n```\n\nA more complicated example showing all possible parameters\n```csharp\nusing FeatureFlags.Library;\n\n//  Read in from your configuration system somewhere...\nvar featureFlag = new FeatureFlag{ Users = new List\u003cstring\u003e{ \"iserra\", \"MReynolds\"} };\n\n//  Check the flag to see if our current user/group/privs/network mean that the feature is on or off\n//  (Don't worry:  almost all of these parameters are optional)\nif(Feature.IsEnabled(featureFlag, testUser, testGroup, testUrl, testInternal, testAdmin))\n{\n  //  The feature is enabled.\n  //  Perform whatever needs to be done for the feature\n\n}\n\n//  You can have an else block here...\n//  but more likely you'll just proceed as normal\n\n```\n\n#### Get a feature flag from a JSON string\n\n```csharp\nusing FeatureFlags.Library;\n\nstring jsonString = \"{\\\"enabled\\\": true}\";\nFeatureFlag retval = jsonString.ToFeatureFlag();\n```\n\n#### Store a feature flag to a JSON string\n\n```csharp\nusing FeatureFlags.Library;\n\nvar flag = new FeatureFlag{ Internal = true, Admin = true };\nstring jsonString = flag.ToJSON();\n```\n\n## JSON format\n\nAll available options:\n\n```JSON\n{\n    \"enabled\": \"true\",\n    \"users\": [\n        \"user1\",\n        \"user2\"\n    ],\n    \"groups\": [\n        \"group1\",\n        \"group2\"\n    ],\n    \"percent_loggedin\": 42,\n    \"admin\": true,\n    \"internal\": true\n}\n```\n\n#### Examples\n\nCompletely on\n```JSON\n{ \"enabled\": true}\n```\n\nCompletely off\n```JSON\n{ \"enabled\": false}\n```\n\nOn for admin\n```JSON\n{ \"admin\": true}\n```\n\nOn for internal users/employees\n```JSON\n{ \"internal\": true}\n```\n\nOn for certain users\n```JSON\n{\n    \"users\": [\n        \"user1\",\n        \"user2\"\n    ]\n}\n```\n\nOn for certain groups\n```JSON\n{\n    \"groups\": [\n        \"group1\",\n        \"group2\"\n    ]\n}\n```\n\nOn for a percentage of logged in users (0 being no users, 100 being all of them)\n```JSON\n{ \"percent_loggedin\": 42}\n```\n\nOn for both admin and for certain users\n```JSON\n{\n    \"users\": [\n        \"user1\",\n        \"user2\"\n    ],\n    \"admin\": true\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanesparza%2Ffeature","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanesparza%2Ffeature","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanesparza%2Ffeature/lists"}