Skip to content

Commit dd8b199

Browse files
committed
DotNet/NuGet: Move class defintions out of the companion object
It does not really make sense to put class definitions into a static scope. Move them to the top level and make them private instead, and also add some documentation links. Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
1 parent 7ce7066 commit dd8b199

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

analyzer/src/main/kotlin/managers/DotNet.kt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ import com.here.ort.model.config.RepositoryConfiguration
3939

4040
import java.io.File
4141

42+
// See https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files.
43+
@JsonIgnoreProperties(ignoreUnknown = true)
44+
private data class ItemGroup(
45+
@JsonProperty(value = "PackageReference")
46+
@JacksonXmlElementWrapper(useWrapping = false)
47+
val packageReference: List<PackageReference>?
48+
)
49+
50+
@JsonIgnoreProperties(ignoreUnknown = true)
51+
private data class PackageReference(
52+
@JacksonXmlProperty(isAttribute = true, localName = "Include")
53+
val include: String?,
54+
@JacksonXmlProperty(isAttribute = true, localName = "Version")
55+
val version: String?
56+
)
57+
4258
/**
4359
* The [DotNet](https://docs.microsoft.com/en-us/dotnet/core/tools/) package manager for .NET.
4460
*/
@@ -64,21 +80,6 @@ class DotNet(
6480

6581
return map
6682
}
67-
68-
@JsonIgnoreProperties(ignoreUnknown = true)
69-
data class ItemGroup(
70-
@JsonProperty(value = "PackageReference")
71-
@JacksonXmlElementWrapper(useWrapping = false)
72-
val packageReference: List<PackageReference>?
73-
)
74-
75-
@JsonIgnoreProperties(ignoreUnknown = true)
76-
data class PackageReference(
77-
@JacksonXmlProperty(isAttribute = true, localName = "Include")
78-
val include: String?,
79-
@JacksonXmlProperty(isAttribute = true, localName = "Version")
80-
val version: String?
81-
)
8283
}
8384

8485
class Factory : AbstractPackageManagerFactory<DotNet>("DotNet") {

analyzer/src/main/kotlin/managers/NuGet.kt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ import com.here.ort.model.config.RepositoryConfiguration
3939

4040
import java.io.File
4141

42+
// See https://docs.microsoft.com/en-us/nuget/reference/packages-config.
43+
@JsonIgnoreProperties(ignoreUnknown = true)
44+
private data class PackagesConfig(
45+
@JsonProperty(value = "package")
46+
@JacksonXmlElementWrapper(useWrapping = false)
47+
val packages: List<Package>?
48+
)
49+
50+
@JsonIgnoreProperties(ignoreUnknown = true)
51+
private data class Package(
52+
@JacksonXmlProperty(isAttribute = true)
53+
val id: String,
54+
@JacksonXmlProperty(isAttribute = true)
55+
val version: String
56+
)
57+
4258
/**
4359
* The [NuGet](https://www.nuget.org/) package manager for .NET.
4460
*/
@@ -60,21 +76,6 @@ class NuGet(
6076

6177
return map
6278
}
63-
64-
@JsonIgnoreProperties(ignoreUnknown = true)
65-
data class PackagesConfig(
66-
@JsonProperty(value = "package")
67-
@JacksonXmlElementWrapper(useWrapping = false)
68-
val packages: List<Package>?
69-
)
70-
71-
@JsonIgnoreProperties(ignoreUnknown = true)
72-
data class Package(
73-
@JacksonXmlProperty(isAttribute = true)
74-
val id: String,
75-
@JacksonXmlProperty(isAttribute = true)
76-
val version: String
77-
)
7879
}
7980

8081
class Factory : AbstractPackageManagerFactory<NuGet>("NuGet") {

0 commit comments

Comments
 (0)