{"id":25654253,"url":"https://github.com/bert2/microscope","last_synced_at":"2025-07-05T12:33:16.433Z","repository":{"id":54576294,"uuid":"287106167","full_name":"bert2/microscope","owner":"bert2","description":":microscope: CodeLens extension for Visual Studio that lets you inspect the intermediate language instructions of methods and properties.","archived":false,"fork":false,"pushed_at":"2022-02-27T10:23:39.000Z","size":3554,"stargazers_count":41,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T09:55:42.881Z","etag":null,"topics":["cil","codelens","codelens-extension","common-intermediate-language","il","marketplace","msil","visual-studio","visual-studio-extension"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=bert.microscope","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/bert2.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}},"created_at":"2020-08-12T20:10:46.000Z","updated_at":"2024-07-10T10:34:48.000Z","dependencies_parsed_at":"2022-08-13T20:20:14.075Z","dependency_job_id":null,"html_url":"https://github.com/bert2/microscope","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bert2%2Fmicroscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bert2%2Fmicroscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bert2%2Fmicroscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bert2%2Fmicroscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bert2","download_url":"https://codeload.github.com/bert2/microscope/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249252438,"owners_count":21238184,"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":["cil","codelens","codelens-extension","common-intermediate-language","il","marketplace","msil","visual-studio","visual-studio-extension"],"created_at":"2025-02-23T20:19:00.825Z","updated_at":"2025-04-16T14:53:04.556Z","avatar_url":"https://github.com/bert2.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# microscope\r\n\r\n[![build](https://img.shields.io/appveyor/build/bert2/microscope/main?logo=appveyor)](https://ci.appveyor.com/project/bert2/microscope/branch/main) [![CodeFactor](https://www.codefactor.io/repository/github/bert2/microscope/badge)](https://www.codefactor.io/repository/github/bert2/microscope) ![last commit](https://img.shields.io/github/last-commit/bert2/microscope/main?logo=github) [![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/bert.microscope?label=marketplace\u0026logo=visual-studio\u0026logoColor=%23bb88f3)](https://marketplace.visualstudio.com/items?itemName=bert.microscope) [![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/bert.microscope?label=installs\u0026logo=visual-studio\u0026logoColor=%23bb88f3)](https://marketplace.visualstudio.com/items?itemName=bert.microscope)\r\n\r\nA CodeLens extension for Visual Studio that lets you inspect the intermediate language instructions of methods and properties.\r\n\r\n![Usage example](img/usage.gif \"Usage example\")\r\n\r\nIt also shows the compiler-generated code for lambdas/closures, local functions, `async` methods, and iterators:\r\n\r\n![Usage example: compiler-generated code](img/usage-csc-gen.gif \"Usage example: compiler-generated code\")\r\n\r\nIt's mostly useful for learning and getting a better understanding of how C# works internally, but it's a must-have if you enjoy procrastinating work with futile micro-optimizations:\r\n\r\n![Usage example: micro-optimization](img/usage-opt.gif \"Usage example: micro-optimization\")\r\n\r\n## Installation\r\n\r\n### Visual Studio 2022\r\n\r\n- Install latest stable release from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=bert.microscope).\r\n- Alternatively you can grab the [VSIX package](https://ci.appveyor.com/project/bert2/microscope/branch/main/artifacts) of the latest build from AppVeyor.\r\n\r\n### Visual Studio 2019\r\n\r\n- Installation via Extension Marketplace is not possible. Download the VSIX package of the [v1.1.0 release](https://github.com/bert2/microscope/releases/tag/1.1.0) and install microscope manually.\r\n\r\n## Usage\r\n\r\n- The CodeLens appears on C#/VB methods/properties and displays the number of instructions that will be generated for the method.\r\n- Click the CodeLens to get a detailed list of all instructions including their offsets and operands.\r\n- Hover over an instruction in the list to see its documentation summary in a tooltip.\r\n- Double-click an instruction in the list to navigate to its documentation on [docs.microsoft.com](https://docs.microsoft.com/dotnet/api/system.reflection.emit.opcodes).\r\n- Hover over the CodeLens to see individual counts for the number of `box` and unconstrained `callvirt` instructions in the method as well the method's/property's byte size.\r\n- The CodeLens will automatically update everytime you save the current document. You can also click the \"Refresh\" button in the bottom left of the details view.\r\n- Any types that the compiler generated for the method/property (e.g. for lambdas) will be shown below the list of instructions together with their methods and instructions.\r\n- In case the retrieval of instructions fails the CodeLens will display `-` instead of a count. Hover over the CodeLens to see the exception that caused the failure.\r\n- Configuration options are available in the Visual Studio settings (\"Tools\" \u003e \"Options...\" \u003e \"microscope\").\r\n\r\n![Settings page](img/settings-page.png \"Settings page\")\r\n\r\n## Known issues\r\n\r\n- Visual Studio might freeze for a couple of seconds when you open the details view for a method with a huge amount of instructions (i.e. multiple thousands). This might be fixed in a future release.\r\n\r\n## Contributing\r\n\r\nBug reports and pull requests are always welcome!\r\n\r\n### Issue tracker\r\n\r\nFeel free to [create an issue on GitHub](https://github.com/bert2/microscope/issues/new) if you found a bug, have a question or got an idea how to improve microscope.\r\n\r\n### Cloning the source\r\n\r\n```powershell\r\nPS\u003e git clone https://github.com/bert2/microscope.git\r\nPS\u003e cd microscope\r\n```\r\n\r\n### Building\r\n\r\nBuilding microscope from source requires Visual Studio 2019 and the [Visual Studio SDK](https://docs.microsoft.com/en-us/visualstudio/extensibility/installing-the-visual-studio-sdk?view=vs-2019).\r\n\r\nYou can build using either Visual Studio or the build script located in microscope's root directory:\r\n\r\n```powershell\r\nPS\u003e ./build.ps1 compile\r\n```\r\n\r\n### Running the tests\r\n\r\nThe tests are implemented using MSTest. You can execute them via Visual Studio or from microscope's root directory:\r\n\r\n```powershell\r\nPS\u003e ./build.ps1 test # will also build\r\n```\r\n\r\n### `nuke` global tool\r\n\r\nMicroscope uses [nuke](https://github.com/nuke-build/nuke) as its build tool. You can install nuke's global tool via `dotnet`:\r\n\r\n```powershell\r\nPS\u003e dotnet tool install Nuke.GlobalTool --global\r\n```\r\n\r\nDon't forget to setup its [auto-completion](https://www.nuke.build/docs/running-builds/global-tool.html#shell-snippets) too.\r\n\r\nEven though the global tool is not required, it makes life a little bit easier:\r\n\r\n```powershell\r\nPS\u003e nuke test # build and run tests\r\n```\r\n\r\n## Possible features for future releases\r\n\r\n- show C# code in details view\r\n- lazy load when method has too many instructions to prevent temporarily freezing VS\r\n- don't show CodeLens on interface/abstract methods\r\n- reduce namespace noise in operands column of details view\r\n  - setting for that\r\n  - checkbox in details view for the setting as well\r\n- is it possible to move in-memory compiling and IL retrieval out of the VS process?\r\n    - can we even access the `Compilation` out-of-proc?\r\n\r\n## Changelog\r\n\r\n### 2.4.0\r\n\r\n- Support inspecting the instructions of properties.\r\n\r\n### 2.3.0\r\n\r\n- Support Visual Basic projects.\r\n\r\n### 2.2.0\r\n\r\n- The code lense tooltip now also shows the method's byte size.\r\n\r\n### 2.1.0\r\n\r\n- Adds new setting to the options page controling whether optimized (release) or unoptimized (debug) instructions are shown. \r\n\r\n### 2.0.0\r\n\r\n- Support Visual Studio 2022. Visual Studio 2019 is no longer supported.\r\n\r\n### 1.1.0\r\n\r\n- Adds support for local functions.\r\n\r\n### 1.0.3\r\n\r\n- Fixes `Mono.Cecil.AssemblyResolutionException`s during retrieval of compiler-generated code.\r\n\r\n### 1.0.2\r\n\r\n- Fixes `NullReferenceException`s during retrieval of compiler-generated code.\r\n\r\n### 1.0.1\r\n\r\n- Fixes a bug where the compiler-generated code for nested lambdas would not be shown.\r\n- Fixes a bug where compiler-generated code for unrelated lambdas would be shown.\r\n- Fixes a bug where the compiler-generated class for anonymous types would not be shown.\r\n\r\n### 1.0.0\r\n\r\n- Instructions of compiler-generated types/methods are now also shown below the instructions of the code-lensed method.\r\n\r\n### 0.5.3\r\n\r\n- Refactoring to greatly reduce the amount of data exchanged between the out-of-process CodeLens engine and Visual Studio.\r\n\r\n### 0.5.2\r\n\r\n- Fixes a bug where clicking on an instruction's opcode that has a trailing dot in its name would not open the correct documentation page.\r\n\r\n### 0.5.1\r\n\r\n- Fixes a bug where the documentation of instructions with opcodes that have a trailing dot in their name could not be retrieved.\r\n- Adds a new custom UI for the details view, replacing the default grid UI. This is only a minor visual change, but enables future features like including instructions from compiler-generated classes or showing the CodeLens on classes.\r\n\r\n### 0.5.0\r\n\r\n- Add settings page to de/activate auto-refresh on save.\r\n\r\n### 0.4.0\r\n\r\n- Instructions are now refreshed automatically when saving a file.\r\n- Don't duplicate compiler errors in the tooltip for failed CodeLenses.\r\n\r\n### 0.3.0\r\n\r\n- Show XML documentation of OpCode as tooltip when hovering an instruction.\r\n\r\n### 0.2.0\r\n\r\n- Double-clicking an instruction in the details view now opens its documentation in the browser.\r\n\r\n### 0.1.3\r\n\r\n- Fixes an issue where the \"Refresh\" button might not work when multiple instances of VS where open.\r\n\r\n### 0.1.2\r\n\r\n- Only fixes development problems with the pipe connections between VS and the CodeLenses by using a different pipe for the VS experimental instance.\r\n\r\n### 0.1.1\r\n\r\n- Fixes a bug where the \"Refresh\" button was not working properly when too many CodeLenses where loaded at once.\r\n- Fixes a regression bug where instruction retrieval failures would not be shown in the CodeLens tooltip.\r\n\r\n### 0.1.0\r\n\r\n- Adds a \"Refresh\" button to the details view which retrieves the instructions of the method again.\r\n\r\n### 0.0.5\r\n\r\n- Fixes an issue where IL retrieval failed for projects with multiple target frameworks.\r\n\r\n### 0.0.4\r\n\r\n- Overload resolution has been extended to handle `dynamic` parameters as well. There no longer should be any issues saying that a method couldn't be found or that a method couldn't be uniquely identified.\r\n\r\n### 0.0.3\r\n\r\n- Overload resolution has been extended to handle more types: arrays, pointers, and `ref`s.\r\n\r\n### 0.0.2\r\n\r\n- Overload resolution has been reworked completely and now works better with generic and/or nested types. Some issues might still remain and will be addressed in the next release.\r\n\r\n### 0.0.1\r\n\r\nIntitial preview release.\r\n\r\n- Enables CodeLens on C# methods showing the number of IL instructions.\r\n- Clicking the CodeLens opens a details view listing all IL instructions of the method.\r\n- Refreshing the CodeLens after code changes currently requires closing and re-opening the C# source file.\r\n\r\n## Versioning scheme\r\n\r\nMicroscope's versioning scheme uses a manually maintained [semantic version](https://semver.org/) with an appended build number. A semver bump is triggered by creating a Git tag. The build version is auto-incremented by [AppVeyor](https://ci.appveyor.com/project/bert2/microscope/branch/main).\r\n\r\n## Credits\r\n\r\n### Similar tools\r\n\r\n- [VSCodeILViewer](https://github.com/JosephWoodward/VSCodeILViewer) by Joseph Woodward only works with VSCode and isn't updated anymore. Joseph wrote a nice [article](https://josephwoodward.co.uk/2017/01/c-sharp-il-viewer-vs-code-using-roslyn) on its implementation which helped me getting started.\r\n- [Msiler](https://marketplace.visualstudio.com/items?itemName=segrived.msiler2017) by Evgeniy Babaev looks like an excellent tool, but unfortunately it's not available for Visual Studio 2019. I discovered it when I was way into the development of microscope and if I had found it earlier, I might have tried patching Msiler first.\r\n\r\n### Dependencies\r\n\r\n- [Roslyn](https://github.com/dotnet/roslyn) compiles the current project in memory.\r\n- [Mono.Cecil](https://github.com/jbevain/cecil) retrieves the IL instructions from the compiled project.\r\n- [nuke](https://github.com/nuke-build/nuke) orchestrates the builds for microscope.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbert2%2Fmicroscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbert2%2Fmicroscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbert2%2Fmicroscope/lists"}