Skip to content

Conversation

@AR-May
Copy link
Member

@AR-May AR-May commented Oct 15, 2025

Fixes #11828

Context

Implement the new task environment APIs

Testing

Added unit tests

Copy link
Contributor

Copilot AI left a 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 implements task environment APIs to provide abstracted access to environment variables and working directory for MSBuild tasks. The implementation supports both single-threaded (stub) and multithreaded execution modes through a driver pattern.

Key changes:

  • Replaced NotImplementedException stubs with functional implementations using a driver pattern
  • Added driver interface and two concrete implementations for different execution modes
  • Implemented path validation and conversion utilities for the AbsolutePath type

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Framework/TaskEnvironment.cs Updated to use driver pattern instead of throwing NotImplementedException
src/Framework/ITaskEnvironmentDriver.cs Added interface defining environment operations contract
src/Framework/StubTaskEnvironmentDriver.cs Implemented driver that directly modifies system environment
src/Framework/MultithreadedTaskEnvironmentDriver.cs Implemented driver with isolated environment for concurrent execution
src/Framework/PathHelpers/AbsolutePath.cs Added path validation and conversion functionality
src/Framework.UnitTests/TaskEnvironment_Tests.cs Added comprehensive unit tests for task environment functionality
src/Framework.UnitTests/AbsolutePath_Tests.cs Added unit tests for AbsolutePath implementation

@AR-May AR-May marked this pull request as draft October 16, 2025 08:11
Copy link
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, needs another reviewer

@AR-May AR-May marked this pull request as ready for review November 24, 2025 14:26
@AR-May AR-May self-assigned this Nov 24, 2025
Copy link
Member

@YuliiaKovalova YuliiaKovalova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we operate on the different environment collections, but we apply the same manipulations.
Please make it universal and reusable to avoid duplications.

- Add EnvironmentVariableComparer to EnvironmentUtilities for platform-appropriate string comparison
- Add CopyCurrentEnvironmentVariables() to EnvironmentUtilities for simple env var copying
- Add SetEnvironment() to EnvironmentUtilities with delegate-based abstraction
- Update MultiProcessTaskEnvironmentDriver and MultithreadedTaskEnvironmentDriver to use shared utilities
- Update CommunicationsUtilities.SetEnvironment to delegate to EnvironmentUtilities (non-CLR2COMPATIBILITY)
- Keep optimized GetEnvironmentVariables with caching/FrozenDictionary in CommunicationsUtilities
- Add GetEnvironmentVariables() to EnvironmentUtilities with caching and FrozenDictionary
- Use P/Invoke on Windows for optimized environment variable reading
- Update MultiProcessTaskEnvironmentDriver to use the cached method
- Skip StringTools dependency (not available in Framework)
- Exclude net35 (CLR2COMPATIBILITY) which doesn't have FrozenDictionary
@JanProvaznik JanProvaznik self-assigned this Nov 27, 2025
@JanProvaznik JanProvaznik merged commit 6ae7bab into dotnet:main Nov 27, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

Design and add new Task API Contract

4 participants