-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Clarify File.WriteAllText and friends' truncation behaviour #9394
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsSummaryClarify in I determined their actual behaviour empirically on aarch64-darwin on SDK 7.0.400 with
|
Learn Build status updates of commit 27dc14f: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Stylistically, I'm torn between this being the right approach, or explaining it in terms of FileMode.Create (https://learn.microsoft.com/en-us/dotnet/api/system.io.filemode?view=net-7.0) dotnet-api-docs/xml/System.IO/FileMode.xml Line 178 in c1bd0b8
I also didn't look to see if all relevant places were updated. So, if this (vs explaining it in terms of FileMode.Create) is the preferred approach and it's complete, LGTM. |
Personally I get the impression that since this is a high-level API, it shouldn't be described in terms of lower-level primitives; but that's an empirical question about the consistent style of the .NET docs which I'm not particularly well-placed to answer. (If I were writing the docs myself from scratch, I'd certainly say "This function is a high-level wrapper around the following lower-level calls", but my general vague impression is that the .NET docs don't do this.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind looking for other places that are appropriate to update. From a quick search of "overwrit" I found
Create
, CreateText
, Replace
.
Ping @Smaug123 |
I have now checked every use of the string "verwrit", and adjusted the ones where it seemed appropriate. |
Learn Build status updates of commit 9672a7d: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Learn Build status updates of commit 94ad57e: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Summary
Clarify in
File.WriteAllText
and friends that the files are truncated before being overwritten. The docs as stated do not define the result of overwritinghello world
withbye
: is itbyelo world
orbye
?I determined their actual behaviour empirically on aarch64-darwin on SDK 7.0.400 with
File.WriteAllText : string * string -> unit
andFile.WriteAllBytes : string * byte[] -> unit
, but have not actually checked the other overloads and methods; I have assumed that they are consistent with each other.