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

"run task" and "debug task" shortcuts only appear when task name is a string literal #830

Open
huw-dhcw opened this issue Jun 30, 2023 · 4 comments

Comments

@huw-dhcw
Copy link

The following will be decorated with the "run task" and "debug task" shortcuts

Task("GenerateReport")
    .Does<BuildParameters>(TestTasks.GenerateReport);

However this will not:

Task(nameof(TestTasks.GenerateReport))
    .Does<BuildParameters>(TestTasks.GenerateReport);
@devlead
Copy link
Member

devlead commented Jun 30, 2023

This is a because the extension doesn't compile and execute C#, it uses an Regex to identity tasks
https://github.com/cake-build/cake-vscode/blob/develop/package.json#L109

@huw-dhcw
Copy link
Author

Tricky, could obviously extend the regex for my specific use case:

Task\s*?\(\s*?\"(.*?)\"|nameof\s*?\(\s*?(.*?)\s*?\)\s*?\)

but there would also be consts etc

@nils-a
Copy link
Member

nils-a commented Jul 3, 2023

@huw-dhcw Currently the name of the task is always in the first match group of the regex. With the introduction of the | it could be either the first or the second. Also, your regex probably matches a bit too much, I guess. (It would result in a task name of TestTasks.GenerateReport)

If all your tasks are set up using nameof, you could try to change the setting of cake.taskRunner.taskRegularExpression in your project to something like Task\s*?\(\s*?nameof\s*?\(\s*?(?:\w+\.)+(\w*?)\s*?\)\s*?\)

@huw-dhcw
Copy link
Author

huw-dhcw commented Jul 7, 2023

It was just a "nice to have". I'll just go back to using literals. Happy for you to close as "Wont fix"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants