Skip to content

Remove internal keyword from TaskEnvironment setter in IMultiThreadableTask - #12848

Merged
JanProvaznik merged 2 commits into
mainfrom
copilot/remove-internal-from-taskenvironment
Dec 2, 2025
Merged

JanProvaznik merged 2 commits into
mainfrom
copilot/remove-internal-from-taskenvironment

Conversation

Copilot AI commented Dec 1, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #

Context

The internal set accessor on IMultiThreadableTask.TaskEnvironment makes the interface unimplementable by external assemblies (SDK tasks, custom tasks) that don't have InternalsVisibleTo access.

Changes Made

  • Remove internal keyword from the TaskEnvironment setter in IMultiThreadableTask.cs
// Before
TaskEnvironment TaskEnvironment { get; internal set; }

// After  
TaskEnvironment TaskEnvironment { get; set; }

The documented contract ("should never be set by a Task itself") remains as the enforcement mechanism, which is the standard pattern for interfaces meant to be implemented externally.

Testing

  • All TaskRouter integration tests pass
  • All Framework unit tests pass
  • Sample project builds successfully

Notes

None.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: /home/REDACTED/work/msbuild/msbuild/artifacts/bin/bootstrap/core/dotnet dotnet test src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj --filter FullyQualifiedName~TaskRouter --no-build -v m (dns block)
    • Triggering command: /home/REDACTED/work/msbuild/msbuild/artifacts/bin/bootstrap/core/dotnet dotnet test src/Framework.UnitTests/Microsoft.Build.Framework.UnitTests.csproj --no-build -v m (dns block)
    • Triggering command: /home/REDACTED/work/msbuild/msbuild/artifacts/bin/bootstrap/core/dotnet dotnet build src/Samples/Dependency/Dependency.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

On IMultiThreadableTask.cs:35-35, remove the internal keyword from taskenvironment in the Pull request explaining that it's necessary so the interface is implementable by assemblies that do not have internalsvisibleto such as SDK tasks or customer custom tasks.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo.

…leTask

The internal keyword on the TaskEnvironment setter prevented external
assemblies from implementing the IMultiThreadableTask interface since
they don't have InternalsVisibleTo access. This change makes the
interface implementable by SDK tasks and custom tasks in external
assemblies.

Co-authored-by: JanProvaznik <[email protected]>
Copilot AI changed the title [WIP] Remove internal keyword from taskenvironment for compatibility Remove internal keyword from TaskEnvironment setter in IMultiThreadableTask Dec 1, 2025
Copilot AI requested a review from JanProvaznik December 1, 2025 09:40
@JanProvaznik
JanProvaznik marked this pull request as ready for review December 1, 2025 09:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes a critical API design issue in the IMultiThreadableTask interface by removing the internal keyword from the TaskEnvironment property setter. The interface was previously unimplementable by external assemblies (SDK tasks, custom tasks) without InternalsVisibleTo access, which defeated the purpose of having a public interface.

Key Changes:

  • Changed TaskEnvironment property setter from internal set to public set in IMultiThreadableTask interface
  • Aligns with the established MSBuild pattern used in ITask interface where engine-set properties have public setters
  • Documentation already clearly states the property "should never be set by a Task itself", relying on documentation as the enforcement mechanism

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

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.

5 participants