From a054d7a61e0f9a61cf552789ed04f63303cb80b3 Mon Sep 17 00:00:00 2001 From: Nicklas Laine Overgaard Date: Thu, 30 Sep 2021 21:12:11 +0200 Subject: [PATCH] Remove requirement for having a package title This was (accidentally) introduced with PR #66. The code is now defaulting to an empty title rather than throwing an exception. --- src/CsProj/ProjectFileParser.cs | 10 +--------- test/CsProj/ProjectFileParserTest.cs | 8 ++------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/CsProj/ProjectFileParser.cs b/src/CsProj/ProjectFileParser.cs index f617458..4732832 100644 --- a/src/CsProj/ProjectFileParser.cs +++ b/src/CsProj/ProjectFileParser.cs @@ -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 or <PackageId> in the <PropertyGroup>", - paramName: nameof(xmlDocument) - ); - } - + break; } } diff --git a/test/CsProj/ProjectFileParserTest.cs b/test/CsProj/ProjectFileParserTest.cs index f08329d..6d3d91d 100644 --- a/test/CsProj/ProjectFileParserTest.cs +++ b/test/CsProj/ProjectFileParserTest.cs @@ -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); } } }