dotnet

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 Import

type Import struct {
	XMLName   xml.Name `xml:"Import"`
	Project   string   `xml:"Project,attr"`
	Condition string   `xml:"Condition,attr"`
}

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

func (itemGroup *ItemGroup) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

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 (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 (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 NuGetLockPackage struct {
	Resolved string `json:"resolved"`
	Type     string `json:"type"`
}

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 (m NugetCsprojMatcher) GetSourceFile(sourceFile lockfile.DepFile) (lockfile.DepFile, error)

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 PackageVersion struct {
	XMLName       xml.Name `xml:"PackageVersion"`
	IncludeAttr   *string  `xml:"Include,attr"`
	Include       *string  `xml:"Include"`
	VersionAttr   *string  `xml:"Version,attr"`
	Version       *string  `xml:"Version"`
	ConditionAttr *string  `xml:"Condition,attr"`
	models.FilePosition
}

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
}

type Property

type Property struct {
	XMLName xml.Name
	Value   string `xml:",chardata"`
}

type PropertyGroup

type PropertyGroup struct {
	XMLName    xml.Name
	Properties []Property `xml:",any"`
}

type PropsFile

type PropsFile struct {
	XMLName        xml.Name        `xml:"Project"`
	ItemGroups     []ItemGroup     `xml:"ItemGroup"`
	PropertyGroups []PropertyGroup `xml:"PropertyGroup"`
	Imports        []Import        `xml:"Import"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL