public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, Method method, object arg) { //if (method.IsAsync) //{ // var result = cecilatorObject.GetAsyncMethod(method.methodDefinition); // cecilatorObject.Log(logTypes, result.Value.MethodDefinition.GetSequencePoint(), arg); //} //else cecilatorObject.Log(logTypes, method.methodDefinition.GetSequencePoint(), arg); }
public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, Method method, object arg) { var result = cecilatorObject.GetAsyncMethod(method.methodDefinition); if (result.HasValue) { cecilatorObject.Log(logTypes, result.Value.MethodDefinition.GetSequencePoint(), arg); } else { cecilatorObject.Log(logTypes, method.methodDefinition.GetSequencePoint(), arg); } }
private static (MethodDefinition MethodDefinition, TypeReference AsyncType)? GetAsyncMethod(this CecilatorObject cecilatorObject, MethodDefinition method) { var asyncStateMachine = method.CustomAttributes.Get("System.Runtime.CompilerServices.AsyncStateMachineAttribute"); if (asyncStateMachine != null) { var asyncType = asyncStateMachine.ConstructorArguments[0].Value as TypeReference; var asyncTypeMethod = asyncType.Resolve().Methods.Get("MoveNext"); if (asyncTypeMethod == null) { cecilatorObject.Log(LogTypes.Error, method, "Unable to find the method MoveNext of async method " + method.Name); return(null); } return(asyncTypeMethod, asyncType); } return(null); }
public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, object arg) => cecilatorObject.Log(logTypes, sequencePoint: null, arg: arg);
public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, Property property, object arg) => cecilatorObject.Log(logTypes, property.Getter ?? property.Setter, arg);
public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, BuilderType type, object arg) => cecilatorObject.Log(logTypes, type.GetRelevantConstructors().FirstOrDefault() ?? type.Methods.FirstOrDefault(), arg);