Repository navigation
Bug and test fixes #1322
Bug and test fixes #1322
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,7 +348,7 @@ private void AnalyzeEntry(IDependencyChainNode<PythonAnalyzerEntry> node, Python | |
|
|
||
| private void LogCompleted(IDependencyChainNode<PythonAnalyzerEntry> node, IPythonModule module, Stopwatch stopWatch, TimeSpan startTime) { | ||
| if (_log != null) { | ||
| var completed = node != null && module.Analysis is LibraryAnalysis ? "completed" : "completed for library"; | ||
| var completed = node != null && module.Analysis is LibraryAnalysis ? "completed for library" : "completed "; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct logging |
||
| var message = node != null | ||
| ? $"Analysis of {module.Name}({module.ModuleType}) on depth {node.VertexDepth} {completed} in {(stopWatch.Elapsed - startTime).TotalMilliseconds} ms." | ||
| : $"Out of order analysis of {module.Name}({module.ModuleType}) completed in {(stopWatch.Elapsed - startTime).TotalMilliseconds} ms."; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,9 +146,6 @@ public static string QuoteArgument(this string arg) { | |
| return "\"{0}\"".FormatInvariant(arg); | ||
| } | ||
|
|
||
| public static bool PathStartsWith(this string s, string prefix) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have it instead calling
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a bit of a mess in our extensions. From my understanding, |
||
| => s?.StartsWith(prefix, PathsStringComparison) ?? false; | ||
|
|
||
| public static bool StartsWithOrdinal(this string s, string prefix, bool ignoreCase = false) | ||
| => s?.StartsWith(prefix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) ?? false; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,14 @@ public static bool IsValidFileNameCharacter(char character) | |
| /// Returns true if the path has a directory separator character at the end. | ||
| /// </summary> | ||
| public static bool HasEndSeparator(string path) | ||
| => !string.IsNullOrEmpty(path) && DirectorySeparators.Contains(path[path.Length - 1]); | ||
| => !string.IsNullOrEmpty(path) && IsDirectorySeparator(path[path.Length - 1]); | ||
|
|
||
|
|
||
| public static bool IsDirectorySeparator(char c) => Array.IndexOf(DirectorySeparators, c) != -1; | ||
|
|
||
| public static bool PathStartsWith(string s, string prefix) | ||
| => s != null && s.StartsWith(prefix, StringExtensions.PathsStringComparison) && | ||
| (s.Length == prefix.Length || IsDirectorySeparator(s[prefix.Length])); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fix for #1321, to ensure that part of folder name isn't considered as part of the path. |
||
|
|
||
| /// <summary> | ||
| /// Removes up to one directory separator character from the end of path. | ||
|
|
@@ -400,7 +407,7 @@ public static bool IsNormalizedPath(string path) { | |
| var altSeparator = Path.AltDirectorySeparatorChar; | ||
| int offset; | ||
| if (path.Length >= 1 && path[0] == separator) { | ||
| offset = 1; | ||
| offset = IsUncStart(path) ? 2 : 1; | ||
| } else if (IsWindows && path.Length >= 2 && IsValidWindowsDriveChar(path[0]) && path[1] == ':') { | ||
| offset = 2; | ||
| } else { | ||
|
|
@@ -436,6 +443,11 @@ public static bool IsNormalizedPath(string path) { | |
| return !(impossibleName || last == '.' || char.IsWhiteSpace(last)); | ||
| } | ||
|
|
||
| private static bool IsUncStart(string path) { | ||
| var separator = Path.DirectorySeparatorChar; | ||
| return IsWindows && path.Length >= 2 && path[0] == separator && path[1] == separator; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Normalizes and returns the provided path. | ||
| /// </summary> | ||
|
|
@@ -451,7 +463,7 @@ public static string NormalizePath(string path) { | |
| return path; | ||
| } | ||
|
|
||
| var root = EnsureEndSeparator(Path.GetPathRoot(path)); | ||
| var root = IsUncStart(path) ? new string(Path.DirectorySeparatorChar, 2) : EnsureEndSeparator(Path.GetPathRoot(path)); | ||
| var parts = path.Substring(root.Length).Split(DirectorySeparators); | ||
| var isDir = string.IsNullOrWhiteSpace(parts[parts.Length - 1]); | ||
|
|
||
|
|
||
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.
This is part of the fix for #1320. Name of the module may not match the name of the variable in Python 2x