Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Suchiman
Copy link
Contributor

  • Avoid writing to the obj directory unnecessarily to avoid tripping up the up-to-date check
  • Also fixes a subtle bug around file writing: File.OpenWrite will open an existing file and not truncate it, so if we ever write fewer bytes to that file than it currently contains, those additional bytes will remain at the end, corrupting the file. Using File.Create or File.WriteAllBytes ensures the contents of the files are fully replaced.

I hope this passes the "not too clever" bar and also improves reliability and performance.

Fixes #32801

- Avoid writing to the obj directory unnecessarily to avoid tripping up the up-to-date check
- Also fixes a subtle bug around file writing: File.OpenWrite will open an existing file and not truncate it, so if we ever write fewer bytes to that file than it currently contains, those additional bytes will be preserved, corrupting the file
Copy link
Contributor

@ajcvickers ajcvickers left a comment

Choose a reason for hiding this comment

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

Looks good to me; just add a bit of exception handling as noted in the comment.

@ajcvickers ajcvickers merged commit 7cae3c3 into dotnet:main Jan 28, 2024
@ajcvickers
Copy link
Contributor

Thanks for the contribution!

@Suchiman Suchiman deleted the fixIncremental branch January 28, 2024 17:40
@AlmightyLks
Copy link

AlmightyLks commented Jan 29, 2024

Nudges towards the double negation in the FileMatch check

With this !File.Read().SequenceEquals() became !!File.Read().SequenceEquals()

@ajcvickers , fyi

@ajcvickers
Copy link
Contributor

@AlmightyLks Good catch!

@Suchiman Suchiman mentioned this pull request Jan 29, 2024
This was referenced Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EFC Tooling always forces a rebuild
3 participants