dotnet

package
v1.17.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 17 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

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) ([]extractor.PackageDetails, error)

func ParseNuGetCsprojWithContext

func ParseNuGetCsprojWithContext(pathToCsproj string, context extractor.ScanContext) ([]extractor.PackageDetails, error)

func ParseNuGetLock

func ParseNuGetLock(pathToLockfile string) ([]extractor.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"`
	ProjectReferences []ProjectReference `xml:"ProjectReference"`
	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) GetArtifact added in v1.17.3

GetArtifact reads a .csproj file and extracts internal <ProjectReference> entries as ProjectDeps. Each reference is resolved to an absolute filesystem path relative to the .csproj file's directory. Non-existent targets are silently skipped. Duplicates are deduplicated.

func (NuGetCsprojExtractor) IsManifestParser added in v1.17.3

func (e NuGetCsprojExtractor) IsManifestParser() bool

IsManifestParser returns false — this extractor parses build files for internal project references, not manifest files.

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 {
	extractor.WithMatcher
}

func (NuGetLockExtractor) Extract

func (NuGetLockExtractor) GetArtifact added in v1.17.3

GetArtifact finds the .csproj file adjacent to the packages.lock.json and extracts its internal <ProjectReference> entries as ProjectDeps. The returned artifact is keyed on the .csproj path (not the lock file path) so that GetBuildFileTrees groups it correctly under FileTypeCsproj. This mirrors the GradleLockExtractor pattern. If no .csproj is found, nil is returned.

func (NuGetLockExtractor) IsManifestParser added in v1.17.3

func (e NuGetLockExtractor) IsManifestParser() bool

IsManifestParser returns false for NuGetLockExtractor — it parses lock files for package deps, not manifest files.

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 extractor.DepFile) (extractor.DepFile, error)

func (NugetCsprojMatcher) Match

func (m NugetCsprojMatcher) Match(sourceFile extractor.DepFile, packages []extractor.PackageDetails, context extractor.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

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

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

type ParsedMSBuildProperties struct {
	PropertiesByName               map[string]string
	VersionsByPackageName          map[string][]PackageVersionInfo
	ManagePackageVersionsCentrally bool
}

type ProjectReference added in v1.17.3

type ProjectReference struct {
	XMLName     xml.Name `xml:"ProjectReference"`
	IncludeAttr *string  `xml:"Include,attr"`
}

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