Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #329 from cartermp/fix-build-warnings
Browse files Browse the repository at this point in the history
Fix build warnings
  • Loading branch information
cartermp authored Nov 17, 2020
2 parents 8c6108c + 42801cd commit 128f9fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/MSBuild.Abstractions/BaselineProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace MSBuild.Abstractions
public struct BaselineProject
{
public readonly ImmutableArray<string> GlobalProperties;
public readonly ImmutableDictionary<string, string> TargetProjectProperties;
public readonly UnconfiguredProject Project;
public readonly ProjectStyle ProjectStyle;
public readonly ProjectOutputType OutputType;
Expand Down
20 changes: 7 additions & 13 deletions src/MSBuild.Conversion.Package/PackagesConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,26 @@ static PackagesConfigPackage ParsePackageConfig(XElement element) =>
new PackagesConfigPackage
{
// Required
ID = element.Attribute(PackageFacts.PackagesConfigIDName).Value,
ID = element.Attribute(PackageFacts.PackagesConfigIDName)?.Value,

// Required
Version = element.Attribute(PackageFacts.PackagesConfigVersionName).Value,
Version = element.Attribute(PackageFacts.PackagesConfigVersionName)?.Value,

// The rest are optional
TargetFramework = element.Attribute(PackageFacts.PackagesConfigTargetFrameworkName) is null
? string.Empty
: element.Attribute(PackageFacts.PackagesConfigTargetFrameworkName).Value,
TargetFramework = element.Attribute(PackageFacts.PackagesConfigTargetFrameworkName)?.Value,

AllowedVersions = element.Attribute(PackageFacts.PackagesConfigAllowedVersionsFrameworkname) is null
? string.Empty
: element.Attribute(PackageFacts.PackagesConfigAllowedVersionsFrameworkname).Value,
AllowedVersions = element.Attribute(PackageFacts.PackagesConfigAllowedVersionsFrameworkname)?.Value,

DevelopmentDependency = element.Attribute(PackageFacts.PackagesConfigDevelopmentDependencyName) is null
? false :
bool.Parse(element.Attribute(PackageFacts.PackagesConfigDevelopmentDependencyName).Value),
DevelopmentDependency = bool.TryParse(element.Attribute(PackageFacts.PackagesConfigDevelopmentDependencyName)?.Value, out var _),
};

static string VersionWithoutSuffix(string nugetVersion) => nugetVersion.Split('-').First();

static bool ValidPackageNode(XElement pkgNode) =>
pkgNode.Attribute(PackageFacts.PackagesConfigIDName) is { }
&& !string.IsNullOrWhiteSpace(pkgNode.Attribute(PackageFacts.PackagesConfigIDName).Value)
&& !string.IsNullOrWhiteSpace(pkgNode.Attribute(PackageFacts.PackagesConfigIDName)?.Value)
&& pkgNode.Attribute(PackageFacts.PackagesConfigVersionName) is { }
&& Version.TryParse(VersionWithoutSuffix(pkgNode.Attribute(PackageFacts.PackagesConfigVersionName).Value), out var version);
&& Version.TryParse(VersionWithoutSuffix(pkgNode.Attribute(PackageFacts.PackagesConfigVersionName)?.Value ?? string.Empty), out var _);
}
}
}

0 comments on commit 128f9fe

Please sign in to comment.