/// <summary> /// DO NOT MODIFY THIS METHOD! /// THIS METHOD IS USED FOR GENERATE CALLBACK INVOCATION! /// </summary> /// <param name="output">OUTPUT PATH</param> public static void Build(string output) { var options = new StubOptions { stubName = "MiniGameAdaptor", outputPath = output, whiteList = WhiteList, namespaceInterceptor = type => { // 不允许没有 Namespace if (type == null) { return(Utils.NamespaceName); } var ns = type.Namespace; if (string.IsNullOrEmpty(ns)) { return(Utils.NamespaceName); } // 如果是 UnityEngine 替换成 MiniGameAdaptor if (!ns.Contains("UnityEngine")) { return(null); } return(Utils.EscapeNamespace(ns)); } }; StubBuilder.Build(options); }
/// <summary> /// DO NOT MODIFY THIS METHOD /// THIS METHOD IS USED TO GENERATE CALLBACK INVOCATION /// </summary> /// <param name="output">OUTPUT PATH</param> public static void Build(string output) { var options = new StubOptions { stubName = "MiniGameAdaptor", outputPath = output, whiteList = WhiteList }; StubBuilder.Build(options); }
private static void GeneratePluginRefStubCs(string stubName, string output, Assembly assembly) { StubBuilder.Build(new StubOptions { stubName = stubName, outputPath = output, whiteList = assembly.ExportedTypes, filter = t => { if (t == null) { return(false); } if (assembly.ExportedTypes.Contains(t)) { return(true); } return(assembly.ExportedTypes.Contains(t.DeclaringType)); } }); }
private static void GeneratePluginStubCs(UnityPlugin plugin) { if (!plugin.enable) { return; } var output = plugin.stubPath.stubCSPath; var dll = plugin.stubPath.stubDLLPath.Replace("-stub.dll", "-internal.dll"); if (dll == null || dll == "") { return; } try { var assembly = Assembly.LoadFile(dll); StubBuilder.Build(new StubOptions { stubName = plugin.pluginName, outputPath = output, whiteList = assembly.ExportedTypes, filter = t => { if (t == null) { return(false); } if (assembly.ExportedTypes.Contains(t)) { return(true); } return(assembly.ExportedTypes.Contains(t.DeclaringType)); }, namespaceInterceptor = type => { // 不允许没有 Namespace if (type == null) { return(Utils.NamespaceName); } var ns = type.Namespace; if (string.IsNullOrEmpty(ns)) { return(Utils.NamespaceName); } return(null); } }); } catch (FileNotFoundException e) { Debug.LogError(dll + " not exists"); } catch (Exception ex) { Debug.LogError(ex); } // header var allRefContent = string.Format(topHeader, plugin.pluginName); string content = ""; using (StreamReader sr = new StreamReader(output)) { content = sr.ReadToEnd(); } if (content == null || content == "" || content.Length == 0) { return; } using (var sw = new StreamWriter(output, false)) { sw.Write(allRefContent); sw.Write(content); } }