IEnumerable <Instruction> GetCatchInstructions() { yield return(Instruction.Create(OpCodes.Stloc, exceptionVariable)); var messageLdstr = Instruction.Create(OpCodes.Ldstr, ""); yield return(messageLdstr); yield return(Instruction.Create(OpCodes.Ldc_I4, Method.Parameters.Count)); yield return(Instruction.Create(OpCodes.Newarr, ModuleWeaver.ModuleDefinition.TypeSystem.Object)); yield return(Instruction.Create(OpCodes.Stloc, paramsArrayVariable)); var paramsFormatBuilder = new ParamsFormatBuilder(Method, paramsArrayVariable); foreach (var instruction in paramsFormatBuilder.Instructions) { yield return(instruction); } messageLdstr.Operand = paramsFormatBuilder.MessageBuilder.ToString(); yield return(Instruction.Create(OpCodes.Ldloc, paramsArrayVariable)); yield return(Instruction.Create(OpCodes.Call, ModuleWeaver.FormatMethod)); yield return(Instruction.Create(OpCodes.Stloc, messageVariable)); foreach (var instruction in AddWrite(ModuleWeaver.ErrorMethod, ModuleWeaver.IsErrorEnabledMethod)) { yield return(instruction); } yield return(Instruction.Create(OpCodes.Rethrow)); }
IEnumerable <Instruction> GetCatchInstructions() { yield return(Instruction.Create(OpCodes.Stloc, exceptionVariable)); var messageLdstr = Instruction.Create(OpCodes.Ldstr, ""); yield return(messageLdstr); yield return(Instruction.Create(OpCodes.Ldc_I4, Method.Parameters.Count)); yield return(Instruction.Create(OpCodes.Newarr, ModuleWeaver.ModuleDefinition.TypeSystem.Object)); yield return(Instruction.Create(OpCodes.Stloc, paramsArrayVariable)); var paramsFormatBuilder = new ParamsFormatBuilder(Method, paramsArrayVariable); foreach (var instruction in paramsFormatBuilder.Instructions) { yield return(instruction); } messageLdstr.Operand = paramsFormatBuilder.MessageBuilder.ToString(); yield return(Instruction.Create(OpCodes.Ldloc, paramsArrayVariable)); yield return(Instruction.Create(OpCodes.Call, ModuleWeaver.FormatMethod)); yield return(Instruction.Create(OpCodes.Stloc, messageVariable)); if (attributeFinder.FoundDebug) { foreach (var instruction in AddWrite(ModuleWeaver.WriteExceptionMethod, ModuleWeaver.isDebugEnabledMethod, ModuleWeaver.DebugLogEvent)) { yield return(instruction); } } if (attributeFinder.FoundInfo) { foreach (var instruction in AddWrite(ModuleWeaver.WriteExceptionMethod, ModuleWeaver.isInfoEnabledMethod, ModuleWeaver.InfoLogEvent)) { yield return(instruction); } } if (attributeFinder.FoundWarning) { foreach (var instruction in AddWrite(ModuleWeaver.WriteExceptionMethod, ModuleWeaver.isWarningEnabledMethod, ModuleWeaver.WarningLogEvent)) { yield return(instruction); } } if (attributeFinder.FoundError) { foreach (var instruction in AddWrite(ModuleWeaver.WriteExceptionMethod, ModuleWeaver.isErrorEnabledMethod, ModuleWeaver.ErrorLogEvent)) { yield return(instruction); } } yield return(Instruction.Create(OpCodes.Rethrow)); }
IEnumerable<Instruction> GetCatchInstructions() { yield return Instruction.Create(OpCodes.Stloc, exceptionVariable); var messageLdstr = Instruction.Create(OpCodes.Ldstr, ""); yield return messageLdstr; yield return Instruction.Create(OpCodes.Ldc_I4, Method.Parameters.Count); yield return Instruction.Create(OpCodes.Newarr, ModuleWeaver.ModuleDefinition.TypeSystem.Object); yield return Instruction.Create(OpCodes.Stloc, paramsArrayVariable); var paramsFormatBuilder = new ParamsFormatBuilder(Method, paramsArrayVariable); foreach (var instruction in paramsFormatBuilder.Instructions) { yield return instruction; } messageLdstr.Operand = paramsFormatBuilder.MessageBuilder.ToString(); yield return Instruction.Create(OpCodes.Ldloc, paramsArrayVariable); yield return Instruction.Create(OpCodes.Call, ModuleWeaver.FormatMethod); yield return Instruction.Create(OpCodes.Stloc, messageVariable); if (attributeFinder.FoundTrace) { foreach (var instruction in AddWrite(ModuleWeaver.TraceExceptionMethod, ModuleWeaver.IsTraceEnabledMethod)) { yield return instruction; } } if (attributeFinder.FoundDebug) { foreach (var instruction in AddWrite(ModuleWeaver.DebugExceptionMethod, ModuleWeaver.IsDebugEnabledMethod)) { yield return instruction; } } if (attributeFinder.FoundInfo) { foreach (var instruction in AddWrite(ModuleWeaver.InfoExceptionMethod, ModuleWeaver.IsInfoEnabledMethod)) { yield return instruction; } } if (attributeFinder.FoundWarn) { foreach (var instruction in AddWrite(ModuleWeaver.WarnExceptionMethod, ModuleWeaver.IsWarnEnabledMethod)) { yield return instruction; } } if (attributeFinder.FoundError) { foreach (var instruction in AddWrite(ModuleWeaver.ErrorExceptionMethod, ModuleWeaver.IsErrorEnabledMethod)) { yield return instruction; } } if (attributeFinder.FoundFatal) { foreach (var instruction in AddWrite(ModuleWeaver.FatalExceptionMethod, ModuleWeaver.IsFatalEnabledMethod)) { yield return instruction; } } yield return Instruction.Create(OpCodes.Rethrow); }
IEnumerable <Instruction> GetCatchInstructions() { yield return(Instruction.Create(OpCodes.Stloc, exceptionVariable)); var messageLdstr = Instruction.Create(OpCodes.Ldstr, ""); yield return(messageLdstr); yield return(Instruction.Create(OpCodes.Ldc_I4, Method.Parameters.Count)); yield return(Instruction.Create(OpCodes.Newarr, ModuleWeaver.TypeSystem.ObjectReference)); yield return(Instruction.Create(OpCodes.Stloc, paramsArrayVariable)); var paramsFormatBuilder = new ParamsFormatBuilder(Method, paramsArrayVariable); foreach (var instruction in paramsFormatBuilder.Instructions) { yield return(instruction); } messageLdstr.Operand = paramsFormatBuilder.MessageBuilder.ToString(); yield return(Instruction.Create(OpCodes.Ldloc, paramsArrayVariable)); yield return(Instruction.Create(OpCodes.Call, ModuleWeaver.FormatMethod)); yield return(Instruction.Create(OpCodes.Stloc, messageVariable)); if (attributeFinder.FoundVerbose) { foreach (var instruction in AddWrite(ModuleWeaver.VerboseExceptionMethod, ModuleWeaver.VerboseLevel)) { yield return(instruction); } } if (attributeFinder.FoundDebug) { foreach (var instruction in AddWrite(ModuleWeaver.DebugExceptionMethod, ModuleWeaver.DebugLevel)) { yield return(instruction); } } if (attributeFinder.FoundInfo) { foreach (var instruction in AddWrite(ModuleWeaver.InfoExceptionMethod, ModuleWeaver.InformationLevel)) { yield return(instruction); } } if (attributeFinder.FoundWarn) { foreach (var instruction in AddWrite(ModuleWeaver.WarnExceptionMethod, ModuleWeaver.WarningLevel)) { yield return(instruction); } } if (attributeFinder.FoundError) { foreach (var instruction in AddWrite(ModuleWeaver.ErrorExceptionMethod, ModuleWeaver.ErrorLevel)) { yield return(instruction); } } if (attributeFinder.FoundFatal) { foreach (var instruction in AddWrite(ModuleWeaver.FatalExceptionMethod, ModuleWeaver.FatalLevel)) { yield return(instruction); } } yield return(Instruction.Create(OpCodes.Rethrow)); }