Skip to content

Commit

Permalink
Check whether root path has path root
Browse files Browse the repository at this point in the history
  • Loading branch information
mruxmohan4 committed Mar 7, 2024
1 parent eb10dd6 commit b2f341d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ public void EmitWarningForProjectsOnMultipleDrives()
}

[Fact]
public void DoNotEmitWarningForEmptyRootPathDrive()
public void DoNotEmitWarningForRootPathWithoutPathRoot()
{
TestLogger logger = new ();
SlnFile slnFile = new ();
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.VisualStudio.SlnGen/SlnFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,15 @@ internal void Save(string rootPath, TextWriter writer, bool useFolders, ISlnGenL
if (hierarchy != null)
{
bool logDriveWarning = false;
string rootPathDrive = Path.GetPathRoot(rootPath);
string rootPathDrive = Path.IsPathRooted(rootPath) ? Path.GetPathRoot(rootPath) : string.Empty;
foreach (SlnFolder folder in hierarchy.Folders)
{
bool useSeparateDrive = false;
bool hasFullPath = !string.IsNullOrEmpty(folder.FullPath);
if (hasFullPath)
{
string folderPathDrive = Path.GetPathRoot(folder.FullPath);
// Only emit warning for a root path that is actually rooted and contains root directory information
if (!string.IsNullOrEmpty(rootPathDrive) && !string.Equals(rootPathDrive, folderPathDrive, StringComparison.OrdinalIgnoreCase))
{
useSeparateDrive = true;
Expand Down

0 comments on commit b2f341d

Please sign in to comment.