public IILGen Try() { _sourceCodeWriter.MarkAndWriteLine(_ilGenerator, "try"); _sourceCodeWriter.OpenScope(); _ilGenerator.BeginExceptionBlock(); return(this); }
public ILDynamicTypeDebugImpl(string name, Type baseType, Type[] interfaces) { _name = name; var uniqueName = UniqueName(name); _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(uniqueName), AssemblyBuilderAccess.RunAndSave, "dynamicIL"); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(uniqueName + ".dll", true); var sourceCodeFileName = Path.GetFullPath("dynamicIL/" + uniqueName + ".il"); _symbolDocumentWriter = _moduleBuilder.DefineDocument(sourceCodeFileName, SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); _sourceCodeWriter = new SourceCodeWriter(sourceCodeFileName, _symbolDocumentWriter); _sourceCodeWriter.WriteLine(string.Format("class {0} : {1}{2}", name, baseType.ToSimpleName(), string.Concat(interfaces.Select(i => ", " + i.ToSimpleName())))); _sourceCodeWriter.OpenScope(); _typeBuilder = _moduleBuilder.DefineType(name, TypeAttributes.Public, baseType, interfaces); _forbidenInstructions = new ILGenForbidenInstructionsCheating(_typeBuilder); }
public ILDynamicTypeDebugImpl(string name, Type baseType, Type[] interfaces) { _name = name; var uniqueName = UniqueName(name, 259 - (DynamicILDirectoryPath.DynamicIL.Length + 1 + 4)); _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(uniqueName), AssemblyBuilderAccess.RunAndSave, DynamicILDirectoryPath.DynamicIL); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(uniqueName + ".dll", true); var sourceCodeFileName = Path.Combine(DynamicILDirectoryPath.DynamicIL, uniqueName + ".il"); _symbolDocumentWriter = _moduleBuilder.DefineDocument(sourceCodeFileName, SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); _sourceCodeWriter = new SourceCodeWriter(sourceCodeFileName, _symbolDocumentWriter); _sourceCodeWriter.WriteLine( $"class {name} : {baseType.ToSimpleName()}{string.Concat(interfaces.Select(i => ", " + i.ToSimpleName()))}"); _sourceCodeWriter.OpenScope(); _typeBuilder = _moduleBuilder.DefineType(name, TypeAttributes.Public, baseType, interfaces); _forbidenInstructions = new ILGenForbidenInstructionsCheating(_typeBuilder); }
public ILDynamicTypeDebugImpl(string name, Type baseType, Type[] interfaces) { _name = name; var uniqueName = UniqueName(name); _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(uniqueName), AssemblyBuilderAccess.RunAndSave, DynamicILDirectoryPath.DynamicIL); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(uniqueName + ".dll", true); var sourceCodeFileName = Path.Combine(DynamicILDirectoryPath.DynamicIL, uniqueName + ".il"); _symbolDocumentWriter = _moduleBuilder.DefineDocument(sourceCodeFileName, SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); _sourceCodeWriter = new SourceCodeWriter(sourceCodeFileName, _symbolDocumentWriter); _sourceCodeWriter.WriteLine( $"class {name} : {baseType.ToSimpleName()}{string.Concat(interfaces.Select(i => ", " + i.ToSimpleName()))}"); _sourceCodeWriter.OpenScope(); _typeBuilder = _moduleBuilder.DefineType(name, TypeAttributes.Public, baseType, interfaces); _forbidenInstructions = new ILGenForbidenInstructionsCheating(_typeBuilder); }