Ejemplo n.º 1
0
        public FluentEmitter Emit(Instruction instruction)
        {
            if (_emitAction == null)
            {
                _emitAction = i => MethodDefinition.Body.Instructions.Add(i);
            }

            _emitAction(instruction);
            LastEmittedInstruction = instruction;

            while (PostEmitActions.Count != 0)
            {
                var action = PostEmitActions.Dequeue();
                if (!action(this))
                {
                    PostEmitActions.Enqueue(action);
                }
            }

            if (StackValidationMode == StackValidationMode.Manual ||
                StackValidationMode == StackValidationMode.OnReturn && instruction.OpCode != OpCodes.Ret)
            {
                return(this);
            }

            var validator = new FlowControlAnalyzer(Body);

            validator.ValidateFullStackOrThrow();

            return(this);
        }
Ejemplo n.º 2
0
 public void validate_all_methods_of_types_in_system_namespace()
 {
     foreach (var method in typeof(string).Assembly.GetTypes().Where(t => t.Namespace == "System")
              .SelectMany(t => t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)))
     {
         var body     = TestModule.SafeImport(method).Resolve().Body;
         var analyzer = new FlowControlAnalyzer(body);
         analyzer.ValidateFullStackOrThrow();
     }
 }