{"id":31667842,"url":"https://github.com/willibrandon/serilog-syntax-vscode","last_synced_at":"2026-05-02T17:34:39.371Z","repository":{"id":315117965,"uuid":"1058184404","full_name":"willibrandon/serilog-syntax-vscode","owner":"willibrandon","description":"Visual Studio Code extension for Serilog syntax highlighting, brace matching, navigation, and property-argument connections","archived":false,"fork":false,"pushed_at":"2025-10-06T15:20:09.000Z","size":235,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T17:31:08.942Z","etag":null,"topics":["csharp","dotnet","message-templates","serilog","structured-logging","syntax-highlighting","vscode-extension","vsix"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/willibrandon.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-16T18:30:02.000Z","updated_at":"2025-10-06T15:17:27.000Z","dependencies_parsed_at":"2025-09-16T21:42:38.056Z","dependency_job_id":null,"html_url":"https://github.com/willibrandon/serilog-syntax-vscode","commit_stats":null,"previous_names":["willibrandon/serilog-syntax-vscode"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/willibrandon/serilog-syntax-vscode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fserilog-syntax-vscode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fserilog-syntax-vscode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fserilog-syntax-vscode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fserilog-syntax-vscode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willibrandon","download_url":"https://codeload.github.com/willibrandon/serilog-syntax-vscode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2Fserilog-syntax-vscode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32543961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T12:25:33.646Z","status":"ssl_error","status_checked_at":"2026-05-02T12:24:51.733Z","response_time":132,"last_error":"SSL_read: 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":["csharp","dotnet","message-templates","serilog","structured-logging","syntax-highlighting","vscode-extension","vsix"],"created_at":"2025-10-08T00:48:22.514Z","updated_at":"2026-05-02T17:34:39.364Z","avatar_url":"https://github.com/willibrandon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serilog Syntax Highlighting for VS Code\n\nA Visual Studio Code extension that provides syntax highlighting and enhanced support for Serilog message templates and Serilog.Expressions in C#/.NET projects.\n\n## Features\n\n### 🎨 Syntax Highlighting\n\n#### Message Templates\n- **Property names** highlighted in theme-appropriate blue: `{UserId}`, `{UserName}`\n- **Destructuring operator** `@` highlighted in warm orange/red: `{@User}`\n- **Stringification operator** `$` highlighted in warm orange/red: `{$Settings}`\n- **Format specifiers** highlighted in green: `{Timestamp:yyyy-MM-dd}`\n- **Alignment** highlighted in red: `{Name,10}`, `{Price,-8}`\n- **Positional parameters** highlighted in purple: `{0}`, `{1}`\n- **Property braces** highlighted for structure\n- **Multi-line verbatim strings** fully supported with proper highlighting across lines\n- **C# 11 raw string literals** supported with `\"\"\"` delimiters for complex templates\n- **Automatic theme adaptation** - All colors automatically adjust for Light/Dark themes\n\n#### Serilog.Expressions\n- **Filter expressions** in `Filter.ByExcluding()` and `Filter.ByIncludingOnly()`\n- **Expression templates** with control flow directives\n- **Operators** highlighted in red: `and`, `or`, `not`, `like`, `in`, `is null`\n- **Functions** highlighted in purple: `StartsWith()`, `Contains()`, `Length()`, etc.\n- **Keywords** highlighted in blue: conditional and control flow keywords\n- **Literals** highlighted in cyan/teal: strings, numbers, booleans, null\n- **Directives** highlighted in magenta: `{#if}`, `{#each}`, `{#else}`, `{#end}`\n- **Built-in properties** highlighted in teal: `@t`, `@m`, `@l`, `@x`, `@i`, `@p`\n- **Theme-aware colors** - All expression elements adapt to Light/Dark themes\n\n### 🔗 Smart Detection\n- Works with any logger variable name (not just `_logger` or `log`)\n- Supports both direct Serilog calls: `Log.Information(...)`\n- Supports Microsoft.Extensions.Logging integration: `_logger.LogInformation(...)`\n- Supports `BeginScope` for scoped logging: `logger.BeginScope(\"Operation={Id}\", operationId)`\n- Supports `LogError` with exception parameter: `logger.LogError(ex, \"Error: {Message}\", msg)`\n- Recognizes configuration templates: `outputTemplate: \"[{Timestamp:HH:mm:ss}...]\"`\n\n### ⚡ Real-time Highlighting\n- Immediate visual feedback as you type\n- Highlighting appears as soon as you close braces `}` (doesn't wait for closing quotes)\n- Supports incomplete strings during editing\n\n### 🧭 Navigation Features\n- **Light bulb suggestions** when hovering over template properties\n- **Navigate to argument** - jump from template properties to their corresponding arguments\n- Click the light bulb and select \"Navigate to 'PropertyName' argument\"\n\n### 🔍 Brace Matching\n- **Highlight matching braces** when cursor is positioned on `{` or `}`\n- Works in all Serilog contexts: message templates, output templates, and Serilog.Expressions\n- **Multi-line support** - matches braces across line boundaries in verbatim and raw strings\n- Uses colored, bold braces for visibility without interfering with other highlighting\n- **Press ESC** to temporarily dismiss brace matching highlights\n\n### 🎯 Property-Argument Highlighting\n- **Synchronous highlighting** of template properties and their corresponding arguments\n- Position cursor on a property like `{UserId}` to highlight both the property (including braces) and its argument\n- Position cursor on an argument to highlight it and its template property\n- Includes quotes when highlighting string arguments (e.g., `\"userId\"`)\n- Helps visualize the connection between template properties and their values\n- Uses background fill to distinguish from brace matching\n- **Press ESC** to temporarily dismiss property-argument highlights\n\n## Installation\n\n### From VS Code Marketplace (Recommended)\n1. Install directly from the [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=mtlog.serilog-syntax-vscode)\n2. Or from within VS Code:\n   - Press `Ctrl+Shift+X` (or `Cmd+Shift+X` on Mac) to open Extensions view\n   - Search for \"Serilog Syntax Highlighting\"\n   - Click **Install**\n\n### From VSIX File\n1. Download the latest `.vsix` file from the [releases page](../../releases)\n2. In VS Code, press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac) to open Command Palette\n3. Type \"Extensions: Install from VSIX...\" and select it\n4. Choose the downloaded `.vsix` file\n\n## Customization\n\n### Basic Settings\n- `serilog.enabled` - Enable/disable Serilog syntax highlighting\n- `serilog.propertyArgumentHighlighting` - Enable/disable property-argument pair highlighting when cursor is positioned on either\n\n### Theme-Aware Colors \u0026 Accessibility\nThe extension automatically adapts to your VS Code theme with **WCAG AA compliant colors**:\n\n- **Automatic theme detection** - Colors change instantly when switching between Light and Dark themes\n- **WCAG AA accessibility** - All colors maintain 4.5:1+ contrast ratios for excellent readability\n- **Semantic color grouping** - Related elements use harmonious color families:\n  - Properties: Blue family (`{UserId}`, `{Name}`)\n  - Operators: Warm colors (`@`, `$`)\n  - Format specifiers: Green family (`:yyyy-MM-dd`)\n  - Expression functions: Purple family (`StartsWith()`, `Length()`)\n\n### Color Customization\nYou can customize colors to match your preferences:\n\n1. Open VS Code Settings (`Ctrl+,` or `Cmd+,`)\n2. Search for \"serilog\" to see all available options\n3. Modify any of these color settings:\n   - `serilog.colors.property` - Color for property names (e.g., `{Property}`)\n   - `serilog.colors.destructure` - Color for destructure operator (`@`)\n   - `serilog.colors.stringify` - Color for stringify operator (`$`)\n   - `serilog.colors.brace` - Color for braces around properties\n   - `serilog.colors.format` - Color for format specifiers (e.g., `:yyyy-MM-dd`)\n   - `serilog.colors.alignment` - Color for alignment specifiers (e.g., `,10`)\n   - `serilog.colors.positional` - Color for positional parameters (e.g., `{0}`, `{1}`)\n\n### Expression Colors\n- `serilog.colors.expression.operator` - Color for expression operators (`and`, `or`, `not`, etc.)\n- `serilog.colors.expression.function` - Color for expression functions (`Contains`, `StartsWith`, etc.)\n- `serilog.colors.expression.builtin` - Color for built-in properties (`@t`, `@l`, `@m`, etc.)\n- `serilog.colors.expression.directive` - Color for directives (`#if`, `#else`, `#each`, etc.)\n- `serilog.colors.expression.string` - Color for string literals in expressions\n- `serilog.colors.expression.number` - Color for number literals in expressions\n- `serilog.colors.expression.keyword` - Color for keywords (`null`, `true`, `false`, etc.)\n- `serilog.colors.expression.identifier` - Color for identifiers/property names in expressions\n\n**Note**: Custom colors override the automatic theme-aware colors.\n\n## Getting Started\n\nAfter installation, the extension works automatically - no configuration required!\n\n1. **Open any C# file** that uses Serilog logging\n2. **Start typing** a Serilog log statement:\n   ```csharp\n   _logger.LogInformation(\"User {UserId} logged in\", userId);\n   ```\n3. **See instant highlighting** as you type - properties turn blue, operators orange, etc.\n\n### Quick Test\nCreate a new C# file and paste this to see all features:\n```csharp\nusing Serilog;\n\nLog.Information(\"User {UserId} logged in with {@Details} at {Timestamp:HH:mm:ss}\",\n    userId, userDetails, DateTime.Now);\n```\n\nYou should see:\n- `UserId` in blue (adapts to your theme)\n- `@` in warm orange/red, `Details` in blue\n- `Timestamp` in blue, `:HH:mm:ss` in green\n- Colors automatically match your Light/Dark theme preference\n\n## Supported Serilog Syntax\n\nThe extension recognizes and highlights all Serilog message template features:\n\n```csharp\n// Basic properties\nlogger.LogInformation(\"User {UserId} logged in at {LoginTime}\", userId, loginTime);\n\n// Destructuring (captures object structure)\nlogger.LogInformation(\"Processing user {@User}\", user);\n\n// Stringification (forces string representation)\nlogger.LogInformation(\"Configuration loaded {$Settings}\", settings);\n\n// Format specifiers\nlogger.LogInformation(\"Current time: {Timestamp:yyyy-MM-dd HH:mm:ss}\", DateTime.Now);\n\n// Alignment\nlogger.LogInformation(\"Item: {Name,10} | Price: {Price,8:C}\", name, price);\n\n// Positional parameters (legacy support)\nlogger.LogWarning(\"Error {0} occurred in {1}\", errorCode, methodName);\n\n// Multi-line verbatim strings\nlogger.LogInformation(@\"Processing report:\n    User: {UserName}\n    Department: {Department}\n    Generated: {Timestamp:yyyy-MM-dd}\", userName, dept, DateTime.Now);\n\n// C# 11 raw string literals (no escaping needed for quotes)\nlogger.LogInformation(\"\"\"\n    Processing record:\n    ID: {RecordId}\n    Status: {Status}\n    User: {@User}\n    \"\"\", recordId, status, user);\n\n// Configuration templates\nLog.Logger = new LoggerConfiguration()\n    .WriteTo.Console(outputTemplate: \"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}\")\n    .CreateLogger();\n\n// Serilog.Expressions filter syntax\nLog.Logger = new LoggerConfiguration()\n    .Filter.ByExcluding(\"RequestPath like '/health%'\")\n    .Filter.ByIncludingOnly(\"Level = 'Error' or StatusCode \u003e= 500\")\n    .CreateLogger();\n\n// Expression templates with control flow\nvar expressionTemplate = new ExpressionTemplate(\n    \"{#if Level = 'Error'}❌{#else}✅{#end} {@m}\");\n\n// Computed properties with expressions\n.Enrich.WithComputed(\"ResponseTime\", \"EndsWith(RequestPath, '.json') ? Elapsed * 2 : Elapsed\")\n```\n\n## Supported Logger Names\n\nThe extension automatically detects Serilog calls regardless of how you name your logger variables:\n\n```csharp\n// All of these work automatically\n_logger.LogInformation(\"Message with {Property}\", value);\nlogger.LogDebug(\"Debug message with {Data}\", data);\nmyCustomLogger.LogWarning(\"Warning with {Details}\", details);\nlog.LogError(\"Error with {Context}\", context);\n```\n\n## Commands\n\nAccess these commands via the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`):\n\n- **Serilog: Test Extension** - Verify the extension is working\n- **Serilog: Refresh Highlighting** - Refresh syntax highlighting in the current file\n\n## Development\n\n### Prerequisites\n- VS Code\n- Node.js 18+\n- npm\n\n### Building\n```bash\n# Install dependencies\nnpm install\n\n# Compile TypeScript\nnpm run compile\n\n# Run tests\nnpm test\n\n# Run benchmarks\nnpm run benchmark\n\n# Watch mode for development\nnpm run watch\n\n# Package extension\nnpm run package\n```\n\n### Architecture\n\nThe extension uses VS Code's extensibility APIs:\n\n- **TextEditorDecorationType API** - For syntax highlighting via decorations\n- **Configuration API** - For user customization settings\n- **Theme API** - For automatic theme adaptation\n\nKey components:\n- `templateParser.ts` - Parses Serilog message templates\n- `expressionParser.ts` \u0026 `expressionTokenizer.ts` - Handles Serilog.Expressions syntax\n- `stringLiteralParser.ts` - Detects C# string literals (regular, verbatim, raw)\n- `serilogDetector.ts` - Identifies Serilog method calls in C# code\n- `cacheManager.ts` - LRU cache for parsed templates providing performance optimization\n- `themeManager.ts` - Theme-aware color management\n- `decorationManager.ts` - Manages text decorations for highlighting\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new features\n5. Run the test suite: `npm test`\n6. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillibrandon%2Fserilog-syntax-vscode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillibrandon%2Fserilog-syntax-vscode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillibrandon%2Fserilog-syntax-vscode/lists"}