-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
CompilationUnit.directives.uri.stringValue behaves inconsistently across platforms. On Windows, path separators in part and part of directives are stripped, whereas on Linux, they are preserved.
Current Behavior
For the following directives in Dart code:
part '../filename.dart';
part 'sub_dir/filename.dart';
part of '../filename.dart';
part of 'sub_dir/filename.dart';-
Linux Output:
../filename.dartandsub_dir/filename.dart -
Windows Output:
..filename.dartandsub_dirfilename.dart
Expected Behavior
For the above directives:
-
Linux Output (unchanged):
../filename.dartandsub_dir/filename.dart -
Windows Output:
..\filename.dartandsub_dir\filename.dart
sdk version: '>=3.3.0 <4.0.0'
analyzer: '^6.0.0'
Related Work:
I encountered this while I was working on a PR at serverpod where I tested generated code using CompilationUnit and comparing CompilationUnit.directives.uri.stringValue to the expected path.
This test worked fine on Linux but failed on Windows due to the inconsistency.
Log of the directives of the CompilationUnit in windows:

Log of directive.uri.stringValue on windows:

Log of directive.uri.stringValue on Linux:

If I can help with any further information, you can holla at me any time 💪