Open LaborJos opened 4 years ago
FodyWeavers.xml
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> <PropertyChanged /> <Tracer traceProperties="true" /> </Weavers>
Sources
[AddINotifyPropertyChangedInterface] [TraceOn(TraceTarget.Public)] public class ExampleClass { public string FirstName { get; set; } public string LastName { get; set; } public string FullName { get { return $"{this.LastName} {this.FirstName}"; } } }
Decompiled Sources
using System; using System.CodeDom.Compiler; using System.ComponentModel; using System.Diagnostics; using System.Threading; using Tracer.NLog.Adapters; using TracerAttributes; namespace MethodBoundaryAspect.Fody.Test { [TraceOn(TraceTarget.Public)] public class ExampleClass : INotifyPropertyChanged { private static LoggerAdapter \u0024log = LogManagerAdapter.GetLogger(typeof (ExampleClass)); [NonSerialized] private PropertyChangedEventHandler PropertyChanged; public string FirstName { get { return this.\u003CFirstName\u003Ek__BackingField; } set { if (string.Equals(this.\u003CFirstName\u003Ek__BackingField, value, StringComparison.Ordinal)) return; this.\u003CFirstName\u003Ek__BackingField = value; this.\u003C\u003EOnPropertyChanged(\u003C\u003EPropertyChangedEventArgs.FullName); this.\u003C\u003EOnPropertyChanged(\u003C\u003EPropertyChangedEventArgs.FirstName); } } public string LastName { get { return this.\u003CLastName\u003Ek__BackingField; } set { if (string.Equals(this.\u003CLastName\u003Ek__BackingField, value, StringComparison.Ordinal)) return; this.\u003CLastName\u003Ek__BackingField = value; this.\u003C\u003EOnPropertyChanged(\u003C\u003EPropertyChangedEventArgs.FullName); this.\u003C\u003EOnPropertyChanged(\u003C\u003EPropertyChangedEventArgs.LastName); } } public string FullName { get { ExampleClass.\u0024log.TraceEnter("get_FullName()", (Tuple<string, string>[]) null, (string[]) null, (object[]) null); long timestamp = Stopwatch.GetTimestamp(); string str; try { str = this.LastName + " " + this.FirstName; } catch (Exception ex) { string[] paramNames = new string[1]; object[] paramValues = new object[1]; paramNames[0] = "$exception"; paramValues[0] = (object) ex; ExampleClass.\u0024log.TraceLeave("get_FullName()", (Tuple<string, string>[]) null, timestamp, Stopwatch.GetTimestamp(), paramNames, paramValues); throw; } string[] paramNames1 = new string[1]; object[] paramValues1 = new object[1]; paramNames1[0] = (string) null; paramValues1[0] = (object) str; ExampleClass.\u0024log.TraceLeave("get_FullName()", (Tuple<string, string>[]) null, timestamp, Stopwatch.GetTimestamp(), paramNames1, paramValues1); return str; } } public event PropertyChangedEventHandler PropertyChanged { add { string[] paramNames1 = new string[1]; object[] paramValues1 = new object[1]; paramNames1[0] = nameof (value); paramValues1[0] = (object) value; ExampleClass.\u0024log.TraceEnter("add_PropertyChanged(PropertyChangedEventHandler)", (Tuple<string, string>[]) null, paramNames1, paramValues1); long timestamp = Stopwatch.GetTimestamp(); try { PropertyChangedEventHandler changedEventHandler = this.PropertyChanged; PropertyChangedEventHandler comparand; do { comparand = changedEventHandler; changedEventHandler = Interlocked.CompareExchange<PropertyChangedEventHandler>(ref this.PropertyChanged, comparand + value, comparand); } while (changedEventHandler != comparand); } catch (Exception ex) { string[] paramNames2 = new string[1]; object[] paramValues2 = new object[1]; paramNames2[0] = "$exception"; paramValues2[0] = (object) ex; ExampleClass.\u0024log.TraceLeave("add_PropertyChanged(PropertyChangedEventHandler)", (Tuple<string, string>[]) null, timestamp, Stopwatch.GetTimestamp(), paramNames2, paramValues2); throw; } ExampleClass.\u0024log.TraceLeave("add_PropertyChanged(PropertyChangedEventHandler)", (Tuple<string, string>[]) null, timestamp, Stopwatch.GetTimestamp(), (string[]) null, (object[]) null); } remove { string[] paramNames1 = new string[1]; object[] paramValues1 = new object[1]; paramNames1[0] = nameof (value); paramValues1[0] = (object) value; ExampleClass.\u0024log.TraceEnter("remove_PropertyChanged(PropertyChangedEventHandler)", (Tuple<string, string>[]) null, paramNames1, paramValues1); long timestamp = Stopwatch.GetTimestamp(); try { PropertyChangedEventHandler changedEventHandler = this.PropertyChanged; PropertyChangedEventHandler comparand; do { comparand = changedEventHandler; changedEventHandler = Interlocked.CompareExchange<PropertyChangedEventHandler>(ref this.PropertyChanged, comparand - value, comparand); } while (changedEventHandler != comparand); } catch (Exception ex) { string[] paramNames2 = new string[1]; object[] paramValues2 = new object[1]; paramNames2[0] = "$exception"; paramValues2[0] = (object) ex; ExampleClass.\u0024log.TraceLeave("remove_PropertyChanged(PropertyChangedEventHandler)", (Tuple<string, string>[]) null, timestamp, Stopwatch.GetTimestamp(), paramNames2, paramValues2); throw; } ExampleClass.\u0024log.TraceLeave("remove_PropertyChanged(PropertyChangedEventHandler)", (Tuple<string, string>[]) null, timestamp, Stopwatch.GetTimestamp(), (string[]) null, (object[]) null); } } [GeneratedCode("PropertyChanged.Fody", "3.2.6.0")] [DebuggerNonUserCode] protected void \u003C\u003EOnPropertyChanged(PropertyChangedEventArgs eventArgs) { PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if (propertyChanged == null) return; propertyChanged((object) this, eventArgs); } } }
FirstName and LastName are not Trace applied and FullName is applied. I don't know why this is happening.
the problem is that the properties have the CompilerGenerated attribute which tracer skips. I'll fix that.
fixed
FodyWeavers.xml
Sources
Decompiled Sources
FirstName and LastName are not Trace applied and FullName is applied. I don't know why this is happening.