Open sandboxFocus

Method ForEachSite

ForEachSite(Func<IMethodInterceptionSite, IMethodInterception>)

Decides the interception of each call site with a delegate, for instance to skip some call sites or to choose a template per site.

Declaration
IMethodInterception ForEachSite(Func<IMethodInterceptionSite, IMethodInterception> intercept)
Parameters
Type Name Description
Func<IMethodInterceptionSite, IMethodInterception> intercept

The delegate. It receives the call site, which describes the site and creates its result, and returns a result created by this site during this invocation, for instance site.Skip() or site.RedirectToSynthesizedMethod( … ). A result created for another site is refused, so the delegate cannot store a result and return it again. It is stored with the registration, so it must not capture a declaration or a compilation. It can be invoked concurrently, and several times for the same site.

Returns
Type Description
IMethodInterception
Remarks

The delegate can report diagnostics through Diagnostics. An exception thrown by the delegate is reported as an error on the declaration that contains the site, and the site is not intercepted.

The delegate is invoked only for call sites written in the source code. A call that the compiler, the runtime or a library makes on behalf of the code is never presented, because no call exists at the site.

Exceptions
Type Condition
ArgumentNullException

intercept is null.