{"id":20688755,"url":"https://github.com/71/blur","last_synced_at":"2026-04-22T16:35:19.160Z","repository":{"id":95480677,"uuid":"77486845","full_name":"71/blur","owner":"71","description":"[No longer maintained] Run and edit a C# assembly at the same time. Convert LINQ Expressions and delegates to Mono.Cecil method bodies as well.","archived":false,"fork":false,"pushed_at":"2017-06-17T22:23:56.000Z","size":157,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T22:24:28.682Z","etag":null,"topics":["assembly","cecil","csharp"],"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/71.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":"2016-12-27T22:44:12.000Z","updated_at":"2024-07-30T14:20:49.000Z","dependencies_parsed_at":"2023-06-03T02:00:30.099Z","dependency_job_id":null,"html_url":"https://github.com/71/blur","commit_stats":null,"previous_names":["6a/blur"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/71/blur","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/71%2Fblur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/71%2Fblur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/71%2Fblur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/71%2Fblur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/71","download_url":"https://codeload.github.com/71/blur/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/71%2Fblur/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32145868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T15:33:03.595Z","status":"ssl_error","status_checked_at":"2026-04-22T15:30:42.712Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["assembly","cecil","csharp"],"created_at":"2024-11-16T23:06:52.426Z","updated_at":"2026-04-22T16:35:14.152Z","avatar_url":"https://github.com/71.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blur\nBlur uses [Mono.Cecil](https://github.com/jbevain/cecil) to weave assemblies from the inside.\nTo make this easier, Blur provides fluent APIs for IL generation and `MethodDefinition` invocation.\n\n## Warning\nBlur has been deprecated in favor of [Cometary](https://github.com/6A/Cometary), and more specifically its [IL](https://github.com/6A/Cometary/samples/Cometary.IL) sample.\n\n## Five-minutes annotated guide\n```csharp\nusing System;\nusing Mono.Cecil;\nusing Mono.Cecil.Cil;\nusing Blur;\n\n// The only requirement when using Blur is to mark\n// the assembly with the BlurAttribute.\n// This attribute also exposes some useful settings.\n// Here, the CleanUp property is set to true:\n//  bool CleanUp { get; set; }\n// In this case, all references to Mono.Cecil and Blur will\n// be removed from the assembly, including all weavers\n// and visitors.\n[assembly: Blur(CleanUp = true)]\n\n/// \u003csummary\u003e\n/// Forces the marked method to block its execution before\n/// returning.\n/// \u003c/summary\u003e\n[AttributeUsage(AttributeTargets.Method)]\nsealed class BlockMethodAttribute : Attribute, IMethodWeaver\n{\n    // The IMethodWeaver interface must be set on this attribute\n    // to register it as a compile-time attribute.\n    // Its only declaration is:\n    //  void Apply(MethodDefinition)\n    // There are other interfaces such as this one, for every element\n    // that can be marked with an attribute, EXCEPT assemblies and modules.\n\n    private readonly static MethodReference ReadLineMethod\n        = typeof(Console).GetMethod(nameof(Console.ReadLine)).GetReference();\n\n    /// \u003csummary\u003e\n    /// Prepends \u003csee cref=\"Console.ReadLine\"/\u003e before all\n    /// \u003csee langword=\"ret\"/\u003e op codes.\n    /// \u003c/summary\u003e\n    public void Apply(MethodDefinition method)\n    {\n        // The ILWriter is the class used by Blur users to edit methods.\n        // It provides a Fluent API, and the ability to inject non-IL code,\n        // such as LINQ Expressions and delegates, directly into bodies.\n        //\n        // The ILWriter can be obtained with 4 methods:\n        //  ILWriter Write(this MethodBody body)\n        //  ILWriter Write(this MethodDefinition method)\n        //  ILWriter Rewrite(this MethodBody body)\n        //  ILWriter Rewrite(this MethodDefinition method)\n        //\n        // Using Rewrite() will reset the method's body.\n        ILWriter writer = method.Write();\n\n        // Iterate over every instruction in the method's body.\n        // If the body is changed during an iteration, the\n        // current position of the ILWriter (obtainable with the\n        // ILWriter.Position property) will be automatically updated.\n        writer.ForEach(ins =\u003e\n        {\n            // If the opcode of the instruction is \"ret\", ...\n            // For those of you that are not familiar with IL, \"ret\" is\n            // the opcode that corresponds to \"return the value at the top of the stack\".\n            if (ins.OpCode == OpCodes.Ret)\n                // ILWriter's fluent API chains calls together.\n                // The following expression will write the following IL code:\n                //  call    string [mscorlib]System.Console::ReadLine()\n                //  pop\n                // Note that Call() automatically inserts 'this' if the method is\n                // an instance method, and uses Callvirt if needed.\n                writer\n                    .Before(ins)            // Position writer before the given instruction\n                    .Call(ReadLineMethod)   //  call string [mscorlib]System.Console::ReadLine()\n                    .Pop();                 //  pop\n        });\n    }\n}\n\nclass Program\n{\n    [BlockMethod]\n    public static void Main(string[] args)\n    {\n        Console.WriteLine(\"Hopefully, you will have time to see this message...\");\n    }\n}\n```\n\n## How to install\n#### `Install-Package Blur -Pre`\nCurrently compatible with:\n- .NET Standard 1.3 and over.\n- .NET 4.5 PCL and over.\n\n## Features\n#### `ILWriter`\nThe `ILWriter` class provides fluent methods meant to make editing\nIL easy. IL can be emitted:\n- Using delegates (via `ILWriter.Delegate(delegate)`).\n- Using LINQ Expressions (via `ILWriter.Expression(Expression)`).\n- Using a simplified emitter.\n- Using raw IL (via `ILWriter.Emit(OpCode, ...)` and `Blur.Extensions.ILWriterExtensions`).\n\n#### `BlurVisitor`\nThe `BlurVisitor` provides many methods that will be called whenever\na declaration is about to or has been modified by Blur:\n- `void Visit(TypeDefinition type)`\n- `void Visit(FieldDefinition field)`\n- `void Visit(MethodDefinition method)`\n- ...\n\nAny class that inherits `BlurVisitor` and is in `BlurAttribute.Visitors` will automatically be created and used when weaving an assembly.\n\n#### In-Assembly weaving\n- The entire assembly is available to you during compilation.\n- Methods can be invoked at any time, even if they have been previously modified.\n- Placing a breakpoint in a `IWeaver` method is enough to debug the modification of your assembly.\n\n#### Miscellaneous\n- Conversion helpers, adding the ability to convert from `System.Reflection` to `Mono.Cecil`, and vise-versa (via `Blur.BlurExtensions`).\n- **Fully** documented assembly, including every IL instruction.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F71%2Fblur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F71%2Fblur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F71%2Fblur/lists"}