Class: Dependabot::Nuget::ProjectDiscovery

Inherits:
DependencyFileDiscovery show all
Extended by:
T::Sig
Defined in:
lib/dependabot/nuget/discovery/project_discovery.rb

Instance Attribute Summary collapse

Attributes inherited from DependencyFileDiscovery

#dependencies, #file_path

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path:, properties:, target_frameworks:, referenced_project_paths:, dependencies:) ⇒ ProjectDiscovery

Returns a new instance of ProjectDiscovery.



43
44
45
46
47
48
# File 'lib/dependabot/nuget/discovery/project_discovery.rb', line 43

def initialize(file_path:, properties:, target_frameworks:, referenced_project_paths:, dependencies:)
  super(file_path: file_path, dependencies: dependencies)
  @properties = properties
  @target_frameworks = target_frameworks
  @referenced_project_paths = referenced_project_paths
end

Instance Attribute Details

#propertiesObject (readonly)

Returns the value of attribute properties.



51
52
53
# File 'lib/dependabot/nuget/discovery/project_discovery.rb', line 51

def properties
  @properties
end

#referenced_project_pathsObject (readonly)

Returns the value of attribute referenced_project_paths.



57
58
59
# File 'lib/dependabot/nuget/discovery/project_discovery.rb', line 57

def referenced_project_paths
  @referenced_project_paths
end

#target_frameworksObject (readonly)

Returns the value of attribute target_frameworks.



54
55
56
# File 'lib/dependabot/nuget/discovery/project_discovery.rb', line 54

def target_frameworks
  @target_frameworks
end

Class Method Details

.from_json(json) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dependabot/nuget/discovery/project_discovery.rb', line 16

def self.from_json(json)
  return nil if json.nil?

  file_path = T.let(json.fetch("FilePath"), String)
  properties = T.let(json.fetch("Properties"), T::Array[T::Hash[String, T.untyped]]).map do |prop|
    PropertyDetails.from_json(prop)
  end
  target_frameworks = T.let(json.fetch("TargetFrameworks"), T::Array[String])
  referenced_project_paths = T.let(json.fetch("ReferencedProjectPaths"), T::Array[String])
  dependencies = T.let(json.fetch("Dependencies"), T::Array[T::Hash[String, T.untyped]]).map do |dep|
    DependencyDetails.from_json(dep)
  end

  ProjectDiscovery.new(file_path: file_path,
                       properties: properties,
                       target_frameworks: target_frameworks,
                       referenced_project_paths: referenced_project_paths,
                       dependencies: dependencies)
end

Instance Method Details

#dependency_setObject



60
61
62
63
64
65
66
67
68
# File 'lib/dependabot/nuget/discovery/project_discovery.rb', line 60

def dependency_set
  if target_frameworks.empty? && file_path.end_with?("proj")
    Dependabot.logger.warn("Excluding project file '#{file_path}' due to unresolvable target framework")
    dependency_set = Dependabot::FileParsers::Base::DependencySet.new
    return dependency_set
  end

  super
end