StructScopeStructScope is a VS Code extension for inspecting the byte-level memory layout of C, C++, and Rust struct-like types. It parses source locally, computes field offsets, field sizes, padding bytes, total size, cache-line split risks, and field reorder suggestions, then renders the result as an interactive byte map with a field table and summary metrics. It is aimed at systems programmers who want quick feedback on data layout without compiling code, launching a debugger, or sending source to a service. RequirementsYou need Python 3.8 or newer, Install the Python dependencies before using the extension backend:
InstallationBuild or download the VSIX package, then install it manually in VS Code:
For local development, install npm dependencies and build the extension bundle:
The extension starts a local Python JSON-RPC process when VS Code activates it for C, C++, or Rust files. If Python is not available as UsageOpen a C, C++, header, or Rust source file and place the cursor near a struct, class, or Rust struct definition. Then run The panel shows a colored byte map for each field, striped padding bytes, a cache line ruler, a field table with offsets and sizes, summary metrics, and reorder suggestions when the current field order wastes space. Changing the platform or cache line dropdown reruns the analysis and updates the panel. Moving the cursor to a different struct while the panel is open refreshes the view after a short debounce. What It ChecksStructScope reports byte offsets, field sizes, inter-field padding, trailing padding, total struct size, overall alignment, padding waste ratio, cache-line splits, and greedy reorder suggestions. It also publishes VS Code diagnostics for padding after fields, cache-line split warnings, and high-padding structs. Supported Languages and PlatformsSupported languages are C structs, C++ structs and classes with data members, and Rust structs. Supported platforms are The current release focuses on common scalar, pointer, array, nested struct, and Rust primitive cases. Unknown types are preserved in the output and marked unresolved instead of being guessed. How It WorksThe extension is split into a TypeScript VS Code frontend and a Python analysis backend. The frontend spawns StructScope does not call cloud services, LLM APIs, compiler toolchains, or external analysis servers. Source text stays on the local machine. DevelopmentRun the Python tests:
Run the server integration test:
Run TypeScript checks and build:
Package the extension:
ContributingKeep changes local first and testable. Parser changes should include fixtures and pytest coverage. Layout changes should include explicit expected offsets, padding, and total sizes. Webview changes should preserve VS Code theme variables and avoid external scripts. LicenseMIT |