-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Add "identifier" to object in vscode.tasks api #57707
Comments
Using the identifier is not save either since a user can change it. This is why I didn't expose it in the first place. It is usually an identifier used for What exactly do you want to achieve |
Here's our most common scenario where we want this:
I work on several Azure extensions and most of them support some sort of "deploy". In some cases we have templates so we can automatically create the task and settings to run a preDeployTask, but in other cases we expect users to manually add this to their projects if desired. I'm not trying to find something that's "safe" because of course the user can do anything to their tasks.json and there isn't a completely "safe" option. I'm just trying to find the safest option and I think that's querying for a task based on identifier instead of label. We will display an error to the user if we can't find the task we're looking for and I think that's fine. After all, why does It honestly just feels like an established pattern that you should query based on id instead of label. I expect our users know that and are less likely to change their identifier. Plus it's not just that I think labels could change - I think labels should change. Labels are displayed in the UI and thus should be translated into a user's language. Identifiers are never displayed in the UI. |
But 99% of the tasks don't have an identifier and the task system doesn't advocate to define one. It is only there if there are two user defined tasks in the system that have the same label to make the unique for the In the C# case the task is I assume contributed by the C# extension using the provider API. In this case the task has an identifer (e.g. the TaskIdentifier) for which API exists. Why can't you use that one? And for the |
If publish tasks become important and providers of a task want to mark them independent of the name as a publish task we should add another |
"the task system doesn't advocate to define one" where is this documentation? And why is this the case? Our extension controls the entire flow from 'Create new Project', 'F5', to 'Deploy'. So no, this task is not contributed by the C# extension. We put down a new tasks.json file for our users when they create the project from our extension and we've been defining the identifier for them. publish was just one example. We also have a |
It is not a mandatory attribute so users only add it if necessary. But if you put down the tasks.json file why don't you contribute the tasks via the API then. Writing a tasks.json file is highly discouraged and was only something we ask extensions to do to work around the fact that there was no API to provide tasks. If there is a seconds extension that puts down a tasks.json file your tasks might simply be overridden. |
I still don't see the problem here. We will likely check the identifier first and the label second if the identifier is not defined. Isn't that how "dependsOn" does it? There are other cases like VS Code's TreeItem interface here which has an optional id attribute that is based on the label if the id isn't defined. We're not providing tasks to existing projects - we're creating an entirely new project (including a csproj file, cs files, gitignore, launch.json, tasks.json, and other files specific to Azure Functions). We never overwrite or edit an existing tasks.json file. If another extension overwrites the user's tasks.json, then that's a bug in their extension. That being said, I'm open to moving to "contribute the tasks via the API then", but that feels separate than the current discussion (we've had our tasks like this for over a year now with no real issues). More importantly, our users could create any task (i.e. an arbitrary powershell script) that they want to run before deploying. If they define an "identifier" (which shows up in IntelliSense when you're editing a tasks.json file, so I think it's pretty likely some of our users will) I still don't get why we shouldn't respect that? |
The problem is that you ask me to make something API that only exist due to legacy. Making it API results in the fact that we need to maintain the API and even maintain the feature. To clarify things:
Instead of exposing a legacy feature I think your extension should use the new supported feature and we should improve those instead. Any objection to close the issue. |
I created #57946 to make clear that |
The interface you linked to only has "type" and "additional attributes". What part of that is the identifier? Do we have to make our own id property in the "additional attributes" part? The "legacy feature" that we've been using is just custom tasks. "identifier" serves a definite and valuable purpose in custom tasks. Are you saying custom tasks are deprecated? |
No, the identifier in custom tasks is deprecated. I was introduce to allow users to make auto detected tasks referencable in So custom tasks are not deprecated. What is deprecated
Every extension can define its own TaskDefinition schema in the package.json using the |
Okay I think this can be closed if identifier is deprecated. Although I'm confused by the message you added:
Shouldn't you just say to use the task's label? "task identifier literal" confuses me and sounds too similar to the actual name of the property itself (identifier) Thanks for bearing with me and I look forward to trying out the recommended contribution points |
Thanks for pointing this out. Actually there are two different solutions. Either the name for custom tasks and the task definition for contributed tasks. I will adopt the message. |
Closing the issue. |
Ping me if something is unclear with the task provider. |
I'm calling the following api:
Here is how my task is defined:
But I can't seem to find the 'identifier' in the Task object returned by that api. I see the 'name' property, which seems to correspond to the 'label' - and I see a generated guid for definition.id
I don't want to query based on the label because that could change based on a user's language or whim. I would much prefer to query based on an id. Can we get "identifier" added to the Task object?
The text was updated successfully, but these errors were encountered: