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

Fix incremental builds #32860

Merged
merged 2 commits into from
Jan 28, 2024
Merged

Fix incremental builds #32860

merged 2 commits into from
Jan 28, 2024

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
Member

@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
7 checks passed
@ajcvickers
Copy link
Member

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
Member

@AlmightyLks Good catch!

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