PluginRequirement

References
public sealed class PluginRequirement
A record of one plugin which a document relied on at the moment it was saved. Documents store these so a later session can find out what is missing — and offer to fetch it — before deserialisation starts discarding objects whose types it cannot resolve.

Constructors

PluginRequirement

#
public PluginRequirement(Guid id, string name, Version version, bool core, Guid[] objects)
Record a requirement.
id (Guid)Plugin id.
name (string)Plugin name as it read when the document was saved.
version (Version)Plugin version as it read when the document was saved.
core (bool)True if the plugin shipped with Grasshopper.
objects (Guid[])IoIds of the object types this plugin contributed to the document.

PluginRequirement

#
public PluginRequirement(IReader reader)
Deserialisation constructor.
reader (IReader)

Properties

Core

#
public bool Core { get; }
Gets whether the plugin shipped with Grasshopper rather than having been installed by the user. A missing core plugin means a broken installation, not something the package server can fix.

Id

#
public Guid Id { get; }
Gets the id of the required plugin. This is the id a loaded Plugin reports, so the two can be compared directly.

Installed

#
public Plugin Installed { get; }
Gets the loaded plugin with this id, or null when none is loaded. Note that this pays no attention to Version; a plugin is either present or it is not, and which build of it is present is a separate question — see IsOutdated.

InstalledVersion

#
public Version InstalledVersion { get; }
Gets the version of the loaded plugin, or null when none is loaded.

IsLoaded

#
public bool IsLoaded { get; }
Gets whether a plugin with this id is loaded right now, in any version.

IsOutdated

#
public bool IsOutdated { get; }
Gets whether the plugin is installed but cannot supply every object type this document asks of it.

This deliberately says nothing about which build is newer. What matters is that some types will not resolve, and there is no fixing that from here: Rhino cannot hold two builds of one assembly at once and the loaded one has already won, so any change of version needs the package manager and a restart.

Never true for a core plugin, by the reasoning in IsSatisfied.

IsSatisfied

#
public bool IsSatisfied { get; }
Gets whether everything this document needs from the plugin is present.

A loaded core plugin always counts as satisfied. Grasshopper's own libraries are not something the user installs, chooses a version of, or can be expected to do anything about, so a shortfall there is never worth putting in front of them — see IsOutdated.

Name

#
public string Name { get; }
Gets the plugin name as it read when the document was saved. This is a display name and no more; it is not a Yak package name, although the two are often similar enough that it makes a serviceable fallback.

ObjectCount

#
public int ObjectCount { get; }
Gets the number of objects in the document which came from this plugin.

Objects

#
public Guid[] Objects { get; }
Gets the IoIds of the object types this plugin contributed to the document. These are what deserialisation will fail to resolve while the plugin is absent.

Unresolved

#
public Guid[] Unresolved { get; }
Gets the object types this document needs from the plugin which nothing currently loaded can provide.

This is the honest test of whether a document can be read, and it is why the manifest records object ids rather than trusting a version number. An installed plugin older than the one a file was saved with will be missing the types added since; a version comparison would only guess at that, whereas asking which ids resolve answers it. It also catches the reverse, where a newer plugin has dropped a type an old file still uses.

The question is put to IO.ResolveType(Guid) rather than to ObjectProxies.IsKnownId(Guid), because that is the lookup deserialisation itself performs. The proxy table is a strict subset of it — a type whose proxy failed to register, for want of a usable constructor say, is still perfectly restorable — so asking the proxies would invent missing types which are not missing at all.

UnresolvedCount

#
public int UnresolvedCount { get; }
Gets the number of object types this document needs and cannot resolve.

Version

#
public Version Version { get; }
Gets the plugin version as it read when the document was saved.

Methods

Store

#
public void Store(IWriter writer)
Serialisation method.
writer (IWriter)

ToString

#
public override string ToString()
Describe this requirement for display in a list.
Object.ToString