Skip to content

Commit 53522c4

Browse files
#3401: fix missing file extension if name contains ':'
1 parent d31ed51 commit 53522c4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,13 +636,9 @@ public static string SanitizeFileName(string fileName)
636636
/// </summary>
637637
static string CleanUpName(string text, bool separateAtDots, bool treatAsFileName, bool treatAsPath)
638638
{
639-
// Remove anything that could be confused with a rooted path.
640-
int pos = text.IndexOf(':');
641-
if (pos > 0)
642-
text = text.Substring(0, pos);
643-
text = text.Trim();
644639
string extension = null;
645640
int currentSegmentLength = 0;
641+
// Extract extension from the end of the name, if valid
646642
if (treatAsFileName)
647643
{
648644
// Check if input is a file name, i.e., has a valid extension
@@ -668,6 +664,11 @@ static string CleanUpName(string text, bool separateAtDots, bool treatAsFileName
668664
}
669665
}
670666
}
667+
// Remove anything that could be confused with a rooted path.
668+
int pos = text.IndexOf(':');
669+
if (pos > 0)
670+
text = text.Substring(0, pos);
671+
text = text.Trim();
671672
// Remove generics
672673
pos = text.IndexOf('`');
673674
if (pos > 0)

0 commit comments

Comments
 (0)