{"id":23885594,"url":"https://github.com/psibr/contextually","last_synced_at":"2025-04-10T01:12:39.252Z","repository":{"id":17055260,"uuid":"81066031","full_name":"psibr/Contextually","owner":"psibr","description":"A dead simple contextual block pattern library that works, even with async/await and threads.","archived":false,"fork":false,"pushed_at":"2024-01-25T07:57:25.000Z","size":578,"stargazers_count":9,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T01:12:32.676Z","etag":null,"topics":["asynclocal","csharp","dotnet","dotnetcore","logging","net46","netstandard","nuget"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psibr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-06T08:42:02.000Z","updated_at":"2024-04-12T07:08:14.000Z","dependencies_parsed_at":"2024-06-21T03:54:03.844Z","dependency_job_id":"56766ea5-3fa0-4de8-82e4-0019d8866987","html_url":"https://github.com/psibr/Contextually","commit_stats":{"total_commits":41,"total_committers":11,"mean_commits":3.727272727272727,"dds":0.6097560975609756,"last_synced_commit":"5ce7c6640f7073fc607219bb147ae50f79241c09"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psibr%2FContextually","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psibr%2FContextually/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psibr%2FContextually/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psibr%2FContextually/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psibr","download_url":"https://codeload.github.com/psibr/Contextually/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137890,"owners_count":21053775,"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":["asynclocal","csharp","dotnet","dotnetcore","logging","net46","netstandard","nuget"],"created_at":"2025-01-04T05:44:47.848Z","updated_at":"2025-04-10T01:12:39.233Z","avatar_url":"https://github.com/psibr.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contextually\n\nEnables contextual information to _flow_ with your code:\n```csharp\nusing System;\nusing Contextually;\n\nnamespace Sample\n{\n  class App\n  {\n    static void Main(string[] args)\n    {\n      // Setup top level context of the entire app.\n      var systemContext = new NameValueCollection\n      {\n        [\"MachineName\"] = System.Environment.MachineName\n      };\n      \n      using (Relevant.Info(systemContext))\n      {\n        // Shows that the context flows even if you start a new thread.\n        Task.Run(AppMainLoop).Wait();\n      }\n      // This is the end of the context scope.\n    }\n    \n    void AppMainLoop()\n    {\n      Console.WriteLine(\"Enter your name:\");\n      var userName = Console.ReadLine();\n\n      var appContext = new NameValueCollection\n      {\n        [\"UserName\"] = userName\n      };\n      \n      // Setup a sub-context of relevant information.\n      using (Relevant.Info(systemContext))\n      {\n        while (...)\n          DoWork();\n      }\n      // End of the sub-scope. The \"UserName\" is not\n      // available anymore, but 'MachineName' still is.\n    }\n\n    void DoWork()\n    {\n      try\n      {\n        ...\n      }\n      catch (Exception ex)\n      {\n        // Now you can collect all contextual information\n        // from all open scopes and sub-scopes.\n        var aggregatedContext = Relevant.Info();\n        // This helps with analysis of 'dynamic' data,\n        // which is not known at compile time.\n        Logger.LogError(ex, aggregatedContext);\n      }\n    }\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsibr%2Fcontextually","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsibr%2Fcontextually","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsibr%2Fcontextually/lists"}