dotnet

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 14 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 GetVersion

func GetVersion(pr PackageReference, properties map[string]string) string

GetVersion returns the Version value from a PackageReference with property substitution applied

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 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"`
}

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) 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"`
	PrivateAssetsAttr *string  `xml:"PrivateAssets,attr"`
	PrivateAssets     *string  `xml:"PrivateAssets"`
	models.FilePosition
}

type ParsedCsProj

type ParsedCsProj struct {
	PackagesByName   map[string]PackageReference
	PropertiesByName map[string]string
}

func ParseNugetCsProj

func ParseNugetCsProj(content []byte, csprojPath 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.

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