Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

> **Note**: odd version numbers, for example, `0.13.0`, are not included in this changelog. They are used to test the new features and fixes before the final release.

## [0.25.2] - Unreleased
## [0.25.3] - Unreleased

### Added:

- MCP Server: Dev Proxy
- Diagnostics: Show error if pluginPath in plugin instance is not correctly set to DevProxy.Plugins.dll when using Dev Proxy v0.29.0 or later
- Code action: Update single or all plugin paths to DevProxy.Plugins.dll

### Changed:

- Snippets: Updated all snippets to use `v0.29.0` schema
- Snippets: Updated all snuppers to use new DLL name, `DevProxy.Plugins.dll`
- Snippets: Updated all snippets to use new DLL name, `DevProxy.Plugins.dll`
- Notification: Upgrade notification invokes package manager to upgrade Dev Proxy
- Improved diagnostics range detection to ensure that they only appear againt the relevant code and don't overlap with ending quotes and commas

## [0.24.0] - 2025-06-04

Expand All @@ -29,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Snippets: Added `devproxy-plugin-openai-telemetry-config` - OpenAITelemetryPlugin config section
- Snippets: Added `devproxy-plugin-prices-file` - OpenAITelemetryPlugin telemetry prices file
- Snippets: Added `devproxy-plugin-price` - OpenAITelemetryPlugin telemetry model price
- Code

### Changed:

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The following sections describe the features that the extension contributes to V
### Code Actions

- Update schema to match installed version of Dev Proxy
- Update single or all plugin paths to DevProxy.Plugins.dll

### Code Lenses

Expand Down Expand Up @@ -44,6 +45,7 @@ The following sections describe the features that the extension contributes to V
- Check for configSections that are not used in plugins
- Check for reporter plugin when a summary plugin is used
- Check that ApiCenterOnboardingPlugin is placed after OpenApiSpecGeneratorPlugin
- Check that pluginPath in plugin instance is correctly set to DevProxy.Plugins.dll when using Dev Proxy v0.29.0 or later

### Editor Actions

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev-proxy-toolkit",
"displayName": "Dev Proxy Toolkit",
"description": "Makes it easy to create and update Dev Proxy configuration files.",
"version": "0.25.2",
"version": "0.25.3",
"publisher": "garrytrinder",
"engines": {
"vscode": "^1.101.0"
Expand Down Expand Up @@ -207,6 +207,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"json-to-ast": "^2.1.0"
"json-to-ast": "^2.1.0",
"semver": "^7.7.2"
}
}
129 changes: 101 additions & 28 deletions src/codeactions.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,104 @@
import * as vscode from 'vscode';
import { DevProxyInstall } from './types';
import {DevProxyInstall} from './types';

export const registerCodeActions = (context: vscode.ExtensionContext) => {
const devProxyInstall = context.globalState.get<DevProxyInstall>('devProxyInstall');
if (!devProxyInstall) {
return;
}
const devProxyVersion = devProxyInstall.isBeta ? devProxyInstall.version.split('-')[0] : devProxyInstall.version;
context.subscriptions.push(
vscode.languages.registerCodeActionsProvider('json', {
provideCodeActions: (document, range, context, token) => {
const diagnostic = context.diagnostics.find(diagnostic => {
return diagnostic.code === 'invalidSchema';
});
if (diagnostic) {
const fix = new vscode.CodeAction('Update schema', vscode.CodeActionKind.QuickFix);
fix.edit = new vscode.WorkspaceEdit();
fix.edit.replace(
document.uri,
new vscode.Range(
diagnostic.range.start,
diagnostic.range.end
),
`$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v${devProxyVersion}/rc.schema.json",`
);
return [fix];
}
}
}));
};
const devProxyInstall =
context.globalState.get<DevProxyInstall>('devProxyInstall');
if (!devProxyInstall) {
return;
}
const devProxyVersion = devProxyInstall.isBeta
? devProxyInstall.version.split('-')[0]
: devProxyInstall.version;

// Code action for invalid schema
context.subscriptions.push(
vscode.languages.registerCodeActionsProvider('json', {
provideCodeActions: (document, range, context, token) => {
const diagnostic = context.diagnostics.find(diagnostic => {
return diagnostic.code === 'invalidSchema';
});
if (diagnostic) {
const fix = new vscode.CodeAction(
'Update schema',
vscode.CodeActionKind.QuickFix,
);
fix.edit = new vscode.WorkspaceEdit();
fix.edit.replace(
document.uri,
new vscode.Range(diagnostic.range.start, diagnostic.range.end),
`https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v${devProxyVersion}/rc.schema.json`,
);
return [fix];
}
},
}),
);

// Code action for deprecated plugin paths (individual and bulk updates)
context.subscriptions.push(
vscode.languages.registerCodeActionsProvider('json', {
provideCodeActions: (document, range, context, token) => {
const correctPluginPath = '~appFolder/plugins/DevProxy.Plugins.dll';

// Check if the current range intersects with a deprecated plugin path diagnostic
const currentDiagnostic = context.diagnostics.find(diagnostic => {
return diagnostic.code === 'deprecatedPluginPath' &&
diagnostic.range.intersection(range);
});

// Only provide deprecated plugin path actions if user is on a deprecated plugin path diagnostic
if (!currentDiagnostic) {
return [];
}

const fixes: vscode.CodeAction[] = [];

// Individual fix for the current diagnostic
const individualFix = new vscode.CodeAction(
'Update plugin path',
vscode.CodeActionKind.QuickFix,
);
individualFix.edit = new vscode.WorkspaceEdit();
individualFix.edit.replace(
document.uri,
new vscode.Range(
currentDiagnostic.range.start,
currentDiagnostic.range.end,
),
correctPluginPath,
);
fixes.push(individualFix);

// Bulk fix for all deprecated plugin paths in the document (only show when on a deprecated plugin path)
const allDeprecatedPluginPathDiagnostics = vscode.languages
.getDiagnostics(document.uri)
.filter(diagnostic => {
return diagnostic.code === 'deprecatedPluginPath';
});

if (allDeprecatedPluginPathDiagnostics.length > 1) {
const bulkFix = new vscode.CodeAction(
`Update all plugin paths`,
vscode.CodeActionKind.QuickFix,
);
bulkFix.edit = new vscode.WorkspaceEdit();

// Update all deprecated plugin paths
allDeprecatedPluginPathDiagnostics.forEach(diagnostic => {
bulkFix.edit!.replace(
document.uri,
new vscode.Range(diagnostic.range.start, diagnostic.range.end),
correctPluginPath,
);
});

bulkFix.isPreferred = true;
fixes.push(bulkFix);
}

return fixes;
},
}),
);
};
Loading