Write a declaration file

Code Scry cannot read, such as a precompiled DLL, adds nothing to what Scry knows: a method calling it asks before it runs, and the values passed to it get no minimum, maximum or dropdown. A declaration file states facts about such code. Each entry, a key line naming a method and the facts below it, is a declaration.

To create one, go to Assets > Create > Scry > Declaration File, then edit it in your code editor. Select it to see its problems in the Inspector. A package can ship one; without Scry, it does nothing.

A declaration file's Inspector, listing a key that matches nothing.

A key line names what the facts apply to, and the indented lines below it are its facts. # starts a comment. Parameters are C# type names; in facts, $0 or $name refers to a parameter.

method MyGame.MathUtil.Saturate(float)
    returns range [0, 1]
    effect pure
method MyPlugin.Audio.Play(string, float)
    param $0 choices MyGame.Editor.SoundChoices
    param $1 requires [0, 1]

Keys

KeyApplies to
method Type.Name(params)One overload, or every overload without the parameters.
get Type.Name, set Type.NameA property's getter or setter.
type TypeEvery member of the type without a declaration of its own.
attribute TypeFields marked with the attribute.
override Type.NameEvery override of a method.

Facts

FactDescription
effect pureThe method changes nothing, so it runs freely.
effect undoableThe method changes only the object it is called on, so it runs as one undo step.
effect irreversible "message"The method does something Scry cannot undo, so it asks before it runs, naming the effect with the message.
effect calledbynameSomething calls the method by name, as Unity calls Update, so Scry does not show it.
notliveScry does not read the method again at every refresh, because each call logs or returns something new.
messagesThe call can run OnEnable and OnDisable.
lifecycle assigned-before-awakeFields marked with this attribute are set before Awake, as an injection framework sets them, so Scry never flags them as missing.
returns range [lo, hi], returns magnitude [lo, hi]The result, or its length, is within the range.
returns clamp $p [lo, hi], returns wrap $p [lo, hi)The result is the parameter, clamped or wrapped.
returns min $a $b, max $a $b, oneof $a $b, copy $pThe result is one of the parameters.
returns excludes valueThe result is never the value.
returns unit name, param $p unit nameThe unit of the result or of the parameter, in plural words: seconds, meters, meters per second, meters per second squared. Units the code combines compose from it.
param $p rejects value, requires [lo, hi], nonemptyValues the call rejects: Scry warns on them.
param $p clamped [lo, hi], wrapped periodValues the call clamps or wraps around: Scry shows the limits at the ends of the field instead of warning.
param $p failsA rejected value makes the call throw or log an error, so Scry shows an error instead of a warning.
param $p choices providerThe parameter takes one of the values a choice provider lists, shown as a dropdown.

Choice providers

A choice provider lists the values a string parameter accepts, so the field shows a dropdown of them instead of a text field. The built-in providers are tags, layers, sorting-layers, scenes, animator-parameters, shader-properties, input-axes and methods. For your own, implement IScryChoiceProvider in an editor assembly, and name its full type in the fact:

public class SoundChoices : IScryChoiceProvider
{
    public IEnumerable<string> GetChoices(ScryChoiceContext context)
    {
        return SoundLibrary.Names;
    }
}

A package compiles its providers only when Scry is installed, through its assembly definition's Version Defines.

Additional resources