AdvancedAssembly attributes that declare special cases, and Concord, which controls and inspects what Concordance does to an object.
Each attribute applies to the assembly declaring it and to the assemblies that reference that assembly. Its arguments must be constants, so a type is named with typeof and a member with nameof. For a type a build may not include, each attribute also takes the type by assembly-qualified name; the entry applies only where the type exists, and code analysis warns about a name the assembly can't see (CND0105). Concordance declares Unity's own special cases with the same attributes.
Special cases
Makes a getter and a setter method one member, which modifiers and observers reach like a property: go.SetActive((Modifier)false), go.activeSelf.Modify(false). The setter takes the value as its only parameter; the getter takes none and returns it, as a method or a property. A setter taking a key before the value, as Material.SetFloat(name, value), is not a member: wrap the call in a property of your own. Use it on an assembly, as many times as needed.
Constructors
| PropertyMethodsAttribute(Type declaringType, string getter, string setter) | Declares the pair: the type declaring both methods, the getter method or property name, and the setter method name, each name given with nameof. |
| PropertyMethodsAttribute(string declaringTypeName, string getter, string setter) | Declares the pair of a type the assembly doesn't reference: the type by assembly-qualified name, as "UnityEngine.Animator, UnityEngine.AnimationModule", then the getter and setter names. |
Properties
| Type DeclaringType { get; } | The type declaring both methods, or null when it's named by string. |
| string DeclaringTypeName { get; } | The assembly-qualified name of the type declaring both methods, or null when it's given as a type. |
| string Getter { get; } | The getter method or property name. |
| string Setter { get; } | The setter method name. |
Declares a driven member: a member written during known player-loop stages by code Concordance doesn't rewrite, such as animation. Right after each stage, the value written becomes the member's base value, and its modifiers apply on top. Applies only while the member has modifiers or observers. A stage the player loop doesn't have logs an error. Use it on an assembly, as many times as needed.
Constructors
| DrivenMemberAttribute(Type declaringType, string member, params Type[] stages) | Declares the driven member: the type declaring it, the field or property name given with nameof, and the player-loop stages that write it, such as typeof(UnityEngine.PlayerLoop.Update) or one of its systems. |
| DrivenMemberAttribute(string declaringTypeName, string member, params Type[] stages) | Declares the driven member of a type the assembly doesn't reference: the type by assembly-qualified name, as "UnityEngine.Cloth, UnityEngine.ClothModule", then the member name and the stages. |
Properties
| Type DeclaringType { get; } | The type declaring the member, or null when it's named by string. |
| string DeclaringTypeName { get; } | The assembly-qualified name of the type declaring the member, or null when it's given as a type. |
| string Member { get; } | The field or property name. |
| Type[] Stages { get; } | The player-loop stages that write the member. |
Makes a modifier on the member a compile error, for a member the engine updates from its own previous value, such as a velocity the physics engine updates each step: each step would apply the modifiers again on top of the last result. Stopping a modifier on it is an error too; observing it and Recombine() stay allowed. Use it on an assembly, as many times as needed.
Constructors
| UnmodifiableMemberAttribute(Type declaringType, string member) | Marks the member as unmodifiable: the type declaring it, and the field or property name given with nameof. |
| UnmodifiableMemberAttribute(string declaringTypeName, string member) | Marks the member of a type the assembly doesn't reference as unmodifiable: the type by assembly-qualified name, then the member name. |
Properties
| Type DeclaringType { get; } | The type declaring the member, or null when it's named by string. |
| string DeclaringTypeName { get; } | The assembly-qualified name of the type declaring the member, or null when it's given as a type. |
| string Member { get; } | The field or property name. |
| string Instead { get; set; } | What to modify instead, shown in the error. |
Control
A type stands for its static members and static code. A GameObject covers its components and children too, as destroying it would. For more information, refer to Control modifiers by object.
Controls and inspects what Concordance does to an object: the modifiers and observers it holds as their owner, and the ones on its members as their target.
Static methods
Every method throws InvalidOperationException off the main thread and in the Editor outside Play mode and tests, and ArgumentNullException when its argument is null.
| OwnerScope Owner(object owner) | The modifiers and observers the object holds as their owner, on any member of any target. For a type, the ones its static code holds. |
| TargetScope Target(object target) | The modifiers and observers on the object's members, whoever holds them. For a type, the ones on its static members. |
| void Release(object obj) | Does to Concordance's state what destroying the object does, without destroying it: stops its observers, then its modifiers, and the ones on its members. Call it when a pooled object returns, before deactivating it. Each modified member gets its base value back. |
| IDisposable CloneUnmodified<T>(T original, out T copy) where T : Object | Copies a GameObject, a component or a ScriptableObject with Object.Instantiate, as it would be without its modifiers: each modified member of the copy holds its base value. A component is copied with its GameObject. The original keeps its modifiers. Disposing the returned object destroys the copy, for a component its GameObject; to keep the copy, ignore it. Overloads take a parent, worldPositionStays, or a position and a rotation with an optional parent, as Object.Instantiate does. |
| IDisposable CloneUnmodified(ICloneable original, out object copy) | Copies a plain C# object with its own Clone, as it would be without its modifiers. Disposing the returned object disposes the copy when it is IDisposable. |
The modifiers and observers one object holds as their owner, returned by Concord.Owner. TargetScope has the same members, for the modifiers and observers on one object's members. A default instance covers nothing.
Properties
Every property and method throws InvalidOperationException off the main thread and in the Editor outside Play mode and tests.
| bool HasModifiers { get; } | Whether the scope holds any modifier. |
| bool HasObservers { get; } | Whether the scope holds any observer. |
Methods
| void StopModifying() | Stops every modifier in the scope. A stop ends the modifier, not its line: the line writes it again the next time it runs. |
| void StopModifying<TKey>(TKey key) | Stops the modifiers in the scope whose key equals key, compared with Equals without boxing a value-type key. StopModifying<object>(null) stops the modifiers that have no key. |
| void StopModifying(Predicate<ModifierInfo> filter) | Stops the modifiers in the scope that the filter accepts. Every modifier in the scope is filtered before any stops, so a filter that throws stops none. Throws ArgumentNullException when filter is null. |
| void StopObserving() | Stops every observer in the scope. |
| void StopObserving(Predicate<ObserverInfo> filter) | Stops the observers in the scope that the filter accepts. Every observer in the scope is filtered before any stops, so a filter that throws stops none. Throws ArgumentNullException when filter is null. |
| void Recombine() | Recombines every member the owner modifies, or for a TargetScope, every member of the target with modifiers or observers: each member's current value becomes its base value, and its modifiers apply again. Call it after code Concordance doesn't rewrite writes the members. Each modifier keeps the values it was written with. |
| ModifierInfo[] GetModifiers(Predicate<ModifierInfo> filter = null) | Returns the modifiers in the scope that the filter accepts, all when it is null, in a new array. Each member's modifiers come in the order they apply. |
| int GetModifiers(List<ModifierInfo> results, Predicate<ModifierInfo> filter = null) | Clears results, fills it with the modifiers in the scope, each member's in the order they apply, and returns their number. Reuse the list to allocate nothing. Throws ArgumentNullException when results is null. |
| ObserverInfo[] GetObservers(Predicate<ObserverInfo> filter = null) | Returns the observers in the scope that the filter accepts, in a new array. |
| int GetObservers(List<ObserverInfo> results, Predicate<ObserverInfo> filter = null) | Clears results, fills it with the observers in the scope, and returns their number. Throws ArgumentNullException when results is null. |
The modifiers and observers on one object's members, whoever holds them, returned by Concord.Target. For a type, the ones on its static members. It has the same members as OwnerScope.
A read-only description of one modifier. It holds no function and cannot act on the modifier.
Properties
| object Owner { get; } | The object the modifier belongs to, or a type for a modifier written in static code. |
| object Target { get; } | The object whose member the modifier changes; for a static member, its declaring type. |
| object Key { get; } | The key the modifier line passed, or null. Compare it with Equals: == compares references. |
| string StructMember { get; } | The field or property of the member's struct the modifier changes, as written after the member: "x" for offset.x, "Area.width" for placard.Area.width. Null for a modifier on the whole member. |
| Type ScriptType { get; } | The type whose code wrote the modifier: its script in the modifier order. |
| string MemberName { get; } | The modified member, as the Concordance window names it: Type.name, or Type.Getter/Setter for a getter and setter pair, as in GameObject.activeSelf/SetActive. |
| Phase Phase { get; } | The phase the modifier applies in: its phase in code, unless the modifier order pins its script elsewhere. |
| Phase PhaseInCode { get; } | The phase its script's code gives it. |
A read-only description of one observer.
Properties
| object Owner { get; } | The object the observer belongs to, or a type for an observer added in static code. |
| object Target { get; } | The object whose member the observer follows; for a static member, its declaring type. |
| string MemberName { get; } | The observed member, as the Concordance window names it: Type.name, or Type.Getter/Setter for a getter and setter pair. |
| Delegate Handler { get; } | The handler passed to Observe: an Action<T> or an Action<T, T>. |
The phases of the modifier order, in the order they apply, so info.Phase >= Phase.Late selects Late and Latest. Scripts set their phase with the [ModifierPhase.X] attributes.
Values
| Earliest | Applies first. |
| Early | Applies after Earliest and before Default. |
| Default | The phase of a script without a [ModifierPhase.X] attribute. |
| Late | Applies after Default and before Latest. |
| Latest | Applies last. |