Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>MSpec DSL SupportNew to Visual Studio Code? Get it now.
MSpec DSL Support

MSpec DSL Support

Ben Hutcheson

|
5 installs
| (0) | Free
Domain-Specific Language support for PLC4X MSpec protocol definitions
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

MSpec DSL Support for VSCode

A comprehensive VSCode extension providing rich language support for PLC4X MSpec (Message Specification) protocol definitions.

Features

Core Language Support

  • ✅ Syntax Highlighting - Full syntax highlighting for all MSpec constructs
  • ✅ Auto-Completion - Context-aware completion for keywords, types, fields, and constants
  • ✅ Error Detection - Real-time syntax and semantic validation with detailed error messages
  • ✅ Hover Information - Detailed documentation and type information on hover
  • ✅ Go to Definition - Navigate to type and field definitions with Ctrl+Click
  • ✅ Document Formatting - Automatic code formatting with configurable indentation
  • ✅ Code Snippets - Pre-defined snippets for common MSpec patterns

Packet Decoder

  • ✅ Binary Packet Decoding - Decode binary packets using MSpec type definitions
  • ✅ Tree View Display - Hierarchical tree view of decoded packet structure
  • ✅ Field Overlay - Visual overlay of field values on the MSpec file
  • ✅ Byte Order Support - Automatic handling of BIG_ENDIAN and LITTLE_ENDIAN byte orders
  • ✅ Expression Evaluation - Automatic evaluation of const and implicit field expressions

Supported MSpec Constructs

  • Type definitions (type, discriminatedType, enum, dataIo)
  • Field types (simple, array, const, reserved, optional, implicit, etc.)
  • Data types (bit, byte, int, uint, float, string, etc.)
  • Expressions and operators with full expression evaluation
  • Type switching and discriminated unions
  • Attributes and parameters
  • Batch sets with custom byte orders

Installation

From VSCode Marketplace

  1. Open VSCode
  2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
  3. Search for "MSpec DSL Support"
  4. Click Install

From VSIX Package

  1. Download the latest .vsix file from releases
  2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
  3. Run Extensions: Install from VSIX...
  4. Select the downloaded .vsix file

Quick Start

Creating MSpec Files

  1. Create a new file with .mspec extension
  2. Start typing MSpec definitions
  3. Use Ctrl+Space for auto-completion suggestions
  4. Use snippets for quick scaffolding

Example MSpec File

[type SimpleMessage byteOrder='BIG_ENDIAN'
    [const uint 8 messageType 0x01]
    [simple uint 16 messageId]
    [implicit uint 16 payloadLength 'payload.lengthInBytes']
    [array byte payload count 'payloadLength']
]

[enum uint 8 MessageType
    ['0x01' REQUEST]
    ['0x02' RESPONSE]
]

[discriminatedType ProtocolMessage
    [discriminator uint 8 messageType]
    [typeSwitch messageType
        ['0x01' RequestMessage
            [simple string 32 command]
        ]
        ['0x02' ResponseMessage
            [simple uint 8 status]
        ]
    ]
]

Using the Packet Decoder

  1. Open an MSpec file
  2. Run MSpec: Open Packet Decoder from the Command Palette
  3. Select a binary file or paste hex data
  4. Choose the root type to decode
  5. View the decoded packet structure in the tree view

Configuration

Configure the extension through VSCode settings:

{
  "mspec.validation.enabled": true,
  "mspec.validation.strictMode": false,
  "mspec.completion.enabled": true,
  "mspec.completion.snippets": true,
  "mspec.formatting.enabled": true,
  "mspec.formatting.indentSize": 4,
  "mspec.trace.server": "off"
}

Configuration Options

  • validation.enabled - Enable/disable real-time validation
  • validation.strictMode - Enable strict validation mode for additional checks
  • completion.enabled - Enable/disable auto-completion
  • completion.snippets - Enable/disable code snippets
  • formatting.enabled - Enable/disable document formatting
  • formatting.indentSize - Number of spaces for indentation (default: 4)
  • trace.server - Trace communication with language server (off, messages, verbose)

Commands

Available Commands

  • MSpec: Restart Language Server - Restart the language server
  • MSpec: Show Output - Show language server output channel
  • MSpec: Go to Definition - Navigate to type/field definition
  • MSpec: Format Document - Format the current document
  • MSpec: Open Packet Decoder - Open the packet decoder panel

Keyboard Shortcuts

  • Ctrl+Space - Trigger auto-completion
  • Ctrl+Shift+F - Format document
  • Ctrl+Click - Go to definition
  • F12 - Go to definition (alternative)

Troubleshooting

Language Server Not Starting

  • Verify Node.js 18+ is installed
  • Check the MSpec output channel for error messages
  • Try restarting VSCode

No Syntax Highlighting

  • Ensure file has .mspec extension
  • Restart VSCode after installation

Auto-Completion Not Working

  • Check if completion is enabled in settings
  • Verify language server is running
  • Try restarting the language server with MSpec: Restart Language Server

Packet Decoder Issues

  • Ensure the MSpec file is valid and has no syntax errors
  • Verify the binary data format matches the selected type
  • Check byte order settings in the MSpec type definition

Support

For issues, feature requests, or questions:

  • GitHub Issues
  • GitHub Discussions

License

Licensed under the Apache License 2.0 - see LICENSE file for details.

Related Resources

  • Apache PLC4X - The main PLC4X project
  • MSpec Language Documentation
  • Language Server Protocol
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft