示例#1
0
 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);
 }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }
示例#4
0
 public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, object arg) => cecilatorObject.Log(logTypes, sequencePoint: null, arg: arg);
示例#5
0
 public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, Property property, object arg) => cecilatorObject.Log(logTypes, property.Getter ?? property.Setter, arg);
示例#6
0
 public static void Log(this CecilatorObject cecilatorObject, LogTypes logTypes, BuilderType type, object arg) => cecilatorObject.Log(logTypes, type.GetRelevantConstructors().FirstOrDefault() ?? type.Methods.FirstOrDefault(), arg);