Epiforge.Extensions.Expressions
5.0.0
dotnet add package Epiforge.Extensions.Expressions --version 5.0.0
NuGet\Install-Package Epiforge.Extensions.Expressions -Version 5.0.0
<PackageReference Include="Epiforge.Extensions.Expressions" Version="5.0.0" />
<PackageVersion Include="Epiforge.Extensions.Expressions" Version="5.0.0" />
<PackageReference Include="Epiforge.Extensions.Expressions" />
paket add Epiforge.Extensions.Expressions --version 5.0.0
#r "nuget: Epiforge.Extensions.Expressions, 5.0.0"
#:package Epiforge.Extensions.Expressions@5.0.0
#addin nuget:?package=Epiforge.Extensions.Expressions&version=5.0.0
#tool nuget:?package=Epiforge.Extensions.Expressions&version=5.0.0
This library has useful tools for dealing with expressions:
ExpressionEqualityComparer- Defines methods to support the comparison of expression trees for equalityExpressionExtensions, providing:Duplicate- Duplicates the specified expression treeSubstituteMethods- Recursively scans an expression tree to replace invocations of specific methods with replacement methods
Observable
This library accepts a LambdaExpression and arguments to pass to it, dissects the LambdaExpression's body, and hooks into change notification events for properties (INotifyPropertyChanged), collections (INotifyCollectionChanged), and dictionaries (Epiforge.Extensions.Collections.INotifyDictionaryChanged).
// Employee implements INotifyPropertyChanged
var elizabeth = Employee.GetByName("Elizabeth");
var observer = new ExpressionObserver();
var expr = observer.Observe(e => e.Name.Length, elizabeth);
// expr subscribed to elizabeth's PropertyChanged
Then, as changes involving any elements of the expression occur, a chain of automatic re-evaluation will get kicked off, possibly causing the observable expression's Evaluation property to change.
var elizabeth = Employee.GetByName("Elizabeth");
var observer = new ExpressionObserver();
var expr = observer.Observe(e => e.Name.Length, elizabeth);
// expr.Evaluation.Result == 9
elizabeth.Name = "Lizzy";
// expr.Evaluation.Result == 5
Also, since exceptions may be encountered after an observable expression was created due to subsequent element changes, observable expressions include a Fault property in their evaluations, which will be set to the exception that was encountered during evaluation.
var elizabeth = Employee.GetByName("Elizabeth");
var observer = new ExpressionObserver();
var expr = observer.Observe(e => e.Name.Length, elizabeth);
// expr.Evaluation.Fault is null
elizabeth.Name = null;
// expr.Evaluation.Fault is NullReferenceException
Observable expressions raise property change events of their own, so listen for those (kinda the whole point)!
var elizabeth = Employee.GetByName("Elizabeth");
var observer = new ExpressionObserver();
var expr = observer.Observe(e => e.Name.Length, elizabeth);
expr.PropertyChanged += (sender, e) =>
{
if (e.PropertyName == "Evaluation")
{
var (fault, result) = expr.Evaluation;
if (fault is not null)
{
// Whoops
}
else
{
// Do something with result
}
}
};
While an expression is working out its new value it can pass through results that were never simultaneously true of its inputs; an addition whose two operands both derive from the same property has to compute one of them before the other. You are not told about those. Every event you receive carries a value the expression genuinely held, so a subscriber that redraws or broadcasts on one does that work once rather than twice, the second time only to correct the first.
Nor are you told anything at all when a change leaves the value where it found it. That is decided by a comparison, using the same equality the expression uses everywhere else, and it happens before PropertyChanging rather than after — so a handler for that event still reads the previous value, and a pair of events always means the value really moved.
When you dispose of your observable expression, it will disconnect from all the events.
var elizabeth = Employee.GetByName("Elizabeth");
var observer = new ExpressionObserver();
using (var expr = observer.Observe(e => e.Name.Length, elizabeth))
{
// expr subscribed to elizabeth's PropertyChanged
}
// expr unsubcribed from elizabeth's PropertyChanged
How an Expression Gets Observed
Observe takes a shortcut when it can and builds a graph when it cannot, deciding once when the observation is created. You receive the same values through the same events either way; the shortcut is just faster and lighter.
The shortcut handles an expression built from these:
- the argument, constants, and captured locals
- fields, on anything above — including static fields
- static properties
- properties and indexers whose target is one of the above
- a property read through something which can change, such as
e => e.Name.Lengthore => e.Manager.Rank, which follows the value as it moves and re-subscribes where it lands ?:,&&,||and??, whose deferred operands take their subscriptions the first time an evaluation reaches them, which is where the graph attaches its nodes for them- a call to the get method of a property or an indexer, which is how an indexer written in C# arrives, read as the member or index access it stands for
- object construction, object initializers and array initializers, including construction of a value the observer disposes of when nothing the constructor is given can change, made once and disposed once
- an invocation of a literal lambda, as a formula or rule engine building expression trees at run time commonly emits, reduced to the body it would have evaluated
- method calls and operators resolved to a method, unless the observer disposes of what one returned and what it is made on or given can change
- a property whose change notifications you have told the observer to ignore, when nothing it is read through can change, read once and kept
What builds the graph instead: a kind of expression not in that list, such as a lambda passed as an argument or an array built from bounds; an indexer whose target can change; a member read on a value type which can notify; a call or operator whose return value the observer disposes of and whose target or arguments can change; a construction whose value the observer disposes of and whose arguments can change; a read of a property or an indexer you have registered for disposal, whatever it is read through, because the property can announce and the graph replaces and disposes of its value when it does; a read of an ignored property through something which can change; and an expression deferring more than sixty-four operands.
To find out about a particular expression, ask:
var analysis = new DirectSubscriptionAnalyzer(options).Analyze(expression.Body);
// analysis.IsEligible says whether the shortcut handles it
// analysis.Ineligibility says why not, such as DirectSubscriptionIneligibility.ValueRequiresDisposal
// analysis.IneligibleExpression is the part responsible
Hand the analyzer the same options you hand the observer, since some of them decide what gets subscribed to at all. Set UseDirectSubscription to false if you would rather always have the graph; it is true by default.
Fields Are Read Once
Whatever a field held when an observation began is what that observation goes on using — a captured local, a field of your own class, and a static field alike. Assigning it afterward does not reach an observation that already exists. Static properties behave the same way, so e => e.Hired < DateTime.Now compares against the moment it was created for as long as it lives.
var threshold = low;
using var expr = observer.Observe(e => e.Salary > threshold.Amount, elizabeth);
threshold = high; // expr is still comparing against low
low.Amount = 50000; // expr re-evaluates
high.Amount = 90000; // expr does not
If you want the comparison to follow the value, do not assign the field — make the thing it points at a property of an object that notifies, and read that instead.
Observable expressions will also try to automatically dispose of disposable objects they create in the course of their evaluation when and where it makes sense. Use the ExpressionObserverOptions class for more direct control over this behavior.
You can use the Optimizer property to specify an optimization method to invoke automatically during the observable expression creation process.
We recommend Tuomas Hietanen's Linq.Expression.Optimizer, the utilization of which would look like so:
var options = new ExpressionObserverOptions { Optimizer = ExpressionOptimizer.tryVisit };
var a = Expression.Parameter(typeof(bool));
var b = Expression.Parameter(typeof(bool));
var lambda = Expression.Lambda<Func<bool, bool, bool>>
(
Expression.AndAlso
(
Expression.Not(a),
Expression.Not(b)
),
a,
b
); // lambda explicitly defined as (a, b) => !a && !b
var observer = new ExpressionObserver(options);
var expr = observer.Observe<bool>(lambda, false, false);
// optimizer has intervened and defined expr as (a, b) => !(a || b)
// (because Augustus De Morgan said they're essentially the same thing, but this involves less steps)
Observable Queries
This library provides re-implementations of LINQ operations, but instead of returning IEnumerable<T>s and simple values, these return IObservableCollectionQuery<T>s, IObservableDictionaryQuery<TKey, TValue>s, and IObservableScalarQuery<T>s.
This is because, unlike traditional LINQ operations, these implementations continuously update their results until those results are disposed.
What they hand back is a read-only view of the source: change the source, and the query brings itself up to date. Queries do not implement the mutating range collection and dictionary interfaces, because a query result is not somewhere you put things.
But... what could cause those updates?
- the source is enumerable, implements
INotifyCollectionChanged, and raises aCollectionChangedevent - the source is a dictionary, implements
Epiforge.Extensions.Collections.INotifyDictionaryChanged<TKey, TValue>, and raises aDictionaryChangedevent - the elements in the enumerable (or the values in the dictionary) implement
INotifyPropertyChangedand raise aPropertyChangedevent - a reference enclosed by a selector or a predicate passed to the method implements
INotifyCollectionChanged,Epiforge.Extensions.Collections.INotifyDictionaryChanged<TKey, TValue>, orINotifyPropertyChangedand raises one of their events
That last one might be a little surprising, but this is because all selectors and predicates passed to Observable Query methods become Observable Expressions (see above).
This means that you will not be able to pass one that an ExpressionObserver cannot observe (e.g. a lambda expression that can't be converted to an expression tree or that contains nodes that are unsupported).
But, in exchange for this, you get all kinds of notification plumbing that's just handled for you behind the scenes.
Suppose, for example, you're working on an app that displays a list of notes and you want the notes to be shown in descending order of when they were last edited.
var notes = new ObservableCollection<Note>();
var collectionObserver = new CollectionObserver();
var observedNotes = collectionObserver.ObserveReadOnlyList(notes);
var orderedNotes = observedNotes.ObserveOrderBy(note => note.LastEdited, isDescending: true);
notesViewControl.ItemsSource = orderedNotes;
From then on, as you add Notes to the notes observable collection, the IObservableCollectionQuery<Note> named orderedNotes will be kept ordered so that notesViewControl displays them in the preferred order.
Since IObservableCollectionQuery<T>'s are automatically subscribing to events for you, you do need to call Dispose on them when you don't need them any more.
void Page_Unload(object? sender, EventArgs e)
{
orderedNotes.Dispose();
observedNotes.Dispose();
}
Ahh, but what about exceptions?
Well, Observable Expressions contain a Fault element in their Evaluation properties, but... you don't really see those Observable Expressions as an Observable Query caller, do ya?
For that reason, Observable Queries all have OperationFault properties.
You may subscribe to their PropertyChanging and PropertyChanged events to be notified when an Observable Expression or the overall Observable Query runs into a problem.
If there is more than one fault in play, the value of OperationFault will be an AggregateException.
Dictionary queries adopt the key comparer of the dictionary they observe, discovering it through Epiforge.Extensions.Collections.Generic.IHashKeys<TKey> or a Dictionary<TKey, TValue>'s own Comparer, so a query over a case-insensitive dictionary is itself case-insensitive.
ObserveGroupBy, ObserveToLookup, and ObserveDistinct do not order their results the way LINQ does.
Groupings are ordered by when they were created and the elements of a grouping by when they were added, rather than by where they occur in the source.
This is deliberate: holding a grouping at the position of its key's first occurrence would mean moving that grouping every time an element was inserted ahead of it, announcing a change to something whose membership did not change, which is the opposite of what an Observable Query is for.
Call ObserveOrderBy on the query, or on a grouping, when you want a defined order.
Reach for foreach rather than the indexer, because the difference between them is larger than it looks and grows with the collection.
An enumeration takes the query's lock once and then walks a list, while the indexer takes that lock again for every element you ask for; on a large collection it must also find each one in a tree, because a query keeps its elements' positions in one so that a change repairs only what it touched.
A query does remember the position it handed out last and searches outward from there, so asking for positions in order, or near one another, costs a fraction of asking for them at random, and what remains is mostly the repeated locking rather than the search.
Walking ten thousand elements by index instead of by enumerator measured between thirty and fifty times slower in order, and around two hundred times out of order; at a hundred elements it was about fifteen, and there the repeated locking is the whole of it.
Where you do need elements by position more than once, copy the query's contents and index the copy.
Since the ExpressionObserver has a number of options governing its behavior, you may optionally pass one you've made to the constructor of CollectionObserver to ensure those options are obeyed when Observable Expressions are created to enable your Observable Queries.
How Observable Queries Work and When to Use Them
It is worth being plain about what kind of thing this is, because "LINQ, but observable" undersells it and sets the wrong expectations.
A LINQ query is a description of a computation you run. Run it again and it does all of the work again. An Observable Query is not re-run. It is a small machine that holds the answer and repairs it, so when something changes, only the parts of the answer that depended on that thing are recomputed. The work is proportional to what changed rather than to how much data you have. If you want the name the literature uses for this idea, it is incremental, or self-adjusting, computation.
Three things that might otherwise look like arbitrary restrictions fall straight out of that:
- Your selectors and predicates have to be expression trees rather than delegates because the machine has to read them to find out what they depend on. A delegate is opaque; there is nothing in it to subscribe to.
- You have to dispose of a query because it is holding subscriptions to everything it depends on, and those subscriptions are the entire reason the answer stays right.
- Faults reach you through
OperationFaultinstead of being thrown, because the evaluation that failed happened later, on whatever thread raised the change. By then there is no call of yours left on the stack to throw out of.
What is not free is construction. Building the machine means building an observable expression for every element the query touches, and that is proportional to the size of the collection. So build a query once and hold onto it. Do not build one per frame, per request, or per keystroke. The bargain is that you pay up front and then stop paying to read.
Reading is also cheaper than being told. A query subscribes to the one it is built on only while something is subscribed to it, and a filtered query works out where a change landed, and describes it, only when something will receive that description. So subscribe when you need to be told what changed, and simply read the query when you only need its answer to be right.
Which is also how to decide whether you want one. If you compute a result once and move on, plain LINQ is cheaper and simpler, and you should use it. If a result has to stay correct across a long run of small changes, such as a list someone is looking at, a running total, or a filter someone is typing into, that is what these are for.
Choosing Between Observable Queries and DynamicData
DynamicData is the nearest thing to this in .NET, and it is a good library. Both keep a derived collection correct as your data changes — filter, sort, group, project, aggregate — and both update the result when an element's property changes rather than only when the collection does. Here is how to tell which one you want.
Start with what you already know. If you know INotifyPropertyChanged, ObservableCollection<T> and LINQ, this library asks you to learn almost nothing else: you point it at the collection you already have, write ObserveWhere(person => person.Rank > 0), and bind the result. If you already know Rx, or you use ReactiveUI, DynamicData will feel like home and this library will feel like an unfamiliar dialect — and it is probably already somewhere in your dependency graph. Most of the rest follows from that one answer.
| What you will actually run into | This library | DynamicData |
|---|---|---|
| Where your data lives | The ObservableCollection<T> you already have |
A SourceCache or SourceList; adapting an existing collection is possible but much slower |
| Saying which property to watch | Read out of your expression | You name it with AutoRefresh — forget it and your view goes quietly stale |
| A property change that does not change the result | Costs nothing | Materializes a change set each time |
| When your projection throws | A fault you can bind to; the query keeps working | Ends the subscription, as Rx does, unless you use TransformSafe |
| Combining collections | ObserveConcat, chained |
Also union, intersection, difference, and merging a changing set of sources |
| Showing only what is on screen | A fixed slice that stays correct | Live paging and virtualization driven by a stream of requests |
| Composing with anything else reactive | Not applicable | Everything in Rx composes with it |
| An expression it cannot analyze | Falls back to a slower path, says so in your log, results unchanged | Not applicable |
Use DynamicData if you are already in Rx; you need to combine several collections by set operations; you need live paging, virtualization, size limits or expiry; you need asynchronous projections; or you want the reassurance of a large and long-established user base.
Use this library if you want a live view of a collection you already have, with the least new vocabulary, and you care about what an individual property change costs.
What It Costs
These are from the benchmarks in this repository, against DynamicData 9.4.33 at a thousand elements unless stated otherwise. Each propagation figure is per property change, above what the same changes cost with nothing observing them at all.
| This library | DynamicData | |
|---|---|---|
| A property change that does not alter a filtered view | 0 B, 7.8 ns | 608 B, 199.1 ns |
| An element changing group | 578 B, 236.9 ns | 1,891 B, 604.8 ns |
| An element moving in a sorted view | 292 B, 1,259.5 ns | 414 B, 984.4 ns |
| Building a filtered view | 973 KB, 295 μs | 4,119 KB, 2,267 μs |
| What a live filtered view holds | 942 B per element | 1,865 B per element |
The zero is exact rather than rounded: a property change that does not move an element in or out of a filtered view allocates nothing here, at a thousand, ten thousand and a hundred thousand elements alike. This library re-evaluates the predicate in place and stays silent when the answer has not moved; DynamicData's model is a stream of change sets, so a refresh has to materialize one. Neither is a defect. One library pays per change and the other pays per change that matters.
Two of those rows move with the size of the view, in opposite directions, and this is the part worth reading twice.
- Sorting. DynamicData's cost per move grows with the collection while this library's barely does, so the two cross at about 1,400 elements. Below that DynamicData is 1.28x faster; at four thousand this library is 1.72x faster and at ten thousand 2.98x.
- Grouping. The reverse. DynamicData's cost per migration is flat while this library's grows, so the two cross at about 7,900 elements. Below that this library is 2.55x faster; at ten thousand DynamicData is 1.18x faster — though it holds about twice the memory to do it, 1,954 B per element against 1,032.
The grouping crossover is a trade rather than an oversight, and knowing which side of it you want is more useful than the number. A grouping here keeps its elements in the order they were added, so moving one out of its old group means finding it first, which is work proportional to the size of that group. DynamicData's groups are keyed rather than positional, so a removal is a dictionary operation and costs the same whatever the group holds. If you need the elements of a group in a stable order, that is what you are paying for. If you do not, DynamicData's shape is cheaper once groups get large. A lookup built with ObserveToLookup is the same shape as a grouping here and behaves the same way.
What decides both is the size of the view the operator sees, not the size of your collection. Filter ten thousand elements down to a thousand and then sort, and you are on the small-view side of the sorting crossover, where DynamicData wins; grouping that same thousand puts you well on this library's side of the grouping one.
Allocation does not cross. At every size measured, this library allocates less for the same work: nothing at all for a filtered view, 0.31x DynamicData's for grouping, 0.71x for sorting.
The propagation advantage is largest at the sizes most applications use, and it narrows above them. Per property change above the floor, this library costs 6.8 ns at a thousand elements, 9.2 ns at ten thousand and 55.0 ns at a hundred thousand, against 190.7, 212.5 and 406.8 ns — a lead of 27.9x, then 23.1x, then 7.4x. The allocation figure is unchanged across all three sizes; the time figure is not. A hundred thousand observations do not fit in cache, and a library which has driven its own per-change work to near zero has nothing left to hide a cache miss behind. The advantage shrinks from very large to large.
Composition behaves. Ordering or grouping a filtered view costs each library close to the sum of its parts rather than more, so a chain does not change which one to prefer — only the size of the view arriving at each stage does.
Two more things worth knowing before you weigh any of the above.
A live view is not free in either library. One over ten thousand elements holds about 9 MB here and about 19 MB in DynamicData, against 960 KB for the elements themselves. Building a view is likewise proportional to the size of the collection in both. Build one and keep it; neither library rewards building views casually.
ToObservableChangeSet() over an existing ObservableCollection<T> costs DynamicData about 210x what its own SourceCache does for the same property changes. That is the path you land on if you adopt it without changing where your data lives, and it is worth knowing about before you do.
These comparisons were written by someone who does not use DynamicData, which is a real limitation on them. The harness is in this repository, the workloads are ordinary ones, and corrections are welcome.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Epiforge.Extensions.Collections (>= 4.1.1)
- Epiforge.Extensions.Components (>= 4.3.0)
-
net6.0
- Epiforge.Extensions.Collections (>= 4.1.1)
- Epiforge.Extensions.Components (>= 4.3.0)
- System.Collections.Immutable (>= 8.0.0)
-
net7.0
- Epiforge.Extensions.Collections (>= 4.1.1)
- Epiforge.Extensions.Components (>= 4.3.0)
- System.Collections.Immutable (>= 8.0.0)
-
net8.0
- Epiforge.Extensions.Collections (>= 4.1.1)
- Epiforge.Extensions.Components (>= 4.3.0)
-
net9.0
- Epiforge.Extensions.Collections (>= 4.1.1)
- Epiforge.Extensions.Components (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0 | 52 | 9/10/2026 |
| 4.4.0 | 45 | 9/9/2026 |
| 4.3.0 | 93 | 9/2/2026 |
| 4.2.0 | 88 | 8/31/2026 |
| 4.1.0 | 84 | 8/31/2026 |
| 4.0.0 | 113 | 8/30/2026 |
| 3.0.1 | 100 | 8/29/2026 |
| 3.0.0 | 189 | 8/27/2026 |
| 2.3.8 | 224 | 6/6/2026 |
| 2.3.7 | 123 | 6/6/2026 |
| 2.3.6 | 130 | 6/6/2026 |
| 2.3.5 | 122 | 6/3/2026 |
| 2.3.4 | 128 | 5/31/2026 |
| 2.3.3 | 122 | 5/29/2026 |
| 2.3.2 | 133 | 5/8/2026 |
| 2.3.1 | 124 | 5/7/2026 |
| 2.3.0 | 125 | 5/7/2026 |
| 2.2.0 | 133 | 4/23/2026 |
| 2.1.2 | 132 | 4/14/2026 |
| 2.1.1 | 144 | 4/12/2026 |
Observing an object initializer now evaluates to a new object each time one of its member assignments changes, and announces that change. Previously the new value was written into the object the observation had already produced and nothing was announced, so a consumer was never told its value had moved and the object it was holding changed underneath it. The correction costs one construction per evaluation of such an observation, which the previous behavior avoided by reusing a single instance.
An object initializer with two bindings whose expressions are the same, assigning one source value to two members, no longer throws when the observation is created.
An expression which invokes a literal lambda, as a formula or rule engine building expression trees at run time commonly emits, is now eligible to be observed by subscribing directly to its change sources. Such an invocation is reduced to the body it would have evaluated before the expression is analyzed, which the graph has always done for itself; measured over a thousand observations of a filtered query, one invocation cost 7.06x the memory and 23.7x the time before this change and two cost 10.94x and 41.3x. An invocation whose operand is not a literal lambda, or whose lambda reads one of its parameters other than exactly once, is still observed by a graph of observable expressions.
A member read through a field is now resolved when an observation is built, even where it sits in a branch of a conditional or a short circuit which is not evaluated until later. Previously such a read was resolved the first time that branch was reached, so an observation could report a value obtained from an object the field no longer held, and could report a different value than the same expression observed by subscribing directly to its change sources. This is a change to what an observation reports and it is the reason for the major version. A member read through something which cannot announce is captured exactly once for the life of an observation and does not change afterward; where such a read occurs only in a branch which is not evaluated immediately, the moment of capture is unspecified, because a local which a lambda captured is captured when its branch is first reached rather than when the observation is built, so that a branch not yet taken does not attach to that local's value's contents.
An expression which invokes a method is now eligible to be observed by subscribing directly to its change sources unless the observer disposes of what that method returned. Previously any method whose return type was not sealed was observed by a graph of observable expressions, whether or not anything would ever dispose of the value it produced, which is not the question a property read has ever been asked. The observer disposes of every static method's return value unless DisposeStaticMethodReturnValues is set to false, so a static method returning an unsealed type is still observed by a graph under the default options. Relatedly, ExpressionObserverOptions.IsMethodReturnValueDisposed now reports true for a method whose return parameter carries DisposeWhenDiscardedAttribute, which an observer built from those options has always honored and which the options alone did not report.
ExpressionObserverOptions.RemovePropertyValueDisposal now removes the registration it names. Previously it removed nothing and reported whether the property's value was disposed of, so a registration made through a property could not be undone through one, and RemoveExpressionValueDisposal did nothing for an expression naming a property or an indexer.
An expression reading a property whose change notifications the observer has been told to ignore is now eligible to be observed by subscribing directly to its change sources when nothing that property is read through can change. Such a read is made once by the first evaluation which reaches it and kept for the life of the observation, and no subscription is planned for it, which is what the graph's node for it does and attaches. A read through something which can change is still observed by a graph of observable expressions, because there the graph re-reads the property when that something moves and keeps its value between those moves, where a fast path would read it afresh whenever anything at all announced.
An observation which defers an operand no longer evaluates a node of that operand twice the first time an evaluation reaches it. Reading a deferred node's evaluation both resolves it and announces that its value changed, and the announcement reached a dependent which was part way through its own evaluation on the very line which read it, re-entering that evaluation and leaving the outer one to repeat the same work when the inner returned. Both produced the same value, so nothing a consumer received was ever wrong, but a node producing a value the observer disposes of made and discarded one more of them than the expression required. An evaluation in progress now declines to be re-entered, having not yet read what it depends on and being about to read what the announcement would have told it. This declines re-entry by something the evaluation depends on; it does not decline re-entry by a source, which is what happens when a property getter announces a change while that getter is being read. Such a getter is read once by a graph of observable expressions and once per re-entry by direct subscription. The two report the same value and the same fault either way, which the differential fuzz covers, so this matters only where reading the getter does something in addition to returning a value, such as constructing something the observer must dispose of.
Observing a method call with no arguments, a constructor with no parameters, or an invocation with no arguments no longer allocates an empty array to hold the subscriptions those arguments would have taken.
An expression constructing a value the observer disposes of is now eligible to be observed by subscribing directly to its change sources when every argument the constructor is given is invariant. Such a value is constructed by the first evaluation which reaches it, kept for the life of the observation and disposed of once with it, which is how many times a graph of observable expressions constructs and disposes it. A construction over an argument which can change is still observed by a graph, because there the graph constructs a new value when that argument moves and disposes of the one it replaced. A read of a property or an indexer registered for disposal is also still observed by a graph even where nothing it is read through can change, because the property itself can announce and the graph replaces and disposes of its value when it does, which holding a value once cannot do.
An expression observer now reports why an expression was not eligible to be observed by subscribing directly to its change sources. Where a logger is supplied through ExpressionObserverOptions.Logger, every expression which falls to a graph of observable expressions is written at debug level under EventIds.Epiforge_Extensions_Expressions_ExpressionNotEligibleForDirectSubscription, naming the expression, the subexpression responsible for the refusal, and the DirectSubscriptionIneligibility value which says what that subexpression failed. An expression which does not appear is being observed by subscribing directly to its change sources, so an application can learn which of its expressions take which mechanism, and why, without asking.