Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/CsProj/ProjectFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ public virtual void Load(string xmlDocument, ProjectFileProperty property)
case ProjectFileProperty.Title:
var defaultPropertyElement = LoadProperty(ProjectFileProperty.PackageId);
PackageName = propertyElement?.Value ?? defaultPropertyElement?.Value ?? string.Empty;

if (string.IsNullOrEmpty(PackageName))
{
throw new ArgumentException(
"The provided csproj file seems malformed - no <Title> or <PackageId> in the <PropertyGroup>",
paramName: nameof(xmlDocument)
);
}


break;
}
}
Expand Down
8 changes: 2 additions & 6 deletions test/CsProj/ProjectFileParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ public void Works_when_no_packageId_or_title()
"<RootNamespace>Unit.For.The.Win</RootNamespace>" +
"</PropertyGroup>" +
"</Project>";

var ex = Assert.Throws<ArgumentException>(() =>
parser.Load(csProjXml)
);

Assert.Contains($"The provided csproj file seems malformed - no <Title> or <PackageId> in the <PropertyGroup>", ex.Message);
Assert.Equal("xmlDocument", ex.ParamName);
parser.Load(csProjXml);
Assert.Empty(parser.PackageName);
}
}
}