private void VerifyIssuer(FieldInfo res, ILGenerator attr) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 if (!res.IsStatic) { attr.PushIssuer(res.DeclaringType); attr.Emit(OpCodes.Ldfld, res); } else { attr.Emit(OpCodes.Ldsfld, res); } attr.AwakeIssuer(res.FieldType); attr.InterruptIssuer(); }
private void DisableIssuer(PropertyInfo v, ILGenerator cfg) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 MethodInfo getMethod = v.GetGetMethod(nonPublic: true); if (getMethod == null) { throw new ArgumentException("Property '{0}' does not have a getter.".ListReader(CultureInfo.InvariantCulture, v.Name)); } if (!getMethod.IsStatic) { cfg.PushIssuer(v.DeclaringType); } cfg.ReadIssuer(getMethod); cfg.AwakeIssuer(v.PropertyType); cfg.InterruptIssuer(); }
private void LoginIssuer(MethodBase param, ILGenerator reg, int nextproc) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 ParameterInfo[] parameters = param.GetParameters(); Label label = reg.DefineLabel(); reg.Emit(OpCodes.Ldarg, nextproc); reg.Emit(OpCodes.Ldlen); reg.Emit(OpCodes.Ldc_I4, parameters.Length); reg.Emit(OpCodes.Beq, label); reg.Emit(OpCodes.Newobj, typeof(TargetParameterCountException).GetConstructor(ResolverErrorFilter.collectionTest)); reg.Emit(OpCodes.Throw); reg.MarkLabel(label); if (!param.IsConstructor && !param.IsStatic) { reg.PushIssuer(param.DeclaringType); } LocalBuilder local = reg.DeclareLocal(typeof(IConvertible)); LocalBuilder local2 = reg.DeclareLocal(typeof(object)); OpCode opcode = (parameters.Length < 256) ? OpCodes.Ldloca_S : OpCodes.Ldloca; OpCode opcode2 = (parameters.Length < 256) ? OpCodes.Ldloc_S : OpCodes.Ldloc; for (int i = 0; i < parameters.Length; i++) { ParameterInfo parameterInfo = parameters[i]; Type parameterType = parameterInfo.ParameterType; if (parameterType.IsByRef) { parameterType = parameterType.GetElementType(); LocalBuilder local3 = reg.DeclareLocal(parameterType); if (!parameterInfo.IsOut) { reg.PrepareIssuer(nextproc, i); if (parameterType.FindClient()) { Label label2 = reg.DefineLabel(); Label label3 = reg.DefineLabel(); reg.Emit(OpCodes.Brtrue_S, label2); reg.Emit(opcode, local3); reg.Emit(OpCodes.Initobj, parameterType); reg.Emit(OpCodes.Br_S, label3); reg.MarkLabel(label2); reg.PrepareIssuer(nextproc, i); reg.UpdateIssuer(parameterType); reg.Emit(OpCodes.Stloc_S, local3); reg.MarkLabel(label3); } else { reg.UpdateIssuer(parameterType); reg.Emit(OpCodes.Stloc_S, local3); } } reg.Emit(opcode, local3); } else if (parameterType.FindClient()) { reg.PrepareIssuer(nextproc, i); reg.Emit(OpCodes.Stloc_S, local2); Label label4 = reg.DefineLabel(); Label label5 = reg.DefineLabel(); reg.Emit(OpCodes.Ldloc_S, local2); reg.Emit(OpCodes.Brtrue_S, label4); LocalBuilder local4 = reg.DeclareLocal(parameterType); reg.Emit(opcode, local4); reg.Emit(OpCodes.Initobj, parameterType); reg.Emit(opcode2, local4); reg.Emit(OpCodes.Br_S, label5); reg.MarkLabel(label4); if (parameterType.ValidateClient()) { MethodInfo method = typeof(IConvertible).GetMethod("To" + parameterType.Name, new Type[1] { typeof(IFormatProvider) }); if (method != null) { Label label6 = reg.DefineLabel(); reg.Emit(OpCodes.Ldloc_S, local2); reg.Emit(OpCodes.Isinst, parameterType); reg.Emit(OpCodes.Brtrue_S, label6); reg.Emit(OpCodes.Ldloc_S, local2); reg.Emit(OpCodes.Isinst, typeof(IConvertible)); reg.Emit(OpCodes.Stloc_S, local); reg.Emit(OpCodes.Ldloc_S, local); reg.Emit(OpCodes.Brfalse_S, label6); reg.Emit(OpCodes.Ldloc_S, local); reg.Emit(OpCodes.Ldnull); reg.Emit(OpCodes.Callvirt, method); reg.Emit(OpCodes.Br_S, label5); reg.MarkLabel(label6); } } reg.Emit(OpCodes.Ldloc_S, local2); reg.UpdateIssuer(parameterType); reg.MarkLabel(label5); } else { reg.PrepareIssuer(nextproc, i); reg.UpdateIssuer(parameterType); } } if (param.IsConstructor) { reg.Emit(OpCodes.Newobj, (ConstructorInfo)param); } else { reg.ReadIssuer((MethodInfo)param); } Type type = param.IsConstructor ? param.DeclaringType : ((MethodInfo)param).ReturnType; if (type != typeof(void)) { reg.AwakeIssuer(type); } else { reg.Emit(OpCodes.Ldnull); } reg.InterruptIssuer(); }