-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Thread-Safe Tasks spec #12111
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
Thread-Safe Tasks spec #12111
Conversation
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Outdated
Show resolved
Hide resolved
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Outdated
Show resolved
Hide resolved
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Outdated
Show resolved
Hide resolved
21b22a3
to
0914b4e
Compare
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Show resolved
Hide resolved
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Outdated
Show resolved
Hide resolved
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Show resolved
Hide resolved
documentation/specs/MultithreadedMSBuild/thread-safe-tasks-api-reference.md
Show resolved
Hide resolved
We found probably some better way to deal with file system rather than re-implement it. Re-wrote our concept. |
61b490d
to
cab9556
Compare
…ath without providing absolute path for task authors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive specification for thread-safe tasks in MSBuild's multithreading execution model. The purpose is to enable tasks to run concurrently within a single MSBuild process while maintaining safety and correctness.
- Defines thread-safe task capabilities through interfaces and attributes
- Introduces TaskEnvironment API for safe access to process-level state
- Provides detailed API analysis for identifying threading issues in existing code
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
thread-safe-tasks.md | Main specification document defining thread-safe task interfaces, TaskEnvironment API, and implementation approaches |
thread-safe-tasks-api-analysis.md | Comprehensive reference of .NET APIs that are problematic for thread-safe tasks with recommendations |
multithreaded-msbuild.md | Minor correction updating TaskExecutionContext reference to TaskEnvironment |
internal AbsolutePath(string path, bool ignoreRootedCheck) { } | ||
public AbsolutePath(string path); // Checks Path.IsPathRooted | ||
public AbsolutePath(string path, AbsolutePath basePath) { } | ||
public static implicit operator string(AbsolutePath path) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like an explicit conversion operator from string
-> AbsolutePath
would be a good shorthand as well for large codebases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might consider adding it later if the need for this shortcut would appear.This conversion would need to check that the string is indeed already an absolute path, otherwise we do not have enough data to make a conversion. I am afraid it might be still confusing that the conversion may fail if the path is not rooted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it should also be able to resolve shorthanded paths like ./somefile.txt
to it's absolute path as well (by replacing the .
in the string with the current directory in the ctor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversion operator would not have enough context to access correct current directory - so the only way to do that now would be using the TaskEnvironement
object created specifically so it has this context and allows the absolute path resolution. Besides, parsing dots in paths feels kind of too hacky to me.
However, MSBuild tasks often work not with stings but with MSBuild items, which should have enough data in many cases, and we might consider having conversion operators for them in version 2.
documentation/specs/multithreading/thread-safe-tasks-api-analysis.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving so we can get this merged - we can always revise it as we go through implementation.
Merged the PR as we are feeling pretty good about the decisions made for this spec. |
Related to #11828.
This spec defines the API contract for the new kind of Task that would be safe to use in multithreaded mode of execution.