Documentation
¶
Index ¶
- Variables
- func GetInclude(pr PackageReference) string
- func GetVersions(pr PackageReference, buildProperties ParsedMSBuildProperties) []string
- func IsDevDependency(pr PackageReference) bool
- func ParseNuGetCsproj(pathToCsproj string) ([]lockfile.PackageDetails, error)
- func ParseNuGetCsprojWithContext(pathToCsproj string, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
- func ParseNuGetLock(pathToLockfile string) ([]lockfile.PackageDetails, error)
- type Import
- type ItemGroup
- type NuGetCsprojExtractor
- func (e NuGetCsprojExtractor) Extract(f lockfile.DepFile, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
- func (e NuGetCsprojExtractor) IsOfficiallySupported() bool
- func (e NuGetCsprojExtractor) PackageManager() models.PackageManager
- func (e NuGetCsprojExtractor) ShouldExtract(path string) bool
- type NuGetLockExtractor
- func (e NuGetLockExtractor) Extract(f lockfile.DepFile, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
- func (e NuGetLockExtractor) IsOfficiallySupported() bool
- func (e NuGetLockExtractor) PackageManager() models.PackageManager
- func (e NuGetLockExtractor) ShouldExtract(path string) bool
- type NuGetLockPackage
- type NuGetLockfile
- type NugetCsProj
- type NugetCsprojMatcher
- type PackageReference
- type PackageVersion
- type PackageVersionInfo
- type ParsedCsProj
- type ParsedMSBuildProperties
- type Property
- type PropertyGroup
- type PropsFile
Constants ¶
This section is empty.
Variables ¶
var NuGetExtractor = NuGetLockExtractor{ lockfile.WithMatcher{Matchers: []lockfile.Matcher{&NugetCsprojMatcher{}}}, }
Functions ¶
func GetInclude ¶
func GetInclude(pr PackageReference) string
GetInclude returns the Include value from a PackageReference
func GetVersions ¶ added in v1.4.0
func GetVersions(pr PackageReference, buildProperties ParsedMSBuildProperties) []string
GetVersions returns the Versions from a PackageReference with property substitution applied If no version is found in the PackageReference, it looks up the version from PackageVersions (central package management) A package can have multiple versions depending on the targetFramework used to build the application.
func IsDevDependency ¶
func IsDevDependency(pr PackageReference) bool
IsDevDependency checks if a PackageReference is a dev dependency (PrivateAssets="all")
func ParseNuGetCsproj ¶
func ParseNuGetCsproj(pathToCsproj string) ([]lockfile.PackageDetails, error)
func ParseNuGetCsprojWithContext ¶ added in v1.4.0
func ParseNuGetCsprojWithContext(pathToCsproj string, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
func ParseNuGetLock ¶
func ParseNuGetLock(pathToLockfile string) ([]lockfile.PackageDetails, error)
Types ¶
type ItemGroup ¶
type ItemGroup struct {
XMLName xml.Name `xml:"ItemGroup"`
PackageReferences []PackageReference `xml:"PackageReference"`
PackageVersions []PackageVersion `xml:"PackageVersion"`
ConditionAttr *string `xml:"Condition,attr"`
}
func (*ItemGroup) UnmarshalXML ¶
UnmarshalXML implements xml.Unmarshaler to capture line and column positions for each PackageReference. This custom unmarshaler is necessary because the standard xml.Unmarshal doesn't provide file position information. By manually iterating through XML tokens and calling decoder.InputPos(), we can record where each PackageReference appears in the file.
type NuGetCsprojExtractor ¶
type NuGetCsprojExtractor struct{}
func (NuGetCsprojExtractor) Extract ¶
func (e NuGetCsprojExtractor) Extract(f lockfile.DepFile, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
func (NuGetCsprojExtractor) IsOfficiallySupported ¶
func (e NuGetCsprojExtractor) IsOfficiallySupported() bool
func (NuGetCsprojExtractor) PackageManager ¶
func (e NuGetCsprojExtractor) PackageManager() models.PackageManager
func (NuGetCsprojExtractor) ShouldExtract ¶
func (e NuGetCsprojExtractor) ShouldExtract(path string) bool
type NuGetLockExtractor ¶
type NuGetLockExtractor struct {
lockfile.WithMatcher
}
func (NuGetLockExtractor) Extract ¶
func (e NuGetLockExtractor) Extract(f lockfile.DepFile, context lockfile.ScanContext) ([]lockfile.PackageDetails, error)
func (NuGetLockExtractor) IsOfficiallySupported ¶
func (e NuGetLockExtractor) IsOfficiallySupported() bool
func (NuGetLockExtractor) PackageManager ¶
func (e NuGetLockExtractor) PackageManager() models.PackageManager
func (NuGetLockExtractor) ShouldExtract ¶
func (e NuGetLockExtractor) ShouldExtract(path string) bool
type NuGetLockPackage ¶
type NuGetLockfile ¶
type NuGetLockfile struct {
Version int `json:"version"`
Dependencies map[string]map[string]NuGetLockPackage `json:"dependencies"`
}
NuGetLockfile contains the required dependency information as defined in https://github.com/NuGet/NuGet.Client/blob/6.5.0.136/src/NuGet.Core/NuGet.ProjectModel/ProjectLockFile/PackagesLockFileFormat.cs
type NugetCsProj ¶
type NugetCsProj struct {
XMLName xml.Name `xml:"Project"`
ItemGroups []ItemGroup `xml:"ItemGroup"`
PropertyGroups []PropertyGroup `xml:"PropertyGroup"`
Imports []Import `xml:"Import"`
}
type NugetCsprojMatcher ¶
type NugetCsprojMatcher struct{}
func (NugetCsprojMatcher) GetSourceFile ¶
func (NugetCsprojMatcher) Match ¶
func (m NugetCsprojMatcher) Match(sourceFile lockfile.DepFile, packages []lockfile.PackageDetails, context lockfile.ScanContext) error
type PackageReference ¶
type PackageReference struct {
XMLName xml.Name `xml:"PackageReference"`
IncludeAttr *string `xml:"Include,attr"`
Include *string `xml:"Include"`
VersionAttr *string `xml:"Version,attr"`
Version *string `xml:"Version"`
VersionOverrideAttr *string `xml:"VersionOverride,attr"`
VersionOverride *string `xml:"VersionOverride"`
PrivateAssetsAttr *string `xml:"PrivateAssets,attr"`
PrivateAssets *string `xml:"PrivateAssets"`
models.FilePosition
}
type PackageVersion ¶ added in v1.4.0
type PackageVersionInfo ¶ added in v1.4.0
type PackageVersionInfo struct {
Name string
Version string
Condition string // Optional condition (e.g., "'$(TargetFramework)' == 'net6.0'")
}
PackageVersionInfo is a simplified representation of a package version for central package management
type ParsedCsProj ¶
type ParsedCsProj struct {
PackagesByConditionAndName map[string]map[string]PackageReference // map[condition]map[packageName]PackageReference
MSBuildProperties ParsedMSBuildProperties
}
func ParseNugetCsProj ¶
func ParseNugetCsProj(content []byte, csprojPath string, rootDir string) (*ParsedCsProj, error)
ParseNugetCsProj parses a .csproj file and returns a map of package references by package name. This is shared logic used by both the extractor and matcher. rootDir is optional - if provided, limits parent directory traversal to this directory
type ParsedMSBuildProperties ¶ added in v1.4.0
type ParsedMSBuildProperties struct {
PropertiesByName map[string]string
VersionsByPackageName map[string][]PackageVersionInfo
ManagePackageVersionsCentrally bool
}