{"id":13629280,"url":"https://github.com/Cricle/StaticReflection","last_synced_at":"2025-04-17T08:34:36.478Z","repository":{"id":168071034,"uuid":"643549754","full_name":"Cricle/StaticReflection","owner":"Cricle","description":"Use roslyn for static reflection","archived":false,"fork":false,"pushed_at":"2023-08-14T08:50:19.000Z","size":246,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T13:16:15.807Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Cricle.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":"2023-05-21T14:18:34.000Z","updated_at":"2024-01-12T09:34:16.000Z","dependencies_parsed_at":"2024-06-14T00:45:35.345Z","dependency_job_id":"36defda4-da15-404c-ab80-589ef9f1a66d","html_url":"https://github.com/Cricle/StaticReflection","commit_stats":null,"previous_names":["cricle/staticreflection"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cricle%2FStaticReflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cricle%2FStaticReflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cricle%2FStaticReflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cricle%2FStaticReflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cricle","download_url":"https://codeload.github.com/Cricle/StaticReflection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249270695,"owners_count":21241400,"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-08-01T22:01:06.375Z","updated_at":"2025-04-17T08:34:36.238Z","avatar_url":"https://github.com/Cricle.png","language":"C#","funding_links":[],"categories":["Content"],"sub_categories":["75. [StaticReflection](https://ignatandrei.github.io/RSCG_Examples/v2/docs/StaticReflection) , in the [EnhancementClass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementclass) category"],"readme":"\u003ch2 align=\"center\"\u003e\nStaticReflection\n\u003c/h2\u003e\n\n\u003ch3 align=\"center\"\u003e\nA fast, easy, scalable static reflection.\n\u003c/h3\u003e\n\n\n## Fast use\n\n* Install from nuget `FastStaticReflection`, `FastStaticReflection.CodeGen`\n\n* Write assembly class\n\n```csharp\n[StaticReflectionAssembly]//for generate assembly code\npublic partial class C\n{\n}\n```\n\n* Tag static type reflection\n\n```csharp\n//You can Tag at assembly\n[assembly: StaticReflection(Type = typeof(StaticReflection.Sample.A))]\n\n//Or Property\n[StaticReflection]\n[StaticReflection(Type =typeof(B))]\npublic A a { get; set; }\n\n//Or class\n[StaticReflection]\npublic class A\n{\n    //....\n}\n```\n\n* For use\n\n```csharp\ninternal class Program\n{\n    static void Main(string[] args)\n    {\n        var b=new Student();\n        var @class=C.Default.Types.First(x =\u003e x.Name == \"Student\");\n        @class.SetProperty(b, \"Id\", 1);//Reflection get property value\n        Console.WriteLine(\"Id: \"+@class.GetProperty(b, \"Id\"));//Reflection set property value\n        var @event = (IEventTransfer)@class.Events.First(x =\u003e x.Name == \"AlreadyGoSchool\");\n        using (var eventScope = @event.CreateScope(b))\n        {\n            eventScope.Start();\n            eventScope.EventTransfed += Instance_EventTransfed;//Reflection listen event\n            var method = @class.Methods.First(x =\u003e x.Name == \"GoToSchool\");\n            Console.WriteLine(\"GoToSchool:\" + method.InvokeUsualMethod(b));//Reflection call method\n        }\n        var obj = @class.Constructors.First(x =\u003e x.ArgumentTypes.Count == 0);\n        var inst = obj.InvokeUsualMethod(null);//Reflection create object\n        Console.WriteLine(inst);\n    }\n\n    private static void Instance_EventTransfed(object? sender, EventTransferEventArgs e)\n    {\n        Console.WriteLine(\"EventRaise: \" + e.Args[0]);\n    }\n}\n[StaticReflection]\npublic record class Student\n{\n    public int Id { get; set; }\n\n    public string? Name { get; set; }\n\n    public event EventHandler\u003cStudent\u003e? AlreadyGoSchool;\n\n    public int GoToSchool()\n    {\n        AlreadyGoSchool?.Invoke(this, this);\n        return Id;\n    }\n}\n[StaticReflectionAssembly]\npublic partial class C\n{\n}\n\n```\n\n## Benchmarks\n\n[Benchmarks](./test/Benchmarks.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCricle%2FStaticReflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCricle%2FStaticReflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCricle%2FStaticReflection/lists"}