Skip to content

v3.7.0

Latest

Choose a tag to compare

@Ralf1108 Ralf1108 released this 13 Nov 07:43
· 1 commit to master since this release

What's new in 3.7.0

Changes since 3.6.0. Version 3.7.0 fixes many edge cases (ref/out arguments, generic aspects, async methods), makes woven calls faster, and adds build warnings for aspects that never had an effect. Most entries fix cases that did not work; some can change the behavior of existing code, see Check before upgrading.

The README is shorter now, the reference moved to docs. The full list with details is in the CHANGELOG.

Check before upgrading

Risk Change What to do
Medium Each aspect has its own MethodExecutionTag; an aspect that did not set the tag sees null (it saw the tag of the aspect before) Set the tag in the aspect itself
Medium New build warnings: unknown setting in FodyWeavers.xml, aspect applied where it is ignored (constructor, field, event, parameter, return value, module, abstract/interface/extern method), runtime-async method. They fail builds with TreatWarningsAsErrors Fix the cause or suppress the warning
Medium An invalid or very slow (30 s timeout) regular expression in a filter fails the build with the aspect named. It was ignored or hung Fix the pattern
Medium More aspects without state are shared between calls, and the code for MethodExecutionTag and FlowBehavior is only woven if used DisableAspectInstanceReuse, DisableExecutionArgsOptimization
Low to medium An aspect on a get or set accessor (int X { [Log] get; }) is woven now. It was ignored Remove the attribute or add [DisableWeaving]
Low FlowBehavior is reset before OnException: Continue set in OnEntry no longer swallows a later exception Set it in OnException
Low Finalizers are not woven none
Low args.Arguments in OnExit/OnException hold the ref and out values after the call Copy them in OnEntry if needed

Performance

  • The getter of a shared aspect is inlined, and the code for MethodExecutionTag and FlowBehavior is only emitted if an aspect uses it. On .NET 10 the overhead of two aspects on a method drops from 6.0 ns to 2.5 ns, on an async method from 17 ns / 208 B to 3.5 ns / 144 B.
  • args.Arguments of a method without parameters is Array.Empty<object>().
  • Uses of an attribute with the same values share one aspect instance ([Log] on 1000 methods generated 1000 fields and getters, now one).
  • Filter regular expressions are cached.

New

  • Build warnings for aspects that were silently ignored: on a constructor, field, event, parameter, return value, the module, or an abstract, interface or extern method or property.
  • Build warning for unknown settings in FodyWeavers.xml (e.g. SupressRefStructWarnings).
  • A schema for FodyWeavers.xml (MethodBoundaryAspect.Fody.xcf): IntelliSense and validation.
  • The NuGet package contains a README.

Fixed

Arguments and return values

  • A ref argument changed by an aspect ([AllowChangingInputArguments]) is the variable of the caller, not a copy. This fixes memory corruption for ref-returning methods and lost values after a swallowed exception.
  • A ref argument is only written back before the call if an aspect replaced it (no lost Interlocked updates).
  • [In] ref parameters are handled like ref parameters.
  • args.Arguments in OnExit and OnException contain the ref/out values after the call or after the method threw.
  • An argument of the wrong type set by an aspect is thrown to the caller, not handled by OnException.
  • ReturnValue of ref returns: ignored for ref readonly, null for a value type keeps the value instead of throwing.
  • Skipping the body of a ref-returning method calls the OnExit of the aspects before it.
  • TypedReference, ArgIterator and RuntimeArgumentHandle parameters work on .NET Framework.

Aspects and ordering

  • FlowBehavior is reset before OnException.
  • Each aspect has its own MethodExecutionTag.
  • An aspect on a property accessor is woven.
  • Generic aspects: constructor parameters and properties of the type parameter ([Validate<int>(5)]), [AspectOrderIndex(typeof(MyAspect<int>), 1)], a private type as type argument (created per call instead of MethodAccessException).
  • The same aspect on class and method can have an [AspectOrderIndex].
  • An aspect with a [MethodImpl(MethodImplOptions.Synchronized)] method is not shared (all calls of the process waited for each other).
  • An aspect with an additional private constructor can be shared.
  • Finalizers are no longer woven (the aspect ran on the finalizer thread, where an exception ends the process).

Async methods

  • With several aspects, the MethodExecutionTag set in OnExit is seen in OnException.
  • The task is returned even if the asynchronous work fails while OnExit runs (was a NullReferenceException or InvalidCastException).
  • Methods compiled with runtime-async (.NET 11) are not woven, with a warning.

Debugging, trimming and build

  • The executor method keeps [DebuggerHidden], [DebuggerStepThrough], [DebuggerNonUserCode], [StackTraceHidden], [HandleProcessCorruptedStateExceptions], [SecurityCritical], [UnconditionalSuppressMessage], [RequiresUnreferencedCode] and [RequiresDynamicCode], and the annotations of generic parameters and the return value (no IL2091 in the woven code).
  • Debugger scopes of woven methods are correct (imports, constants, locals visible).
  • 1 and 0 are accepted as boolean values in FodyWeavers.xml.
  • The warning "sets X in its code" names generic aspects correctly.
  • Build messages say "woven" instead of "weaved" (matters only for build log filters).

Planned for version 4

Obsolete aspect roles and CompileTimeValidate are removed, aspects applied directly to an event are woven, the filter properties are no longer virtual, and the minimum .NET Framework becomes 4.7.2. See the CHANGELOG.

Full Changelog: v3.6.0...v3.7.0