Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension broke 10.3 to 10.5 => Objects passed as command arguments are now stripped of functions #1698

Closed
hoovercj opened this issue Dec 29, 2015 · 2 comments
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@hoovercj
Copy link
Member

I have an extension that works in version 0.10.3 but does not work in 0.10.5+.

The cause of this breakage is that functions on objects passed in the arguments array of a Command were available when executing the actions in 0.10.3 but are not available in 10.5+

This is illustrated in the following example:

class Repro implements vscode.CodeActionProvider {
    public commandId = 'hoovercj.reproCommand';
    private command;

    constructor() {
        this.command = vscode.commands.registerCommand(this.commandId, this.runCodeAction, this);
    }

    public provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): vscode.Command[] {
        return [<vscode.Command>{
            title: "Broken Command",
            command: this.commandId,
            arguments: [document, { 
                broken: () => { return 5; },
                works: 5
            }]
        }];
    }

    public runCodeAction(document: vscode.TextDocument, test:any) {
        try {
            test.works;
            test.broken();
            document.getText();
        } catch (error) {
                        // This should show up in 10.5+ but should not show up in 10.3
            vscode.window.showErrorMessage(error);
        }
    }
@egamma egamma added bug Issue identified by VS Code Team member as probable bug api labels Dec 29, 2015
@egamma egamma added this to the Backlog milestone Dec 29, 2015
@jrieken jrieken modified the milestones: Jan 2016, Backlog Jan 4, 2016
@jrieken
Copy link
Member

jrieken commented Jan 4, 2016

The issue is that we trigger the action on the main side but cannot serialise over such arguments. Before we would keep them cached on the extension side and create a dummy action for it. Tho, that is likely to result in memory leakage. Needs thinking...

jrieken added a commit that referenced this issue Jan 4, 2016
jrieken added a commit that referenced this issue Jan 4, 2016
@jrieken jrieken closed this as completed in 2e50c91 Jan 5, 2016
@jrieken jrieken assigned joaomoreno and unassigned jrieken Jan 28, 2016
@bpasero bpasero assigned dbaeumer and unassigned joaomoreno Jan 29, 2016
@dbaeumer dbaeumer added the verified Verification succeeded label Jan 29, 2016
@dbaeumer
Copy link
Member

Verified in code. Joe and I discussed the solution when he implemented it.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants