{"id":19992196,"url":"https://github.com/skbkontur/gremit","last_synced_at":"2025-04-13T02:19:39.677Z","repository":{"id":33480030,"uuid":"37125755","full_name":"skbkontur/gremit","owner":"skbkontur","description":".NET Reflection.Emit extensions","archived":false,"fork":false,"pushed_at":"2024-04-07T18:11:02.000Z","size":1691,"stargazers_count":157,"open_issues_count":4,"forks_count":22,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-04-28T22:03:29.933Z","etag":null,"topics":["csharp","dotnet","il","ilgenerator","reflection"],"latest_commit_sha":null,"homepage":null,"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/skbkontur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-06-09T10:29:34.000Z","updated_at":"2024-06-18T13:58:36.268Z","dependencies_parsed_at":"2024-06-18T14:08:38.291Z","dependency_job_id":null,"html_url":"https://github.com/skbkontur/gremit","commit_stats":{"total_commits":299,"total_committers":21,"mean_commits":"14.238095238095237","dds":0.5518394648829432,"last_synced_commit":"f235b2962ed18ed81abc17f287516a149152122a"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skbkontur%2Fgremit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skbkontur%2Fgremit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skbkontur%2Fgremit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skbkontur%2Fgremit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skbkontur","download_url":"https://codeload.github.com/skbkontur/gremit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654388,"owners_count":21140289,"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":["csharp","dotnet","il","ilgenerator","reflection"],"created_at":"2024-11-13T04:52:04.526Z","updated_at":"2025-04-13T02:19:39.652Z","avatar_url":"https://github.com/skbkontur.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# GrEmit\n\n[![NuGet Status](https://img.shields.io/nuget/v/GrEmit.svg)](https://www.nuget.org/packages/GrEmit/)\n[![Build status](https://github.com/skbkontur/gremit/actions/workflows/actions.yml/badge.svg)](https://github.com/skbkontur/gremit/actions)\n\n\nGrEmit is a library containing different helpers for generating code using Reflection.Emit with the main one being GroboIL - a smart wrapper over [ILGenerator](http://msdn.microsoft.com/en-us/library/system.reflection.emit.ilgenerator.aspx).\n\n## Usage\n\nGroboIL is a replacement for ILGenerator. Instead of calling ILGenerator.Emit(OpCode, ..), one may call GroboIL.OpCode(..).\n\n### Example\n\nILGenerator:\n```\n// .. creating DynamicMethod, MethodBuilder or ConstructorBuilder\nvar il = method.GetILGenerator();\nil.Emit(OpCodes.Ldarg_0);\nil.Emit(OpCodes.Ldc_i4_4);\nil.EmitCall(OpCodes.Callvirt, someMethod, null);\nil.Emit(OpCodes.Ret);\n```\nGroboIL:\n```\n// .. creating DynamicMethod, MethodBuilder or ConstructorBuilder\nusing(var il = new GroboIL(method))\n{\n    il.Ldarg(0);\n    il.Ldc_I4(4);\n    il.Call(someMethod);\n    il.Ret();\n}\n```\n\n## Advantages\nBesides more beautiful interface GroboIL has some more advantages over ILGenerator:\n - GroboIL has a single method for all instructions from the same family, for instance, instead of 11 instructions OpCodes.Ldelem_* there is one method GroboIL.Ldelem(Type type).\n - During code generation GroboIL builds the content of the evaluation stack and validates instructions arguments, and if something is not OK, immediately throws an Exception.\n - There is a debug ouput of the code being generated.\n - Full generics support.\n - It is possible to debug MethodBuilders (use constructor of GroboIL with parameter [ISymbolDocumentWriter](http://msdn.microsoft.com/en-us/library/system.diagnostics.symbolstore.isymboldocumentwriter.aspx)).\n - Appropriate performance. For instance, once I had to compile a program with 500000 instructions and it was verified by GroboIL in 3 seconds (I guess there is a way to break performance, but in practice such a program won't occure).\n\nExample of debug output:\n\nGroboIL.GetILCode()\n```\n        ldarg.0              // [List\u003cT\u003e]\n        dup                  // [List\u003cT\u003e, List\u003cT\u003e]\n        brtrue notNull_0     // [null]\n        pop                  // []\n        ldc.i4.0             // [Int32]\n        newarr T             // [T[]]\nnotNull_0:                   // [{Object: IList, IList\u003cT\u003e, IReadOnlyList\u003cT\u003e}]\n        ldarg.1              // [{Object: IList, IList\u003cT\u003e, IReadOnlyList\u003cT\u003e}, Func\u003cT, Int32\u003e]\n        call Int32 Enumerable.Sum\u003cT\u003e(IEnumerable\u003cT\u003e, Func\u003cT, Int32\u003e)\n                             // [Int32]\n        ret                  // []\n```\n\n## Release Notes\n\nSee [CHANGELOG](CHANGELOG.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskbkontur%2Fgremit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskbkontur%2Fgremit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskbkontur%2Fgremit/lists"}