public string[] GetEntryPoints(bool includePrivate = false) { var list = new List <string>(); if (CurrentAssembly == null) { return(list.ToArray()); } var mods = CurrentAssembly.GetModules(false); if (mods.Length == 0) { return(list.ToArray()); } var types = includePrivate ? mods[0].GetTypes().Where(x => x.IsClass).ToArray() : mods[0].GetTypes().Where(x => x.IsClass && x.IsPublic).ToArray(); if (Language == LanguageType.JScript) { types = types.Where(x => x.Name != "JScript 0").ToArray(); } foreach (var type in types) { var methods = type.GetMethods(flags); foreach (var method in methods) { list.Add(string.Format("{0}.{1}", type.Name, method.Name)); } } return(list.ToArray()); }
public void treeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e, ref CurrentAssembly currentAssembly) { if (!(e.Node.Tag is AssemblyRef) || e.Node.TreeView.SelectedNode != e.Node) { return; } var assemblyRef = e.Node.Tag as AssemblyRef; string runtimeDirectory = RuntimeEnvironment.GetRuntimeDirectory(); string directory = Directory.GetParent(currentAssembly.Path).FullName; var paths = new List <string> { Path.Combine(directory, assemblyRef.Name + ".dll"), Path.Combine(directory, assemblyRef.Name + ".exe") }; var paths2 = new List <string> { Path.Combine(runtimeDirectory, assemblyRef.Name + ".exe"), Path.Combine(runtimeDirectory, assemblyRef.Name + ".dll") }; if (paths.Where(File.Exists).Count() == 1) { Functions.OpenFile(this, paths.First(File.Exists), ref currentAssembly); return; } if (paths2.Where(File.Exists).Count() == 1) { Functions.OpenFile(this, paths2.First(File.Exists), ref currentAssembly); return; } if ( MessageBox.Show("Could not automatically find reference file. Browse for it?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { currentAssembly = null; return; } var dialog = new OpenFileDialog { Title = String.Format("Browse for the reference \"{0}\"", assemblyRef.Name), Filter = "Executable Files (*.exe)|*.exe|Library Files (*.dll)|*.dll" }; if (dialog.ShowDialog() != DialogResult.OK && File.Exists(dialog.FileName)) { currentAssembly = null; return; } Functions.OpenFile(this, dialog.FileName, ref currentAssembly); }
static bool Weave(string assName, IEnumerable <string> dependencies) { using (DefaultAssemblyResolver asmResolver = new DefaultAssemblyResolver()) using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { asmResolver.AddSearchDirectory(Path.GetDirectoryName(assName)); asmResolver.AddSearchDirectory(Helpers.UnityEngineDllDirectoryName()); if (dependencies != null) { foreach (string path in dependencies) { asmResolver.AddSearchDirectory(path); } } WeaverTypes.SetupTargetTypes(CurrentAssembly); // WeaverList depends on WeaverTypes setup because it uses Import WeaveLists = new WeaverLists(); System.Diagnostics.Stopwatch rwstopwatch = System.Diagnostics.Stopwatch.StartNew(); // Need to track modified from ReaderWriterProcessor too because it could find custom read/write functions or create functions for NetworkMessages bool modified = ReaderWriterProcessor.Process(CurrentAssembly); rwstopwatch.Stop(); Console.WriteLine($"Find all reader and writers took {rwstopwatch.ElapsedMilliseconds} milliseconds"); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine($"Script Module: {moduleDefinition.Name}"); modified |= WeaveModule(moduleDefinition); if (WeavingFailed) { return(false); } if (modified) { PropertySiteProcessor.Process(moduleDefinition); // add class that holds read/write functions moduleDefinition.Types.Add(WeaveLists.generateContainerClass); ReaderWriterProcessor.InitializeReaderAndWriters(CurrentAssembly); // write to outputDir if specified, otherwise perform in-place write WriterParameters writeParams = new WriterParameters { WriteSymbols = true }; CurrentAssembly.Write(writeParams); } } return(true); }
public void TestOverloadedMethods() { var obj = new MultipleOverloadedMethodsClass(); var cecilType = CurrentAssembly.FindRuntimeType(typeof(MultipleOverloadedMethodsClass)); var met = Recompiler.RecompileMethod(cecilType.GetMethodByName("test")); var result = met.Invoke(this, new object[] { obj }); Assert.AreEqual(true, (bool)result); }
public void TestInnerAccess() { var obj = new TestClassA(); var cecilType = CurrentAssembly.FindRuntimeType(typeof(TestClassA)); var met2 = Recompiler.RecompileMethod(cecilType.GetMethodByName("dotest")); var result = met2.Invoke(this, new object[] { obj }); Assert.NotNull(obj.obj); Assert.AreEqual(1337, (int)result); }
static bool Weave(string assName, IEnumerable <string> dependencies) { using (DefaultAssemblyResolver asmResolver = new DefaultAssemblyResolver()) using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { asmResolver.AddSearchDirectory(Path.GetDirectoryName(assName)); asmResolver.AddSearchDirectory(Helpers.UnityEngineDllDirectoryName()); if (dependencies != null) { foreach (string path in dependencies) { asmResolver.AddSearchDirectory(path); } } WeaverTypes.SetupTargetTypes(CurrentAssembly); System.Diagnostics.Stopwatch rwstopwatch = System.Diagnostics.Stopwatch.StartNew(); ReaderWriterProcessor.Process(CurrentAssembly); rwstopwatch.Stop(); Console.WriteLine($"Find all reader and writers took {rwstopwatch.ElapsedMilliseconds} milliseconds"); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine($"Script Module: {moduleDefinition.Name}"); bool modified = WeaveModule(moduleDefinition); if (WeavingFailed) { return(false); } if (modified) { ReaderWriterProcessor.InitializeReaderAndWriters(CurrentAssembly); // write to outputDir if specified, otherwise perform in-place write WriterParameters writeParams = new WriterParameters { WriteSymbols = true }; CurrentAssembly.Write(writeParams); } } return(true); }
public void ViewOnFormLoad(object sender, EventArgs e) { _view.SaveEnabled = false; _view.AddStepEnabled = false; _view.ClearTreeNodes(); // is there a file path? if yes, get the library name and load it if (!string.IsNullOrEmpty(FilePath)) { var reader = new TestFileReader(_fileService); reader.LoadFile(FilePath); LibraryName = reader.GetLibraryName(); _view.TestCaseLines = _fileService.GetLines(FilePath).ToArray(); _view.SaveAsEnabled = true; } else { _fileBrowser.InitialDirectory = Environment.CurrentDirectory; if (_fileBrowser.ShowDialog()) { LibraryName = System.IO.Path.GetFileNameWithoutExtension(_fileBrowser.FileName); } else { //_view.Close(); _view.Result = DialogResult.Cancel; } _view.TestCaseLines = new string[] { }; _view.SaveAsEnabled = false; } SetTitle(); if (String.IsNullOrEmpty(LibraryName) == false && CurrentLibrary != LibraryName) { // need to load new step list CurrentAssembly = Assembly.Load(LibraryName); CurrentLibrary = LibraryName; StepClasses = CurrentAssembly.GetTypes().Where(t => Attribute.IsDefined(t, typeof(StepsAttribute))).ToList(); } // for the descriptions of the test steps LoadXml(); BuildTestStepTree(); _view.SaveEnabled = false; }
/// <summary> /// Gets XML schema by path. Loads, if the schema not found. /// </summary> /// <param name="path"></param> /// <returns></returns> protected XmlSchema GetXmlSchema(string path) { if (_schemas == null) { _schemas = new Dictionary <string, XmlSchema>(StringComparer.CurrentCultureIgnoreCase); } if (!_schemas.ContainsKey(path)) { Stream schemaStream = CurrentAssembly.GetManifestResourceStream(path); XmlSchema schema = XmlSchema.Read(schemaStream, null); schemaStream.Close(); _schemas.Add(path, schema); } return(_schemas[path]); }
public static List <Type> GetTypesWith <TAttribute>(bool bInherit) where TAttribute : Attribute { List <Type> AllTypes = new List <Type>(); Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly CurrentAssembly in Assemblies) { foreach (Type CurrentType in CurrentAssembly.GetTypes()) { if (CurrentType.IsDefined(typeof(TAttribute), bInherit)) { AllTypes.Add(CurrentType); } } } return(AllTypes); }
/// <summary> /// Gets the bytes of an embedded resource in your project. /// </summary> /// <param name="resourcePath">The filepath to the embedded resource in your project.</param> /// <returns>The bytes of the embedded resource.</returns> public static byte[] GetBytesFromResource(string resourcePath) { resourcePath = resourcePath.Replace("/", "."); resourcePath = resourcePath.Replace("\\", "."); if (CurrentAssembly == null) { Init(); } using (Stream stream = CurrentAssembly.GetManifestResourceStream(resourcePath)) { if (stream == null) { return(null); } byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); return(bytes); } }
public static List <Type> GetTypesInheritFrom <InheritType>(bool bExcludeTemplateType = true, bool bExcludeOpenTemplateTypes = true) { List <Type> AllTypes = new List <Type>(); Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly CurrentAssembly in Assemblies) { foreach (Type CurrentType in CurrentAssembly.GetTypes()) { if (typeof(InheritType).IsAssignableFrom(CurrentType) && (!bExcludeTemplateType || typeof(InheritType) != CurrentType) && (!bExcludeOpenTemplateTypes || !CurrentType.IsGenericTypeDefinition)) { AllTypes.Add(CurrentType); } } } return(AllTypes); }
private static void Main() { DevExpress.UserSkins.BonusSkins.Register( ); DevExpress.Skins.SkinManager.EnableFormSkins( ); string skinStyle = "Visual Studio 2013 Blue"; // "Metropolis Dark"; //if( true ) // skinStyle = "Office 2016 Colorful"; //else // skinStyle = "Visual Studio 2013 Blue"; DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(skinStyle); // Bitmap splashScreenImage = new Bitmap(CurrentAssembly.GetManifestResourceStream("FrontEnd.Resources.splashScreen.png")); DevExpress.XtraSplashScreen.SplashScreenManager.ShowImage(splashScreenImage, true, false); // Application.EnableVisualStyles( ); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1( )); }
private static void FindPluginCandidates(string embeddedPluginName, out Dictionary <Assembly, List <Type> > pluginClientTypeTable, OidCollection oidCheckList, ref int exitCode, ref bool isBadSignature) { Contract.RequireNotNull(Assembly.GetEntryAssembly(), out Assembly CurrentAssembly); string Location = CurrentAssembly.Location; Contract.RequireNotNull(Path.GetDirectoryName(Location), out string AppFolder); pluginClientTypeTable = new Dictionary <Assembly, List <Type> >(); Assembly? PluginAssembly; List <Type>?PluginClientTypeList; if (embeddedPluginName != null) { AssemblyName[] AssemblyNames = CurrentAssembly.GetReferencedAssemblies(); foreach (AssemblyName name in AssemblyNames) { if (name.Name == embeddedPluginName) { FindPluginClientTypesByName(name, oidCheckList, out PluginAssembly, out PluginClientTypeList, ref exitCode, ref isBadSignature); if (PluginAssembly != null && PluginClientTypeList != null && PluginClientTypeList.Count > 0) { pluginClientTypeTable.Add(PluginAssembly, PluginClientTypeList); } } } } string[] Assemblies = Directory.GetFiles(AppFolder, "*.dll"); foreach (string AssemblyPath in Assemblies) { FindPluginClientTypesByPath(AssemblyPath, oidCheckList, out PluginAssembly, out PluginClientTypeList, ref exitCode, ref isBadSignature); if (PluginAssembly != null && PluginClientTypeList != null) { if (!pluginClientTypeTable.ContainsKey(PluginAssembly)) { pluginClientTypeTable.Add(PluginAssembly, PluginClientTypeList); } } } }
static void Main() { //var s = Assembly.GetManifestResourceStream("POS.Resources.splashScreen.png"); //System.Reflection.Assembly s = this.GetType().Assembly; var ss = Assembly.GetExecutingAssembly().GetManifestResourceNames(); DevExpress.UserSkins.BonusSkins.Register(); DevExpress.Skins.SkinManager.EnableFormSkins(); DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Blue");// Visual Studio 2013 Blue Blue var splashScreenImage = new Bitmap(CurrentAssembly.GetManifestResourceStream("POS.Resources.SplashScreen.png")); DevExpress.XtraSplashScreen.SplashScreenManager.ShowImage(splashScreenImage, true, false); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-EG"); //Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-EG"); //Application.Run(new ssMain()); Application.Run(new frmMain()); }
static bool Weave(Assembly unityAssembly) { using (var asmResolver = new DefaultAssemblyResolver()) using (CurrentAssembly = AssemblyDefinition.ReadAssembly(unityAssembly.outputPath, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { AddPaths(asmResolver, unityAssembly); WeaverTypes.SetupTargetTypes(CurrentAssembly); var rwstopwatch = System.Diagnostics.Stopwatch.StartNew(); ReaderWriterProcessor.Process(CurrentAssembly, unityAssembly); rwstopwatch.Stop(); Console.WriteLine($"Find all reader and writers took {rwstopwatch.ElapsedMilliseconds} milliseconds"); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine($"Script Module: {moduleDefinition.Name}"); bool modified = WeaveModule(moduleDefinition); if (WeavingFailed) { return(false); } if (modified) { ReaderWriterProcessor.InitializeReaderAndWriters(CurrentAssembly); // write to outputDir if specified, otherwise perform in-place write var writeParams = new WriterParameters { WriteSymbols = true }; CurrentAssembly.Write(writeParams); } } return(true); }
public void TestGenericClasses() { var obj1 = new GenericDerivedClass1(); var obj2 = new GenericDerivedClass2(); var cecilType1 = CurrentAssembly.FindRuntimeType(typeof(GenericDerivedClass1)); var cecilType2 = CurrentAssembly.FindRuntimeType(typeof(GenericDerivedClass2)); obj1.add(); obj2.add(); obj2.add(); var met = Recompiler.RecompileMethod(cecilType1.GetMethodByName("test")); var result = met.Invoke(obj1, new object[] { obj1 }); Assert.IsTrue((bool)result); met = Recompiler.RecompileMethod(cecilType2.GetMethodByName("test")); result = met.Invoke(obj2, new object[] { obj2 }); //obj2 was added twice. Test if target method bound to proper field Assert.IsTrue((bool)result); }
/// <summary> /// Attempt to convert the given <see cref="TypeReference"/> to /// a <see cref="Type"/>. /// </summary> public static Type AsType(this TypeReference typeRef) { Type t = CurrentAssembly.GetType(typeRef.Namespace + "." + typeRef.Name); if (t == null && Assemblies.ContainsKey(typeRef.Module.Assembly.Name.Name)) { t = Assemblies[typeRef.Module.Assembly.Name.Name].Item1.GetType(typeRef.Namespace + '.' + typeRef.Name); } if (t == null && Assemblies.ContainsKey(typeRef.Scope.Name)) { t = Assemblies[typeRef.Scope.Name].Item1.GetType(typeRef.Namespace + '.' + typeRef.Name); } if (t == null) { return(null); } if (typeRef is GenericInstanceType) { t = t.MakeGenericType(((GenericInstanceType)typeRef).GenericArguments.Select(x => x.AsType()).ToArray()); } return(t); }
static bool Weave(string assName, AssemblyDefinition unityAssembly, AssemblyDefinition mirrorAssembly, IEnumerable <string> dependencies, string unityEngineDLLPath, string mirrorNetDLLPath, string outputDir) { using (DefaultAssemblyResolver asmResolver = new DefaultAssemblyResolver()) using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { asmResolver.AddSearchDirectory(Path.GetDirectoryName(assName)); asmResolver.AddSearchDirectory(Helpers.UnityEngineDllDirectoryName()); asmResolver.AddSearchDirectory(Path.GetDirectoryName(unityEngineDLLPath)); asmResolver.AddSearchDirectory(Path.GetDirectoryName(mirrorNetDLLPath)); if (dependencies != null) { foreach (string path in dependencies) { asmResolver.AddSearchDirectory(path); } } WeaverTypes.SetupTargetTypes(unityAssembly, mirrorAssembly, CurrentAssembly); System.Diagnostics.Stopwatch rwstopwatch = System.Diagnostics.Stopwatch.StartNew(); ReaderWriterProcessor.Process(CurrentAssembly); rwstopwatch.Stop(); Console.WriteLine("Find all reader and writers took " + rwstopwatch.ElapsedMilliseconds + " milliseconds"); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine("Script Module: {0}", moduleDefinition.Name); bool modified = WeaveModule(moduleDefinition); if (WeavingFailed) { return(false); } if (modified) { // this must be done for ALL code, not just NetworkBehaviours try { PropertySiteProcessor.Process(moduleDefinition); } catch (Exception e) { Log.Error("ProcessPropertySites exception: " + e); return(false); } if (WeavingFailed) { return(false); } // write to outputDir if specified, otherwise perform in-place write WriterParameters writeParams = new WriterParameters { WriteSymbols = true }; if (!string.IsNullOrEmpty(outputDir)) { CurrentAssembly.Write(Helpers.DestinationFileFor(outputDir, assName), writeParams); } else { CurrentAssembly.Write(writeParams); } } } return(true); }
public static T GetAttribute <T>() { return((T)CurrentAssembly.GetCustomAttributes(typeof(T), false).FirstOrDefault()); }
protected override void Awake() { CurrentAssembly = Assembly.GetExecutingAssembly(); Types = CurrentAssembly.GetTypes(); base.Awake(); }
static bool Weave(string assName, IEnumerable <string> dependencies, IAssemblyResolver assemblyResolver, string unityEngineDLLPath, string mirrorNetDLLPath, string outputDir) { using (DefaultAssemblyResolver asmResolver = new DefaultAssemblyResolver()) using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { asmResolver.AddSearchDirectory(Path.GetDirectoryName(assName)); asmResolver.AddSearchDirectory(Helpers.UnityEngineDLLDirectoryName()); asmResolver.AddSearchDirectory(Path.GetDirectoryName(unityEngineDLLPath)); asmResolver.AddSearchDirectory(Path.GetDirectoryName(mirrorNetDLLPath)); if (dependencies != null) { foreach (string path in dependencies) { asmResolver.AddSearchDirectory(path); } } SetupTargetTypes(); Readers.Init(CurrentAssembly); Writers.Init(CurrentAssembly); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine("Script Module: {0}", moduleDefinition.Name); // Process each NetworkBehaviour bool didWork = false; // We need to do 2 passes, because SyncListStructs might be referenced from other modules, so we must make sure we generate them first. for (int pass = 0; pass < 2; pass++) { System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew(); foreach (TypeDefinition td in moduleDefinition.Types) { if (td.IsClass && td.BaseType.CanBeResolved()) { try { if (pass == 0) { didWork |= CheckSyncList(td); } else { didWork |= CheckNetworkBehaviour(td); didWork |= CheckMessageBase(td); } } catch (Exception ex) { Weaver.Error(ex.Message); throw ex; } } if (WeavingFailed) { return(false); } } watch.Stop(); Console.WriteLine("Pass: "******" took " + watch.ElapsedMilliseconds + " milliseconds"); } if (didWork) { // this must be done for ALL code, not just NetworkBehaviours try { PropertySiteProcessor.ProcessSitesModule(CurrentAssembly.MainModule); } catch (Exception e) { Log.Error("ProcessPropertySites exception: " + e); return(false); } if (WeavingFailed) { //Log.Error("Failed phase II."); return(false); } // write to outputDir if specified, otherwise perform in-place write WriterParameters writeParams = new WriterParameters { WriteSymbols = true }; if (outputDir != null) { CurrentAssembly.Write(Helpers.DestinationFileFor(outputDir, assName), writeParams); } else { CurrentAssembly.Write(writeParams); } } } return(true); }
static bool Weave(string assName, IEnumerable <string> dependencies) { using (DefaultAssemblyResolver asmResolver = new DefaultAssemblyResolver()) using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, new ReaderParameters { ReadWrite = true, ReadSymbols = true, AssemblyResolver = asmResolver })) { asmResolver.AddSearchDirectory(Path.GetDirectoryName(assName)); asmResolver.AddSearchDirectory(Helpers.UnityEngineDllDirectoryName()); if (dependencies != null) { foreach (string path in dependencies) { asmResolver.AddSearchDirectory(path); } } // fix "No writer found for ..." error // https://github.com/vis2k/Mirror/issues/2579 // -> when restarting Unity, weaver would try to weave a DLL // again // -> resulting in two GeneratedNetworkCode classes (see ILSpy) // -> the second one wouldn't have all the writer types setup if (ContainsGeneratedCodeClass(CurrentAssembly.MainModule)) { //Log.Warning($"Weaver: skipping {CurrentAssembly.Name} because already weaved"); return(true); } WeaverTypes.SetupTargetTypes(CurrentAssembly); CreateGeneratedCodeClass(); // WeaverList depends on WeaverTypes setup because it uses Import WeaveLists = new WeaverLists(); System.Diagnostics.Stopwatch rwstopwatch = System.Diagnostics.Stopwatch.StartNew(); // Need to track modified from ReaderWriterProcessor too because it could find custom read/write functions or create functions for NetworkMessages bool modified = ReaderWriterProcessor.Process(CurrentAssembly); rwstopwatch.Stop(); Console.WriteLine($"Find all reader and writers took {rwstopwatch.ElapsedMilliseconds} milliseconds"); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine($"Script Module: {moduleDefinition.Name}"); modified |= WeaveModule(moduleDefinition); if (WeavingFailed) { return(false); } if (modified) { PropertySiteProcessor.Process(moduleDefinition); // add class that holds read/write functions moduleDefinition.Types.Add(GeneratedCodeClass); ReaderWriterProcessor.InitializeReaderAndWriters(CurrentAssembly); // write to outputDir if specified, otherwise perform in-place write WriterParameters writeParams = new WriterParameters { WriteSymbols = true }; CurrentAssembly.Write(writeParams); } } return(true); }
static bool Weave(string assName, IEnumerable <string> dependencies, IAssemblyResolver assemblyResolver, string unityEngineDLLPath, string mirrorNetDLLPath, string outputDir) { ReaderParameters readParams = Helpers.ReaderParameters(assName, dependencies, assemblyResolver, unityEngineDLLPath, mirrorNetDLLPath); using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, readParams)) { SetupTargetTypes(); Readers.Init(CurrentAssembly); Writers.Init(CurrentAssembly); ModuleDefinition moduleDefinition = CurrentAssembly.MainModule; Console.WriteLine("Script Module: {0}", moduleDefinition.Name); // Process each NetworkBehaviour bool didWork = false; // We need to do 2 passes, because SyncListStructs might be referenced from other modules, so we must make sure we generate them first. for (int pass = 0; pass < 2; pass++) { System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew(); foreach (TypeDefinition td in moduleDefinition.Types) { if (td.IsClass && td.BaseType.CanBeResolved()) { try { if (pass == 0) { didWork |= CheckSyncList(td); } else { didWork |= CheckNetworkBehaviour(td); didWork |= CheckMessageBase(td); } } catch (Exception ex) { if (CurrentAssembly.MainModule.SymbolReader != null) { CurrentAssembly.MainModule.SymbolReader.Dispose(); } Weaver.Error(ex.Message); throw ex; } } if (WeavingFailed) { if (CurrentAssembly.MainModule.SymbolReader != null) { CurrentAssembly.MainModule.SymbolReader.Dispose(); } return(false); } } watch.Stop(); Console.WriteLine("Pass: "******" took " + watch.ElapsedMilliseconds + " milliseconds"); } if (didWork) { // this must be done for ALL code, not just NetworkBehaviours try { PropertySiteProcessor.ProcessSitesModule(CurrentAssembly.MainModule); } catch (Exception e) { Log.Error("ProcessPropertySites exception: " + e); if (CurrentAssembly.MainModule.SymbolReader != null) { CurrentAssembly.MainModule.SymbolReader.Dispose(); } return(false); } if (WeavingFailed) { //Log.Error("Failed phase II."); if (CurrentAssembly.MainModule.SymbolReader != null) { CurrentAssembly.MainModule.SymbolReader.Dispose(); } return(false); } string dest = Helpers.DestinationFileFor(outputDir, assName); //Console.WriteLine ("Output:" + dest); WriterParameters writeParams = Helpers.GetWriterParameters(readParams); CurrentAssembly.Write(dest, writeParams); } if (CurrentAssembly.MainModule.SymbolReader != null) { CurrentAssembly.MainModule.SymbolReader.Dispose(); } } return(true); }