From 7d32e79137f1edd65a119f3c5e7f1e658b4afbde Mon Sep 17 00:00:00 2001 From: "Denis Kuzmin (github/3F)" Date: Mon, 31 Jan 2022 17:48:03 +0300 Subject: [PATCH] Fixed ProjectItem 'The path is not of a legal form.' --- MvsSln/Core/ProjectItem.cs | 4 +--- MvsSlnTest/Core/ProjectItemTest.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MvsSln/Core/ProjectItem.cs b/MvsSln/Core/ProjectItem.cs index 4add98c..bf777ed 100644 --- a/MvsSln/Core/ProjectItem.cs +++ b/MvsSln/Core/ProjectItem.cs @@ -229,9 +229,7 @@ private void SetProjectType(string pType) private void SetFullPath(string slnDir) { - if(path == null) { - return; - } + if(string.IsNullOrWhiteSpace(path)) return; if(Path.IsPathRooted(path)) { fullPath = path; diff --git a/MvsSlnTest/Core/ProjectItemTest.cs b/MvsSlnTest/Core/ProjectItemTest.cs index 3b46471..a8080b6 100644 --- a/MvsSlnTest/Core/ProjectItemTest.cs +++ b/MvsSlnTest/Core/ProjectItemTest.cs @@ -209,6 +209,18 @@ public void CtorTest3() ); } + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData(null)] + public void CtorTest4(string name) + { + ProjectItem p = new(name, ProjectType.Cs); + + Assert.Null(p.fullPath); + Assert.Equal(p.path, p.name); + } + [Fact] public void EqTest1() {