{"id":15882188,"url":"https://github.com/another-guy/mirror","last_synced_at":"2025-08-13T11:32:58.203Z","repository":{"id":89024186,"uuid":"62982631","full_name":"another-guy/Mirror","owner":"another-guy","description":"Syntax-honeyed .NET reflection","archived":false,"fork":false,"pushed_at":"2017-06-16T17:39:57.000Z","size":60,"stargazers_count":0,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-06T04:47:57.952Z","etag":null,"topics":[],"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/another-guy.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}},"created_at":"2016-07-10T05:08:17.000Z","updated_at":"2017-01-05T16:23:49.000Z","dependencies_parsed_at":"2023-06-16T10:30:48.551Z","dependency_job_id":null,"html_url":"https://github.com/another-guy/Mirror","commit_stats":{"total_commits":58,"total_committers":2,"mean_commits":29.0,"dds":0.3620689655172413,"last_synced_commit":"9034cd0d6ee6ec072469f6c0f07bdb16b4b5764e"},"previous_names":["another-guy/constructionset"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/another-guy%2FMirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/another-guy%2FMirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/another-guy%2FMirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/another-guy%2FMirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/another-guy","download_url":"https://codeload.github.com/another-guy/Mirror/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229759827,"owners_count":18119871,"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":[],"created_at":"2024-10-06T04:01:54.534Z","updated_at":"2024-12-14T21:43:23.315Z","avatar_url":"https://github.com/another-guy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Synopsis\n\n[![Mirror](https://github.com/another-guy/Mirror/raw/master/Mirror.png)](https://github.com/another-guy/Mirror)\n\nSimplifies C# reflection code.\n\n## Status\n\nNuGet (stable)\n\n[![NuGet](https://img.shields.io/nuget/v/Mirror.svg)](https://www.nuget.org/packages/Mirror/)\n[![NuGet](https://img.shields.io/nuget/vpre/Mirror.svg)](https://www.nuget.org/packages/Mirror/)\n\nMyGet (latest)\n\n[![MyGet CI](https://img.shields.io/myget/another-guy/v/Mirror.svg)](https://www.myget.org/feed/another-guy/package/nuget/Mirror)\n[![MyGet CI](https://img.shields.io/myget/another-guy/vpre/Mirror.svg)](https://www.myget.org/feed/another-guy/package/nuget/Mirror)\n\nBuild\n\n[![Build status](https://ci.appveyor.com/api/projects/status/as29kthpwxftaiy6?svg=true)](https://ci.appveyor.com/project/another-guy/mirror)\n\nIssues and pull requests\n\n[![GitHub issues](https://img.shields.io/github/issues/another-guy/mirror.svg?maxAge=2592000)](https://github.com/another-guy/Mirror/issues)\n\n## Code Example\n\n### Describing the target\n\nTo access or invoke a private method that is defined on a `type` or an `object` client code needs to specify the target correctly.\nTargets' members can be either static or instance.\nNotice that `constructors` must be accessed through a **static** target since no **instance target** is available yet:\n\n```cs\nclass MyClass {\n  private string name;\n  private MyClass() { this.name = \"Name is not set\"; }\n  private MyClass(string name) { this.name = name; }\n}\n\nMyClass targetObject = ...;\n\nvar staticTarget = Use.Target\u003cMyClass\u003e();\n// staticTarget can now be used to call constructor or\n// call or access static members\n\nvar instanceTarget = Use.Target(targetObject)\n// instanceTarget can now be used to call or access targetObject's members\n```\n\n### Creating an instance of an object\n\n```cs\n// Creates object by calling its default constructor\nMyClass newInstance = Use.Target\u003cMyClass\u003e().ToCreateInstance();\n\n// Creates object by calling its best matching parameterized constructor\nMyClass newInstance = Use.Target\u003cMyClass\u003e().ToCreateInstance(\"Alice\");\n```\n\n### Working with instance members\n\n```cs\nclass MyClass {\n  private string name;\n  private string Name { get { return name; } set { name = value } }\n  private void SetName(string newName) { name = newName; }\n  private string GetName() { return name; }\n}\nMyClass target = new MyClass();\n\n// Field/Property access code looks similar\nUse.Target(target).Set(\"name\").Value(\"Bob\")\nUse.Target(target).Set(\"Name\").Value(\"Chris\")\nstring nameFromField = Use.Target(target).ToGet\u003cstring\u003e(\"name\");\nstring nameFromProperty = Use.Target(target).ToGet\u003cstring\u003e(\"Name\");\n\n// Method access\nUse.Target(target).ToCall(\"SetName\", \"David\");\nstring nameFromMethod = Use.Target(target).ToCall\u003cstring\u003e(\"GetName\");\n```\n\n### Working with static members\n\n```cs\nstatic class MyClass {\n  private static string name;\n  private static string Name { get { return name; } set { name = value } }\n  private static void SetName(string newName) { name = newName; }\n  private static string GetName() { return name; }\n}\n\nUse.Target\u003cMyClass\u003e().Set(\"name\").Value(\"Bob\")\nstring nameFromStaticField = Use.Target\u003cMyClass\u003e().ToGet\u003cstring\u003e(\"name\");\n\nUse.Target\u003cMyClass\u003e().Set(\"Name\").Value(\"Chris\")\nstring nameFromStaticProperty = Use.Target\u003cMyClass\u003e().ToGet\u003cstring\u003e(\"Name\");\n\nUse.Target\u003cMyClass\u003e().ToCall(\"SetName\", \"David\");\nstring nameFromStaticMethod = Use.Target\u003cMyClass\u003e().ToCall\u003cstring\u003e(\"GetName\");\n```\n\n### Attribute discovery\n\nAttribute retrieval can be string-based (full type name argument required).\n\n```\nIEnumerable\u003cAttribute\u003e obsoleteClassAttribute =\n\ttypeof(TargetClass)\n\t\t.GetAttributes(\"System.Obsolete\")\n\t\t.SingleOrDefault();\n\nIEnumerable\u003cAttribute\u003e obsoleteMethodAttribute =\n\ttypeof(TargetClass)\n\t\t.GetMethod(\"TargetMethod\")\n\t\t.GetAttributes(\"System.Obsolete\")\n\t\t.SingleOrDefault();\n```\n\nAlternatively, the generic method can be used if specific attribute type is known at compile time.\n\n```\nIEnumerable\u003cObsolete\u003e obsoleteClassAttribute =\n\ttypeof(TargetClass)\n\t\t.GetAttributes\u003cObsolete\u003e()\n\t\t.SingleOrDefault();\n\nIEnumerable\u003cObsolete\u003e obsoleteMethodAttribute =\n\ttypeof(TargetClass)\n\t\t.GetMethod(\"TargetMethod\")\n\t\t.GetAttributes\u003cObsolete\u003e()\n\t\t.SingleOrDefault();\n```\n\n## Motivation\n\nSyntax sugar is syntax sugar: it's not a necessary thing per se but it can improve code quality.\nReflection should be your last resort tool when used in production code:\ntypes very often limit constructor and other members' accessibility level on purpose.\n\nIn your tests, however, it may be okay to have slightly sloppier code.\nFor example, you may want to build a dummy/fake object and for some reason mocking tools like NSubstitute can't do it.\n\n## Installation\n\nMirror is a available in a form of a NuGet package.\nFollow regular installation process to bring it to your project.\nhttps://www.nuget.org/packages/Mirror/\n\n## Tests\n\nUnit tests are available in Mirror.Tests project.\n\n## License\n\nThe code is distributed under the MIT license.\n\n## Reporting an Issue\n\nReporting an issue, proposing a feature, or asking a question are all great ways to improve software quality.\n\nHere are a few important things that package contributors will expect to see in a new born GitHub issue:\n* the relevant version of the package;\n* the steps to reproduce;\n* the expected result;\n* the observed result;\n* some code samples illustrating current inconveniences and/or proposed improvements.\n\n## Contributing\n\nContribution is the best way to improve any project!\n\n1. Fork it!\n2. Create your feature branch (```git checkout -b my-new-feature```).\n3. Commit your changes (```git commit -am 'Added some feature'```)\n4. Push to the branch (```git push origin my-new-feature```)\n5. Create new Pull Request\n\n...or follow steps described in a nice [fork guide](http://kbroman.org/github_tutorial/pages/fork.html) by Karl Broman\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanother-guy%2Fmirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanother-guy%2Fmirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanother-guy%2Fmirror/lists"}