{"id":20130746,"url":"https://github.com/rafaelmelo007/csharpcodebuilder","last_synced_at":"2025-10-11T14:38:24.192Z","repository":{"id":258236099,"uuid":"458522688","full_name":"rafaelmelo007/CSharpCodeBuilder","owner":"rafaelmelo007","description":"Implemented c# source code class compiler in runtime using Microsoft.CodeAnalysis.","archived":false,"fork":false,"pushed_at":"2022-02-12T14:13:24.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-13T08:46:28.659Z","etag":null,"topics":["code-analysis","csharp","dotnet-core6"],"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/rafaelmelo007.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":"2022-02-12T12:59:54.000Z","updated_at":"2022-02-12T14:10:49.000Z","dependencies_parsed_at":"2024-10-18T04:58:27.903Z","dependency_job_id":null,"html_url":"https://github.com/rafaelmelo007/CSharpCodeBuilder","commit_stats":null,"previous_names":["rafaelmelo007/csharpcodebuilder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelmelo007%2FCSharpCodeBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelmelo007%2FCSharpCodeBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelmelo007%2FCSharpCodeBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelmelo007%2FCSharpCodeBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafaelmelo007","download_url":"https://codeload.github.com/rafaelmelo007/CSharpCodeBuilder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241577072,"owners_count":19984940,"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":["code-analysis","csharp","dotnet-core6"],"created_at":"2024-11-13T20:39:57.290Z","updated_at":"2025-10-11T14:38:19.142Z","avatar_url":"https://github.com/rafaelmelo007.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSharpCodeBuilder\nc# helper to compile source code in runtime. Using Microsoft.CodeAnalysis.\n\n### Sample code\n```c#\nvar sourceCode = @\"using System; \npublic class ConsoleLogger : ILogger\n{ \n    public void Info(string msg) \n    { \n        Console.WriteLine($\"\"[INFO] {msg}\"\", msg); \n    } \n    public void Warn(string msg) \n    { \n        Console.WriteLine($\"\"[WARN] {msg}\"\", msg); \n    } \n    public DateTime Now() \n    { \n        return DateTime.Now; \n    } \n}\";\n\n// 1. Compile source code and generate its assembly\nvar scriptBuilder = new CSharpCodeBuilder();\nvar assembly = scriptBuilder.CompileCode(sourceCode, typeof(Console), typeof(ILogger), typeof(DateTime));\n\n// 2. Instantiate ConsoleLogger class\nvar consoleLogger = scriptBuilder.CreateInstance\u003cILogger\u003e(assembly);\nif (consoleLogger is null)\n{\n    throw new Exception(\"Unable to create instance of ConsoleLogger.\");\n}\n\n// 3. Execute a method implemented in ConsoleLogger\nvar now = consoleLogger.Now(); \nconsoleLogger.Info($\"Print INFO at {now}!\");\nconsoleLogger.Warn($\"Print WARN at {now}!\");\n\n// ****************************** //\n\npublic interface ILogger\n{\n    void Info(string msg);\n    void Warn(string msg);\n    DateTime Now();\n}\n\n\n```\n\n### Output in console will be:\n```shell\n[INFO] Print INFO at 2/12/2022 11:02:42 AM!\n[WARN] Print WARN at 2/12/2022 11:02:42 AM!\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelmelo007%2Fcsharpcodebuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaelmelo007%2Fcsharpcodebuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelmelo007%2Fcsharpcodebuilder/lists"}