Skip to content

Commit ea5195f

Browse files
stereotype441whesse
authored andcommitted
Fix newline normalization in _PhysicalFile.readAsStringSync().
Most clients of _PhysicalFile read the file by translating it into a Source object using createSource() and then reading it using FileBasedSource.contentsFromFile, which normalizes newlines using FileBasedSource.fileReadMode. However, a few clients read the file directly using _PhysicalFile.readAsStringSync(), which wasn't doing the normalization. This CL adds the normalization to that code path. One such client was the code generation logic for summaries; this caused code generation to produce different results on Windows, which led to a test failure. Fixes #25470. [email protected] Review URL: https://codereview.chromium.org/1584313010 .
1 parent 2d6532c commit ea5195f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/analyzer/lib/file_system/physical_file_system.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class _PhysicalFile extends _PhysicalResource implements File {
114114
String readAsStringSync() {
115115
try {
116116
io.File file = _entry as io.File;
117-
return file.readAsStringSync();
117+
return FileBasedSource.fileReadMode(file.readAsStringSync());
118118
} on io.FileSystemException catch (exception) {
119119
throw new FileSystemException(exception.path, exception.message);
120120
}

0 commit comments

Comments
 (0)