Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
PackageReference: parse version from xml attr
Browse files Browse the repository at this point in the history
  • Loading branch information
cnr committed Jun 4, 2021
1 parent 8a5224d commit 70c58cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/Strategy/NuGet/PackageReference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ instance FromXML PackageReference where
instance FromXML ItemGroup where
parseElement el = ItemGroup <$> children "PackageReference" el

-- | A "PackageReference" xml tag
--
-- See: https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#packagereference
-- See: https://cloud.google.com/functions/docs/writing/specifying-dependencies-dotnet
instance FromXML Package where
parseElement el =
Package <$> attr "Include" el
<*> optional (child "Version" el)
<*> optional (attr "Version" el)

buildGraph :: PackageReference -> Graphing Dependency
buildGraph project = Graphing.fromList (map toDependency direct)
Expand Down
12 changes: 3 additions & 9 deletions test/NuGet/testdata/test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="one">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="two">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="one" Version="1.0.0" />
<PackageReference Include="two" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="three">
<Version>3.0.0</Version>
</PackageReference>
<PackageReference Include="three" Version="3.0.0" />
<PackageReference Include="four">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 70c58cd

Please sign in to comment.