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

Remove GetTempPath copy #74159

Merged
merged 1 commit into from
Jun 26, 2024
Merged

Remove GetTempPath copy #74159

merged 1 commit into from
Jun 26, 2024

Conversation

jaredpar
Copy link
Member

This function was addedin 2016 when the compiler was still coming to terms with its server process model. At that time we discovered that the return for Path.GetTempPath() was different for different invocation of our build task. This happened when more complex builds changed environment variables that influenced temp directories.

Part of our reaction was adding this function that gave us more control over how temporary paths could vary between builds. It let us have explicit control over the working directory.

In the years since this change was made we've gotten a lot more mature in our model here:

  1. Path.GetTemPath is banned in the compiler via analyzers
  2. The server process model is established and we are much more rigorous with how environment variables, temp paths, etc ... are handled.

As such this method serves very little purpose. It just makes our code different and harder to understand. As such we're removing it.

This function was addedin 2016 when the compiler was still coming to
terms with its server process model. At that time we discovered that the
return for `Path.GetTempPath()` was different for different invocation
of our build task. This happened when more complex builds changed
environment variables that influenced temp directories.

Part of our reaction was adding this function that gave us more control
over how temporary paths could vary between builds. It let us have
explicit control over the working directory.

In the years since this change was made we've gotten a lot more mature
in our model here:

1. `Path.GetTemPath` is banned in the compiler via analyzers
2. The server process model is established and we are much more
   rigorous with how environment variables, temp paths, etc ... are
   handled.

As such this method serves very little purpose. It just makes our code
different and harder to understand. As such we're removing it.
@jaredpar jaredpar requested a review from a team as a code owner June 25, 2024 23:56
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 25, 2024
@jaredpar
Copy link
Member Author

@roslyn-compiler PTAL

@jcouv jcouv self-assigned this Jun 26, 2024
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 1)

@jaredpar jaredpar enabled auto-merge June 26, 2024 00:08
@@ -520,8 +520,7 @@ internal int ExecuteTool(string pathToTool, string responseFileCommands, string
var requestId = getRequestId();
logger.Log($"Compilation request {requestId}, PathToTool={pathToTool}");

string workingDirectory = CurrentDirectoryToUse();
string? tempDirectory = BuildServerConnection.GetTempPath(workingDirectory);
string? tempDirectory = Path.GetTempPath();
Copy link
Contributor

Choose a reason for hiding this comment

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

So in the case where $env:TEMP is a relative path, is there a need to resolve it against the "CurrentDirectoryToUse()" now?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. It's the job of GetTempPath to ensure there is a valid path here.

@RikkiGibson
Copy link
Contributor

Test jobs appear to be timing out

@jaredpar jaredpar merged commit cba78fe into dotnet:main Jun 26, 2024
24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 26, 2024
@jaredpar jaredpar deleted the tempdir branch July 9, 2024 18:58
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 P1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants