public void AddMultipleItemsShouldBuildMultiples()
 {
     var subject = new ArgumentBuilder("/", ":");
     subject.AddArgument("references", "ref1");
     subject.AddArgument("references", "ref2");
     Assert.That(subject.Build(), Is.EqualTo("/references:ref1 /references:ref2"));
 }
Beispiel #2
0
 public static ExecutionResults ExecuteIn(string workingDirectory,
     string exec = null, string execArgs = null, string projectFile = null, string projectArgs = null,
     bool isTeamCity = false)
 {
     var logFile = Path.Combine(workingDirectory, "log.txt");
     var args = new ArgumentBuilder(workingDirectory, exec, execArgs, projectFile, projectArgs, logFile, isTeamCity);
     return ExecuteIn(args);
 }
Beispiel #3
0
    static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
    {
        var gitVersion = Path.Combine(PathHelper.GetCurrentDirectory(), "GitVersion.exe");
        var output = new StringBuilder();

        Console.WriteLine("Executing: {0} {1}", gitVersion, arguments);
        Console.WriteLine();
        var environmentalVariables =
            new[]
            {
                new KeyValuePair<string, string>(TeamCity.EnvironmentVariableName, arguments.IsTeamCity ? "8.0.0" : null),
                new KeyValuePair<string, string>(AppVeyor.EnvironmentVariableName, null),
                new KeyValuePair<string, string>(TravisCI.EnvironmentVariableName, null),
            };

        var exitCode = -1;

        try
        {
            exitCode = ProcessHelper.Run(
                s => output.AppendLine(s), s => output.AppendLine(s), null,
                gitVersion, arguments.ToString(), arguments.WorkingDirectory,
                environmentalVariables);
        }
        catch (Exception exception)
        {
            // NOTE: It's the exit code and output from the process we want to test,
            //       not the internals of the ProcessHelper. That's why we're catching
            //       any exceptions here, because problems in the process being executed
            //       should be visible in the output or exit code. @asbjornu
            Console.WriteLine(exception);
        }

        Console.WriteLine("Output from GitVersion.exe");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(output.ToString());
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        if (string.IsNullOrWhiteSpace(arguments.LogFile) || !File.Exists(arguments.LogFile))
        {
            return new ExecutionResults(exitCode, output.ToString(), null);
        }

        var logContents = File.ReadAllText(arguments.LogFile);
        Console.WriteLine("Log from GitVersion.exe");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(logContents);
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        return new ExecutionResults(exitCode, output.ToString(), logContents);
    }
Beispiel #4
0
        public FileSet Execute()
        {
            string resGenExecutable = GetPathToResGenExecutable();

            var outputFiles = new FileSet();
            foreach (string resourceFileName in Files.Files)
            {
                string outputFileName = Prefix + Path.GetFileNameWithoutExtension(resourceFileName) + ".resources";
                outputFileName = Path.Combine(OutputFolder, outputFileName);
                outputFiles.Include(outputFileName);
                var builder = new ArgumentBuilder();
                builder.StartOfEntireArgumentString = "\"" + resourceFileName + "\" \"" + outputFileName + "\"";
                _actionExcecutor.Execute<Executable>(x=>x.ExecutablePath(resGenExecutable).UseArgumentBuilder(builder));
            }
            return outputFiles;
        }
    static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
    {
        var gitVersion = Path.Combine(PathHelper.GetCurrentDirectory(), "GitVersion.exe");
        var output = new StringBuilder();

        Console.WriteLine("Executing: {0} {1}", gitVersion, arguments);
        Console.WriteLine();
        var environmentalVariables =
            new[]
            {
                new KeyValuePair<string, string>("TEAMCITY_VERSION", arguments.IsTeamCity ? "8.0.0" : null),
                new KeyValuePair<string, string>("APPVEYOR", null)
            };

        var exitCode = ProcessHelper.Run(
            s => output.AppendLine(s), s => output.AppendLine(s), null,
            gitVersion, arguments.ToString(), arguments.WorkingDirectory,
            environmentalVariables);

        Console.WriteLine("Output from GitVersion.exe");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(output.ToString());
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        if (string.IsNullOrWhiteSpace(arguments.LogFile) || !File.Exists(arguments.LogFile))
        {
            return new ExecutionResults(exitCode, output.ToString(), null);
        }

        var logContents = File.ReadAllText(arguments.LogFile);
        Console.WriteLine("Log from GitVersion.exe");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(logContents);
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        return new ExecutionResults(exitCode, output.ToString(), logContents);
    }
Beispiel #6
0
 /// <inheritdoc />
 public ICli SetArguments(ArgumentBuilder argbuilder)
 {
     _arguments = argbuilder.Render();
     return(this);
 }
Beispiel #7
0
        private void AddReference(ArgumentBuilder arguments, ProjectItem reference, string rootPath)
        {
            string referencePath = reference.Include;

            arguments.Add("reference", referencePath);
        }
Beispiel #8
0
        private void RunFunctionalTests()
        {
            //Copy sample folder to compile directory
            var sampleData = directory_base.SubFolder("tests").SubFolder("FluentBuild.Tests").SubFolder("Samples");
            var builder = new ArgumentBuilder("/", ":");
            builder.StartOfEntireArgumentString = sampleData.ToString() + " " + directory_compile.SubFolder("Samples");
            builder.AddArgument("E");
            builder.AddArgument("I");
            Task.Run.Executable(x=>x.ExecutablePath(@"C:\Windows\System32\xcopy.exe").UseArgumentBuilder(builder));
            var configSource = directory_base.SubFolder("tests").SubFolder("FluentBuild.Tests").File("app.config.template");
            var configDestination = directory_compile.File("FluentBuild_Functional_Tests.dll.config");
            configSource.Copy
                .ReplaceToken("RelativeRoot").With("..\\")
                .ReplaceToken("RelativeSamples").With(@"Samples")
                .To(configDestination.ToString());

            Task.Run.UnitTestFramework.Nunit(x => x.FileToTest(assembly_Functional_Tests));
        }
Beispiel #9
0
 internal NUnitRunner(IExecutable executable, IFileSystemHelper fileSystemHelper)
 {
     _executable       = executable;
     _fileSystemHelper = fileSystemHelper;
     _argumentBuilder  = new ArgumentBuilder("/", ":");
 }
Beispiel #10
0
        public static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language,
            bool encryptArguments)
        {
            Log.Information($"XivGame::LaunchGame(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})");

            try
            {
                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamNative.Initialize();

                        if (SteamApi.IsSteamRunning() && SteamApi.Initialize(STEAM_APP_ID))
                            Log.Information("Steam initialized.");
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not initialize Steam.");
                    }
                }

                var exePath = gamePath + "/game/ffxiv_dx11.exe";
                if (!isDx11)
                    exePath = gamePath + "/game/ffxiv.exe";

                var environment = new Dictionary<string, string>();

                var argumentBuilder = new ArgumentBuilder()
                    .Append("DEV.DataPathType", "1")
                    .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                    .Append("DEV.TestSID", sessionId)
                    .Append("DEV.UseSqPack", "1")
                    .Append("SYS.Region", region.ToString())
                    .Append("language", ((int)language).ToString())
                    .Append("ver", Repository.Ffxiv.GetVer(gamePath));

                if (isSteamServiceAccount)
                {
                    // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
                    environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
                    argumentBuilder.Append("IsSteam", "1");
                }

                // This is a bit of a hack; ideally additionalArguments would be a dictionary or some KeyValue structure
                if (!string.IsNullOrEmpty(additionalArguments))
                {
                    var regex = new Regex(@"\s*(?<key>[^=]+)\s*=\s*(?<value>[^\s]+)\s*", RegexOptions.Compiled);
                    foreach (Match match in regex.Matches(additionalArguments))
                        argumentBuilder.Append(match.Groups["key"].Value, match.Groups["value"].Value);
                }


                var workingDir = Path.Combine(gamePath.FullName, "game");

                Process game;
                try
                {
                    var arguments = encryptArguments
                        ? argumentBuilder.BuildEncrypted()
                        : argumentBuilder.Build();
                    game = NativeAclFix.LaunchGame(workingDir, exePath, arguments, environment);
                }
                catch (Win32Exception ex)
                {
                    CustomMessageBox.Show(
                        "Could not start the game correctly. Please report this error.", "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    Log.Error(ex, $"NativeLauncher error; {ex.NativeErrorCode}: {ex.Message}");

                    return null;
                }

                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamApi.Uninitialize();
                        SteamNative.Uninitialize();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not uninitialize Steam.");
                    }
                }

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                        throw new Exception("Game exited prematurely");

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    break;
                }

                return game;
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.",
                    "XG LaunchGame").ShowDialog();
            }

            return null;
        }
    private static ExecutionResults ExecuteIn(ArgumentBuilder arguments,
                                              params KeyValuePair <string, string?>[] environments
                                              )
    {
        var executable = ExecutableHelper.GetExecutable();
        var output     = new StringBuilder();

        var environmentalVariables = new Dictionary <string, string?>
        {
            { TeamCity.EnvironmentVariableName, null },
            { AppVeyor.EnvironmentVariableName, null },
            { TravisCi.EnvironmentVariableName, null },
            { Jenkins.EnvironmentVariableName, null },
            { AzurePipelines.EnvironmentVariableName, null },
            { GitHubActions.EnvironmentVariableName, null },
            { SpaceAutomation.EnvironmentVariableName, null }
        };

        foreach (var(key, value) in environments)
        {
            if (environmentalVariables.ContainsKey(key))
            {
                environmentalVariables[key] = value;
            }
            else
            {
                environmentalVariables.Add(key, value);
            }
        }

        var exitCode = -1;

        try
        {
            var args = ExecutableHelper.GetExecutableArgs(arguments.ToString());

            Console.WriteLine("Executing: {0} {1}", executable, args);
            Console.WriteLine();

            exitCode = ProcessHelper.Run(
                s => output.AppendLine(s),
                s => output.AppendLine(s),
                null,
                executable,
                args,
                arguments.WorkingDirectory,
                environmentalVariables.ToArray());
        }
        catch (Exception exception)
        {
            // NOTE: It's the exit code and output from the process we want to test,
            //       not the internals of the ProcessHelper. That's why we're catching
            //       any exceptions here, because problems in the process being executed
            //       should be visible in the output or exit code. @asbjornu
            Console.WriteLine(exception);
        }

        Console.WriteLine("Output from gitversion tool");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(output.ToString());
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        if (arguments.LogFile.IsNullOrWhiteSpace() || !File.Exists(arguments.LogFile))
        {
            return(new ExecutionResults(exitCode, output.ToString(), null));
        }

        var logContents = File.ReadAllText(arguments.LogFile);

        Console.WriteLine("Log from gitversion tool");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(logContents);
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        return(new ExecutionResults(exitCode, output.ToString(), logContents));
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            accountingMasterPage = (AccountingMasterPage)Page.Master;
            accountingMasterPage.InitializeMasterPageComponents();

            if (!Authorization.AuthorizedAsAdministrator(Session))
            {
                // Mostra aviso de falta de autorização
                ShowWarning(Authorization.GetWarning());
                return;
            }

            // action:
            //    null -  Sem ação, apenas lista os dispositivos
            //    0    -  Excluir dispositivo, lista os restantes
            int?action   = null;
            int?deviceId = null;

            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["action"]))
                {
                    action = int.Parse(Request.QueryString["action"]);
                }

                if (!String.IsNullOrEmpty(Request.QueryString["deviceId"]))
                {
                    deviceId = int.Parse(Request.QueryString["deviceId"]);
                }
            }
            catch (System.FormatException)
            {
                // Remove todos os controles da página
                configurationArea.Controls.Clear();
                controlArea.Controls.Clear();

                // Mostra aviso de inconsistência nos parâmetros
                WarningMessage.Show(controlArea, ArgumentBuilder.GetWarning());
                return;
            }

            Tenant tenant = (Tenant)Session["tenant"];

            printingDeviceDAO = new PrintingDeviceDAO(accountingMasterPage.dataAccess.GetConnection());

            if (deviceId != null)
            {
                switch (action)
                {
                case 0:
                    printingDeviceDAO.RemovePrintingDevice(deviceId.Value);
                    Response.Redirect("PageCounters.aspx");      // Limpa a QueryString para evitar erros
                    break;

                default:
                    break;
                }
            }

            List <Object> deviceList = printingDeviceDAO.GetAllPrintingDevices(tenant.id);

            String[] columnNames  = new String[] { "Endereço IP", "Descrição", "Número de série", "Contador", "Atualizado Em" };
            String   viewScript   = "window.open('PageCounterHistory.aspx?deviceId=' + {0}, 'Histórico do contador', 'width=540,height=600');";
            String   removeScript = "var confirmed = confirm('Deseja realmente excluir este dispositivo?'); if (confirmed) window.location='PageCounters.aspx?action=0&deviceId=' + {0};";

            EditableListButton[] buttons = new EditableListButton[]
            {
                // Botões que devem aparecer para os items da lista
                new EditableListButton("Histórico", viewScript, ButtonTypeEnum.Edit),
                new EditableListButton("Excluir", removeScript, ButtonTypeEnum.Remove)
            };
            EditableList editableList = new EditableList(configurationArea, columnNames, buttons);

            foreach (PrintingDevice device in deviceList)
            {
                String[] deviceProperties = new String[]
                {
                    device.ipAddress,
                    device.description,
                    device.serialNumber,
                    device.counter.ToString(),
                    String.Format("{0:dd/MM/yyyy HH:mm}", device.lastUpdated)
                };
                editableList.InsertItem(device.id, false, deviceProperties);
            }
            editableList.DrawList();
        }
Beispiel #13
0
        public CommandDefinition GenerateNewCommandDefinition(Entity templateEntity, TemplateDescription description,
                                                              CommandDefinition baseCommand,
                                                              IEnumerable <TemplateDescription> otherTemplates)
        {
            otherTemplates = otherTemplates.ToArray();
            CommandDefinitionBuilder builder = CommandDefinitionBuilder.Create()
                                               .SetName(description.name.ToLowerInvariant())
                                               .SetHelp(resolver.Resolve(description.Description ?? string.Empty,
                                                                         templateEntity))
                                               .SetBaseDefintion(baseCommand);
            List <char> shortNames = new List <char>(new [] { 'f' });

            foreach (templateArgumentDefinition argument in description.Arguments ?? Enumerable.Empty <templateArgumentDefinition>())
            {
                GenerateArgumentFromDefinition(templateEntity, builder, argument, shortNames);
            }

            foreach (templateRelationship relationship in description.Relationship ?? Enumerable.Empty <templateRelationship>())
            {
                if (otherTemplates.FirstOrDefault(t => t.name.Equals(relationship.@type,
                                                                     StringComparison.OrdinalIgnoreCase))
                    ?.isRoot == true)
                {
                    continue;
                }
                ArgumentType argumentType = relationship.multiplicity == multiplicity.One
                                                ? ArgumentType.SingleValue
                                                : ArgumentType.MultipleValue;

                ArgumentBuilder argBuilder = builder.CreateArgument()
                                             .SetName(relationship.name)
                                             .SetArgumentType(argumentType)
                                             .SetMandatory()
                                             .SetHelp(
                    $"Specifies the {relationship.name} of the {description.name}. " +
                    $"The {relationship.name} must be an " +
                    $"existing {relationship.type}.");
                char shortName = relationship.name[0];
                if (!shortNames.Contains(shortName))
                {
                    shortNames.Add(shortName);
                    argBuilder.SetShortName(shortName);
                }

                argBuilder.Build();
            }

            foreach (templateExample example in description.Example ?? Enumerable.Empty <templateExample>())
            {
                StringBuilder command = new StringBuilder($"new {description.name.ToLowerInvariant()}");
                ParseExample(description, example, command);

                builder.AddExample(command.ToString(), example.Description ?? string.Empty);
            }

            builder.CreateArgument()
            .SetName(ForcedArgumentName)
            .SetShortName('f')
            .SetArgumentType(ArgumentType.Bool)
            .SetHelp("Overrides existing files when encountered.")
            .Build();

            return(builder.Build());
        }
Beispiel #14
0
 public IExecutable UseArgumentBuilder(ArgumentBuilder argumentBuilder)
 {
     _argumentBuilder = argumentBuilder;
     return(this);
 }
Beispiel #15
0
 internal ILMerge(IFileSystemHelper fileSystemHelper)
 {
     _fileSystemHelper = fileSystemHelper;
     Sources           = new List <string>();
     _argumentBuilder  = new ArgumentBuilder();
 }
Beispiel #16
0
        protected ArgumentBuilder ToArgumentBuilder()
        {
            ArgumentBuilder builder;

            builder = new ArgumentBuilder();
            builder.AppendUnityArguments(
                "-batchmode",
                "-quit");
            if (this._logFile != null)
                builder.AppendUnityArguments(
                    "-logFile",
                    this._logFile);
            if (this._projectPath == null)
                throw new NullReferenceException();
            builder.AppendUnityArguments(
                "-projectPath",
                this._projectPath);
            builder.AppendUnityArguments(
                "-executeMethod",
                "UnityStack.Editor.Runner.Batch");
            return builder;
        }
Beispiel #17
0
 protected override IArgument BuildArgument(string name, string value) =>
 ArgumentBuilder.Build(name, value);
Beispiel #18
0
 protected override void SetAdditionalArguments(ArgumentBuilder builder)
 {
     base.SetAdditionalArguments(builder);
     DefineConstant(builder, "DEBUGGEE_COMPILER", "Clang");
 }
Beispiel #19
0
        private void BuildCommandLineArguments(BuildEnvironment environment, Csc csc, ArgumentBuilder arguments)
        {
            if (AllowUnsafeBlocks(environment, csc))
            {
                arguments.Flag("unsafe");
            }

            arguments.Add("debug", GetDebugType(environment, csc));
            if (EmitDebugInformation(environment, csc))
            {
                arguments.Flag("debug+");
            }

            if (!Optimize(environment, csc))
            {
                arguments.Flag("optimize-");
            }

            var baseAddress = GetBaseAddress(environment, csc);

            if (!string.IsNullOrEmpty(baseAddress))
            {
                arguments.Add("baseaddress", baseAddress);
            }

            arguments.Add("define", GetDefines(environment, csc));
            arguments.Add("nowarn", GetDisabledWarnings(environment, csc));

            if (GetNoLogo(environment, csc))
            {
                arguments.Flag("nologo");
            }

            arguments.Add("target", GetTarget(environment, csc));
            arguments.Add("errorreport", GetErrorReport(environment, csc));
            arguments.Add("platform", GetPlatform(environment, csc));

            if (ErrorEndLocation(environment, csc))
            {
                arguments.Flag("errorendlocation");
            }

            arguments.Add("filealign", GetFileAlignment(environment, csc));

            if (HighEntropyVA(environment, csc))
            {
                arguments.Flag("highentropyva+");
            }

            arguments.Add("out", GetOutputAssembly(environment, csc));

            arguments.Flag("nostdlib+");

            var rootPath   = environment.Properties[Properties.MSBuildProjectDirectory];
            var references = _expressionEngine.EvaluateItemList(csc.References, environment);

            foreach (var reference in references)
            {
                AddReference(arguments, reference, rootPath);
            }

            var resources = _expressionEngine.EvaluateItemList(csc.Resources, environment);

            foreach (var resource in resources)
            {
                var include      = resource.Include;
                var resourceName = string.Format("EmbeddedResource.{0}", include.Replace('\\', '.'));
                arguments.Add("resource", resource.Include, resourceName);
            }

            var sources = _expressionEngine.EvaluateItemList(csc.Sources, environment);

            foreach (var source in sources)
            {
                arguments.Add(source.Include);
            }

            string outputPath = environment.Properties[Properties.OutputPath];

            _fileSystem.CreateDirectory(outputPath);

            // http://stackoverflow.com/questions/19306194/process-launch-exception-filename-or-extension-is-too-long-can-it-be-caused-b
            int commandLineLength = arguments.Length + CompilerPath.Length + 1;

            if (commandLineLength > 32000)             //< The maximum length seems to be 32768, but this one's close enough
            {
                // In order to not exceed the limit we'll have to write the arguments
                // to a file that is then passes as an argument to csc (so that's why that option exists).
                var filename = Path.Combine(outputPath, "csc_arguments.txt");
                File.WriteAllText(filename, arguments.ToString());
                arguments.Clear();

                arguments.Add(string.Format("\"@{0}\"", filename));
            }

            // without this, csc automatically references a bunch of assemblies and then gives us shit
            // that we've included a double reference...
            arguments.Flag("noconfig");
        }
Beispiel #20
0
 private static void addFunction(FunctionCode code, ArgumentBuilder arg)
 {
     addFunction(code, arg, 0);
 }
        private void LoadFileHistory()
        {
            FileChanges.Visible = true;

            if (string.IsNullOrEmpty(FileName))
            {
                return;
            }

            _asyncLoader.LoadAsync(
                () => BuildFilter(),
                filter =>
            {
                FileChanges.SetFilters(filter);
                FileChanges.Load();
            });

            return;

            (string revision, string path) BuildFilter()
            {
                var fileName = FileName;

                // Replace windows path separator to Linux path separator.
                // This is needed to keep the file history working when started from file tree in
                // browse dialog.
                fileName = fileName.ToPosixPath();

                // we will need this later to look up proper casing for the file
                var fullFilePath = _fullPathResolver.Resolve(fileName);

                // The section below contains native windows (kernel32) calls
                // and breaks on Linux. Only use it on Windows. Casing is only
                // a Windows problem anyway.
                if (EnvUtils.RunningOnWindows() && File.Exists(fullFilePath))
                {
                    // grab the 8.3 file path
                    var shortPath = new StringBuilder(4096);
                    NativeMethods.GetShortPathName(fullFilePath, shortPath, shortPath.Capacity);

                    // use 8.3 file path to get properly cased full file path
                    var longPath = new StringBuilder(4096);
                    NativeMethods.GetLongPathName(shortPath.ToString(), longPath, longPath.Capacity);

                    // remove the working directory and now we have a properly cased file name.
                    fileName = longPath.ToString().Substring(Module.WorkingDir.Length).ToPosixPath();
                }

                if (fileName.StartsWith(Module.WorkingDir, StringComparison.InvariantCultureIgnoreCase))
                {
                    fileName = fileName.Substring(Module.WorkingDir.Length);
                }

                FileName = fileName;

                var res = (revision : (string)null, path : $" \"{fileName}\"");

                if (AppSettings.FollowRenamesInFileHistory && !Directory.Exists(fullFilePath))
                {
                    // git log --follow is not working as expected (see  http://kerneltrap.org/mailarchive/git/2009/1/30/4856404/thread)
                    //
                    // But we can take a more complicated path to get reasonable results:
                    //  1. use git log --follow to get all previous filenames of the file we are interested in
                    //  2. use git log "list of files names" to get the history graph
                    //
                    // note: This implementation is quite a quick hack (by someone who does not speak C# fluently).
                    //

                    var args = new ArgumentBuilder
                    {
                        "log",
                        "--format=\"%n\"",
                        "--name-only",
                        "--format",
                        GitCommandHelpers.FindRenamesAndCopiesOpts(),
                        "--",
                        fileName.Quote()
                    };

                    var listOfFileNames = new StringBuilder(fileName.Quote());

                    // keep a set of the file names already seen
                    var setOfFileNames = new HashSet <string> {
                        fileName
                    };

                    var lines = Module.GetGitOutputLines(args, GitModule.LosslessEncoding);

                    foreach (var line in lines.Select(GitModule.ReEncodeFileNameFromLossless))
                    {
                        if (!string.IsNullOrEmpty(line) && setOfFileNames.Add(line))
                        {
                            listOfFileNames.Append(" \"");
                            listOfFileNames.Append(line);
                            listOfFileNames.Append('\"');
                        }
                    }

                    // here we need --name-only to get the previous filenames in the revision graph
                    res.path      = listOfFileNames.ToString();
                    res.revision += " --name-only --parents" + GitCommandHelpers.FindRenamesAndCopiesOpts();
                }
                else if (AppSettings.FollowRenamesInFileHistory)
                {
                    // history of a directory
                    // --parents doesn't work with --follow enabled, but needed to graph a filtered log
                    res.revision = " " + GitCommandHelpers.FindRenamesOpt() + " --follow --parents";
                }
                else
                {
                    // rename following disabled
                    res.revision = " --parents";
                }

                if (AppSettings.FullHistoryInFileHistory)
                {
                    res.revision = string.Concat(" --full-history --simplify-merges ", res.revision);
                }

                return(res);
            }
        }
Beispiel #22
0
        static FunctionIdentifier()
        {
            Dictionary <FunctionArgType, ArgumentBuilder> argb = ArgumentParser.GetArgumentBuilderDictionary();

            methodArgumentBuilder = argb[FunctionArgType.METHOD];
            methodInstruction     = new METHOD_Instruction();
            setFunc = new FunctionIdentifier("SET", FunctionCode.SET, new SET_Instruction());            //代入文
            #region PRINT or INPUT
            addPrintFunction(FunctionCode.PRINT);
            addPrintFunction(FunctionCode.PRINTL);
            addPrintFunction(FunctionCode.PRINTW);
            addPrintFunction(FunctionCode.PRINTV);
            addPrintFunction(FunctionCode.PRINTVL);
            addPrintFunction(FunctionCode.PRINTVW);
            addPrintFunction(FunctionCode.PRINTS);
            addPrintFunction(FunctionCode.PRINTSL);
            addPrintFunction(FunctionCode.PRINTSW);
            addPrintFunction(FunctionCode.PRINTFORM);
            addPrintFunction(FunctionCode.PRINTFORML);
            addPrintFunction(FunctionCode.PRINTFORMW);
            addPrintFunction(FunctionCode.PRINTFORMS);
            addPrintFunction(FunctionCode.PRINTFORMSL);
            addPrintFunction(FunctionCode.PRINTFORMSW);
            addPrintFunction(FunctionCode.PRINTK);
            addPrintFunction(FunctionCode.PRINTKL);
            addPrintFunction(FunctionCode.PRINTKW);
            addPrintFunction(FunctionCode.PRINTVK);
            addPrintFunction(FunctionCode.PRINTVKL);
            addPrintFunction(FunctionCode.PRINTVKW);
            addPrintFunction(FunctionCode.PRINTSK);
            addPrintFunction(FunctionCode.PRINTSKL);
            addPrintFunction(FunctionCode.PRINTSKW);
            addPrintFunction(FunctionCode.PRINTFORMK);
            addPrintFunction(FunctionCode.PRINTFORMKL);
            addPrintFunction(FunctionCode.PRINTFORMKW);
            addPrintFunction(FunctionCode.PRINTFORMSK);
            addPrintFunction(FunctionCode.PRINTFORMSKL);
            addPrintFunction(FunctionCode.PRINTFORMSKW);
            addPrintFunction(FunctionCode.PRINTD);
            addPrintFunction(FunctionCode.PRINTDL);
            addPrintFunction(FunctionCode.PRINTDW);
            addPrintFunction(FunctionCode.PRINTVD);
            addPrintFunction(FunctionCode.PRINTVDL);
            addPrintFunction(FunctionCode.PRINTVDW);
            addPrintFunction(FunctionCode.PRINTSD);
            addPrintFunction(FunctionCode.PRINTSDL);
            addPrintFunction(FunctionCode.PRINTSDW);
            addPrintFunction(FunctionCode.PRINTFORMD);
            addPrintFunction(FunctionCode.PRINTFORMDL);
            addPrintFunction(FunctionCode.PRINTFORMDW);
            addPrintFunction(FunctionCode.PRINTFORMSD);
            addPrintFunction(FunctionCode.PRINTFORMSDL);
            addPrintFunction(FunctionCode.PRINTFORMSDW);
            addPrintFunction(FunctionCode.PRINTSINGLE);
            addPrintFunction(FunctionCode.PRINTSINGLEV);
            addPrintFunction(FunctionCode.PRINTSINGLES);
            addPrintFunction(FunctionCode.PRINTSINGLEFORM);
            addPrintFunction(FunctionCode.PRINTSINGLEFORMS);
            addPrintFunction(FunctionCode.PRINTSINGLEK);
            addPrintFunction(FunctionCode.PRINTSINGLEVK);
            addPrintFunction(FunctionCode.PRINTSINGLESK);
            addPrintFunction(FunctionCode.PRINTSINGLEFORMK);
            addPrintFunction(FunctionCode.PRINTSINGLEFORMSK);
            addPrintFunction(FunctionCode.PRINTSINGLED);
            addPrintFunction(FunctionCode.PRINTSINGLEVD);
            addPrintFunction(FunctionCode.PRINTSINGLESD);
            addPrintFunction(FunctionCode.PRINTSINGLEFORMD);
            addPrintFunction(FunctionCode.PRINTSINGLEFORMSD);

            addPrintFunction(FunctionCode.PRINTC);
            addPrintFunction(FunctionCode.PRINTLC);
            addPrintFunction(FunctionCode.PRINTFORMC);
            addPrintFunction(FunctionCode.PRINTFORMLC);
            addPrintFunction(FunctionCode.PRINTCK);
            addPrintFunction(FunctionCode.PRINTLCK);
            addPrintFunction(FunctionCode.PRINTFORMCK);
            addPrintFunction(FunctionCode.PRINTFORMLCK);
            addPrintFunction(FunctionCode.PRINTCD);
            addPrintFunction(FunctionCode.PRINTLCD);
            addPrintFunction(FunctionCode.PRINTFORMCD);
            addPrintFunction(FunctionCode.PRINTFORMLCD);
            addPrintDataFunction(FunctionCode.PRINTDATA);
            addPrintDataFunction(FunctionCode.PRINTDATAL);
            addPrintDataFunction(FunctionCode.PRINTDATAW);
            addPrintDataFunction(FunctionCode.PRINTDATAK);
            addPrintDataFunction(FunctionCode.PRINTDATAKL);
            addPrintDataFunction(FunctionCode.PRINTDATAKW);
            addPrintDataFunction(FunctionCode.PRINTDATAD);
            addPrintDataFunction(FunctionCode.PRINTDATADL);
            addPrintDataFunction(FunctionCode.PRINTDATADW);


            addFunction(FunctionCode.PRINTBUTTON, argb[FunctionArgType.SP_BUTTON], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.PRINTBUTTONC, argb[FunctionArgType.SP_BUTTON], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.PRINTBUTTONLC, argb[FunctionArgType.SP_BUTTON], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.PRINTPLAIN, argb[FunctionArgType.STR_NULLABLE], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.PRINTPLAINFORM, argb[FunctionArgType.FORM_STR_NULLABLE], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.PRINT_ABL, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE);    //能力。引数は登録番号
            addFunction(FunctionCode.PRINT_TALENT, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE); //素質
            addFunction(FunctionCode.PRINT_MARK, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE);   //刻印
            addFunction(FunctionCode.PRINT_EXP, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE);    //経験
            addFunction(FunctionCode.PRINT_PALAM, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE);  //パラメータ
            addFunction(FunctionCode.PRINT_ITEM, argb[FunctionArgType.VOID], METHOD_SAFE);             //所持アイテム
            addFunction(FunctionCode.PRINT_SHOPITEM, argb[FunctionArgType.VOID], METHOD_SAFE);         //ショップで売っているアイテム

            addFunction(FunctionCode.DRAWLINE, argb[FunctionArgType.VOID], METHOD_SAFE);               //画面の左端から右端まで----と線を引く。
            addFunction(FunctionCode.BAR, new BAR_Instruction(false));                                 //[*****....]のようなグラフを書く。BAR (変数) , (最大値), (長さ)
            addFunction(FunctionCode.BARL, new BAR_Instruction(true));                                 //改行付き。
            addFunction(FunctionCode.TIMES, new TIMES_Instruction());                                  //小数計算。TIMES (変数) , (小数値)という形で使う。

            addFunction(FunctionCode.WAIT, new WAIT_Instruction(false));
            addFunction(FunctionCode.INPUT, new INPUT_Instruction());
            addFunction(FunctionCode.INPUTS, new INPUTS_Instruction());
            addFunction(FunctionCode.TINPUT, new TINPUT_Instruction(false));
            addFunction(FunctionCode.TINPUTS, new TINPUTS_Instruction(false));
            addFunction(FunctionCode.TONEINPUT, new TINPUT_Instruction(true));
            addFunction(FunctionCode.TONEINPUTS, new TINPUTS_Instruction(true));
            addFunction(FunctionCode.TWAIT, new TWAIT_Instruction());
            addFunction(FunctionCode.WAITANYKEY, new WAITANYKEY_Instruction());
            addFunction(FunctionCode.FORCEWAIT, new WAIT_Instruction(true));
            addFunction(FunctionCode.ONEINPUT, new ONEINPUT_Instruction());
            addFunction(FunctionCode.ONEINPUTS, new ONEINPUTS_Instruction());
            addFunction(FunctionCode.CLEARLINE, new CLEARLINE_Instruction());
            addFunction(FunctionCode.REUSELASTLINE, new REUSELASTLINE_Instruction());

            #endregion
            addFunction(FunctionCode.UPCHECK, argb[FunctionArgType.VOID], METHOD_SAFE);              //パラメータの変動
            addFunction(FunctionCode.CUPCHECK, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.ADDCHARA, new ADDCHARA_Instruction(false, false));              //(キャラ番号)のキャラクタを追加
            addFunction(FunctionCode.ADDSPCHARA, new ADDCHARA_Instruction(true, false));             //(キャラ番号)のSPキャラクタを追加(フラグ0を1にして作成)
            addFunction(FunctionCode.ADDDEFCHARA, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.ADDVOIDCHARA, new ADDVOIDCHARA_Instruction());                  //変数に何の設定のないキャラを作成
            addFunction(FunctionCode.DELCHARA, new ADDCHARA_Instruction(false, true));               //(キャラ登録番号)のキャラクタを削除。

            addFunction(FunctionCode.PUTFORM, argb[FunctionArgType.FORM_STR_NULLABLE], METHOD_SAFE); //@SAVEINFO関数でのみ使用可能。PRINTFORMと同様の書式でセーブデータに概要をつける。
            addFunction(FunctionCode.QUIT, argb[FunctionArgType.VOID]);                              //ゲームを終了
            addFunction(FunctionCode.OUTPUTLOG, argb[FunctionArgType.VOID]);

            addFunction(FunctionCode.BEGIN, new BEGIN_Instruction());                //システム関数の実行。実行するとCALLの呼び出し元などを忘れてしまう。

            addFunction(FunctionCode.SAVEGAME, new SAVELOADGAME_Instruction(true));  //セーブ画面を呼ぶ。ショップのみ。
            addFunction(FunctionCode.LOADGAME, new SAVELOADGAME_Instruction(false)); //
            addFunction(FunctionCode.SAVEDATA, argb[FunctionArgType.SP_SAVEDATA], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.LOADDATA, argb[FunctionArgType.INT_EXPRESSION], EXTENDED | FLOW_CONTROL);
            addFunction(FunctionCode.DELDATA, new DELDATA_Instruction());
            addFunction(FunctionCode.SAVEGLOBAL, new SAVEGLOBAL_Instruction());
            addFunction(FunctionCode.LOADGLOBAL, new LOADGLOBAL_Instruction());
            addFunction(FunctionCode.RESETDATA, new RESETDATA_Instruction());
            addFunction(FunctionCode.RESETGLOBAL, new RESETGLOBAL_Instruction());

            addFunction(FunctionCode.SIF, new SIF_Instruction());            //一行のみIF
            addFunction(FunctionCode.IF, new IF_Instruction());
            addFunction(FunctionCode.ELSE, new ELSEIF_Instruction(FunctionArgType.VOID));
            addFunction(FunctionCode.ELSEIF, new ELSEIF_Instruction(FunctionArgType.INT_EXPRESSION));
            addFunction(FunctionCode.ENDIF, new ENDIF_Instruction(), METHOD_SAFE);
            addFunction(FunctionCode.SELECTCASE, new SELECTCASE_Instruction());
            addFunction(FunctionCode.CASE, new ELSEIF_Instruction(FunctionArgType.CASE), EXTENDED);
            addFunction(FunctionCode.CASEELSE, new ELSEIF_Instruction(FunctionArgType.VOID), EXTENDED);
            addFunction(FunctionCode.ENDSELECT, new ENDIF_Instruction(), METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.REPEAT, new REPEAT_Instruction(false));            //RENDまで繰り返し。繰り返した回数がCOUNTへ。ネスト不可。
            addFunction(FunctionCode.REND, new REND_Instruction());
            addFunction(FunctionCode.FOR, new REPEAT_Instruction(true), EXTENDED);
            addFunction(FunctionCode.NEXT, new REND_Instruction(), EXTENDED);
            addFunction(FunctionCode.WHILE, new WHILE_Instruction());
            addFunction(FunctionCode.WEND, new WEND_Instruction());
            addFunction(FunctionCode.DO, new ENDIF_Instruction(), METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.LOOP, new LOOP_Instruction());
            addFunction(FunctionCode.CONTINUE, new CONTINUE_Instruction());      //REPEATに戻る
            addFunction(FunctionCode.BREAK, new BREAK_Instruction());            //RENDの次の行まで

            addFunction(FunctionCode.RETURN, new RETURN_Instruction());          //関数の終了。RESULTに整数を格納可能。省略した場合、0。(次の@~~がRETURNと見なされる。)
            addFunction(FunctionCode.RETURNFORM, new RETURNFORM_Instruction());  //関数の終了。RESULTに整数を格納可能。省略した場合、0。(次の@~~がRETURNと見なされる。)
            addFunction(FunctionCode.RETURNF, new RETURNF_Instruction());

            addFunction(FunctionCode.STRLEN, new STRLEN_Instruction(false, false));
            addFunction(FunctionCode.STRLENFORM, new STRLEN_Instruction(true, false));
            addFunction(FunctionCode.STRLENU, new STRLEN_Instruction(false, true));
            addFunction(FunctionCode.STRLENFORMU, new STRLEN_Instruction(true, true));

            addFunction(FunctionCode.SWAPCHARA, new SWAPCHARA_Instruction());
            addFunction(FunctionCode.COPYCHARA, new COPYCHARA_Instruction());
            addFunction(FunctionCode.ADDCOPYCHARA, new ADDCOPYCHARA_Instruction());
            addFunction(FunctionCode.SPLIT, argb[FunctionArgType.SP_SPLIT], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.SETCOLOR, argb[FunctionArgType.SP_COLOR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.SETCOLORBYNAME, argb[FunctionArgType.STR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.RESETCOLOR, new RESETCOLOR_Instruction());
            addFunction(FunctionCode.SETBGCOLOR, argb[FunctionArgType.SP_COLOR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.SETBGCOLORBYNAME, argb[FunctionArgType.STR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.RESETBGCOLOR, new RESETBGCOLOR_Instruction());
            addFunction(FunctionCode.FONTBOLD, new FONTBOLD_Instruction());
            addFunction(FunctionCode.FONTITALIC, new FONTITALIC_Instruction());
            addFunction(FunctionCode.FONTREGULAR, new FONTREGULAR_Instruction());
            addFunction(FunctionCode.SORTCHARA, new SORTCHARA_Instruction());
            addFunction(FunctionCode.FONTSTYLE, argb[FunctionArgType.INT_EXPRESSION_NULLABLE], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.ALIGNMENT, argb[FunctionArgType.STR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.CUSTOMDRAWLINE, argb[FunctionArgType.STR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.DRAWLINEFORM, argb[FunctionArgType.FORM_STR], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.CLEARTEXTBOX, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.SETFONT, argb[FunctionArgType.STR_EXPRESSION_NULLABLE], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.SWAP, argb[FunctionArgType.SP_SWAPVAR], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.RANDOMIZE, new RANDOMIZE_Instruction());
            addFunction(FunctionCode.DUMPRAND, new DUMPRAND_Instruction());
            addFunction(FunctionCode.INITRAND, new INITRAND_Instruction());

            addFunction(FunctionCode.REDRAW, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.CALLTRAIN, argb[FunctionArgType.INT_EXPRESSION], EXTENDED | FLOW_CONTROL);
            addFunction(FunctionCode.STOPCALLTRAIN, argb[FunctionArgType.VOID], EXTENDED | FLOW_CONTROL);
            addFunction(FunctionCode.DOTRAIN, argb[FunctionArgType.INT_EXPRESSION], EXTENDED | FLOW_CONTROL);

            addFunction(FunctionCode.DATA, argb[FunctionArgType.STR_NULLABLE], METHOD_SAFE | EXTENDED | PARTIAL | PARTIAL);
            addFunction(FunctionCode.DATAFORM, argb[FunctionArgType.FORM_STR_NULLABLE], METHOD_SAFE | EXTENDED | PARTIAL);
            addFunction(FunctionCode.ENDDATA, new DO_NOTHING_Instruction());
            addFunction(FunctionCode.DATALIST, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED | PARTIAL);
            addFunction(FunctionCode.ENDLIST, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED | PARTIAL);
            addFunction(FunctionCode.STRDATA, argb[FunctionArgType.VAR_STR], METHOD_SAFE | EXTENDED | PARTIAL);

            addFunction(FunctionCode.SETBIT, new SETBIT_Instruction(1));
            addFunction(FunctionCode.CLEARBIT, new SETBIT_Instruction(0));
            addFunction(FunctionCode.INVERTBIT, new SETBIT_Instruction(-1));
            addFunction(FunctionCode.DELALLCHARA, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.PICKUPCHARA, argb[FunctionArgType.INT_ANY], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.VARSET, new VARSET_Instruction());
            addFunction(FunctionCode.CVARSET, new CVARSET_Instruction());

            addFunction(FunctionCode.RESET_STAIN, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.FORCEKANA, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.SKIPDISP, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.NOSKIP, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED | PARTIAL);
            addFunction(FunctionCode.ENDNOSKIP, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED | PARTIAL);

            addFunction(FunctionCode.ARRAYSHIFT, argb[FunctionArgType.SP_SHIFT_ARRAY], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.ARRAYREMOVE, argb[FunctionArgType.SP_CONTROL_ARRAY], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.ARRAYSORT, argb[FunctionArgType.SP_SORTARRAY], METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.ARRAYCOPY, argb[FunctionArgType.SP_COPY_ARRAY], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.JUMP, new CALL_Instruction(false, true, false, false));            //関数に移動
            addFunction(FunctionCode.CALL, new CALL_Instruction(false, false, false, false));           //関数に移動。移動元を記憶し、RETURNで帰る。
            addFunction(FunctionCode.TRYJUMP, new CALL_Instruction(false, true, true, false), EXTENDED);
            addFunction(FunctionCode.TRYCALL, new CALL_Instruction(false, false, true, false), EXTENDED);
            addFunction(FunctionCode.JUMPFORM, new CALL_Instruction(true, true, false, false), EXTENDED);
            addFunction(FunctionCode.CALLFORM, new CALL_Instruction(true, false, false, false), EXTENDED);
            addFunction(FunctionCode.TRYJUMPFORM, new CALL_Instruction(true, true, true, false), EXTENDED);
            addFunction(FunctionCode.TRYCALLFORM, new CALL_Instruction(true, false, true, false), EXTENDED);
            addFunction(FunctionCode.TRYCJUMP, new CALL_Instruction(false, true, true, true), EXTENDED);
            addFunction(FunctionCode.TRYCCALL, new CALL_Instruction(false, false, true, true), EXTENDED);
            addFunction(FunctionCode.TRYCJUMPFORM, new CALL_Instruction(true, true, true, true), EXTENDED);
            addFunction(FunctionCode.TRYCCALLFORM, new CALL_Instruction(true, false, true, true), EXTENDED);
            addFunction(FunctionCode.CALLEVENT, new CALLEVENT_Instruction());
            addFunction(FunctionCode.CALLF, new CALLF_Instruction(false));
            addFunction(FunctionCode.CALLFORMF, new CALLF_Instruction(true));
            addFunction(FunctionCode.RESTART, new RESTART_Instruction());              //関数の再開。関数の最初に戻る。
            addFunction(FunctionCode.GOTO, new GOTO_Instruction(false, false, false)); //$ラベルへジャンプ
            addFunction(FunctionCode.TRYGOTO, new GOTO_Instruction(false, true, false), EXTENDED);
            addFunction(FunctionCode.GOTOFORM, new GOTO_Instruction(true, false, false), EXTENDED);
            addFunction(FunctionCode.TRYGOTOFORM, new GOTO_Instruction(true, true, false), EXTENDED);
            addFunction(FunctionCode.TRYCGOTO, new GOTO_Instruction(false, true, true), EXTENDED);
            addFunction(FunctionCode.TRYCGOTOFORM, new GOTO_Instruction(true, true, true), EXTENDED);


            addFunction(FunctionCode.CATCH, new CATCH_Instruction());
            addFunction(FunctionCode.ENDCATCH, new ENDIF_Instruction(), METHOD_SAFE | EXTENDED);
            addFunction(FunctionCode.TRYCALLLIST, argb[FunctionArgType.VOID], EXTENDED | FLOW_CONTROL | PARTIAL | IS_TRY);
            addFunction(FunctionCode.TRYJUMPLIST, argb[FunctionArgType.VOID], EXTENDED | FLOW_CONTROL | PARTIAL | IS_JUMP | IS_TRY);
            addFunction(FunctionCode.TRYGOTOLIST, argb[FunctionArgType.VOID], EXTENDED | FLOW_CONTROL | PARTIAL | IS_TRY);
            addFunction(FunctionCode.FUNC, argb[FunctionArgType.SP_CALLFORM], EXTENDED | FLOW_CONTROL | PARTIAL | FORCE_SETARG);
            addFunction(FunctionCode.ENDFUNC, new ENDIF_Instruction(), EXTENDED);

            addFunction(FunctionCode.DEBUGPRINT, new DEBUGPRINT_Instruction(false, false));
            addFunction(FunctionCode.DEBUGPRINTL, new DEBUGPRINT_Instruction(false, true));
            addFunction(FunctionCode.DEBUGPRINTFORM, new DEBUGPRINT_Instruction(true, false));
            addFunction(FunctionCode.DEBUGPRINTFORML, new DEBUGPRINT_Instruction(true, true));
            addFunction(FunctionCode.DEBUGCLEAR, new DEBUGCLEAR_Instruction());
            addFunction(FunctionCode.ASSERT, argb[FunctionArgType.INT_EXPRESSION], METHOD_SAFE | EXTENDED | DEBUG_FUNC);
            addFunction(FunctionCode.THROW, argb[FunctionArgType.FORM_STR_NULLABLE], METHOD_SAFE | EXTENDED);

            addFunction(FunctionCode.SAVEVAR, new SAVEVAR_Instruction());
            addFunction(FunctionCode.LOADVAR, new LOADVAR_Instruction());
            addFunction(FunctionCode.SAVECHARA, new SAVECHARA_Instruction());
            addFunction(FunctionCode.LOADCHARA, new LOADCHARA_Instruction());
            addFunction(FunctionCode.REF, new REF_Instruction(false));
            addFunction(FunctionCode.REFBYNAME, new REF_Instruction(true));
            addFunction(FunctionCode.HTML_PRINT, new HTML_PRINT_Instruction());
            addFunction(FunctionCode.HTML_TAGSPLIT, new HTML_TAGSPLIT_Instruction());
            addFunction(FunctionCode.PRINT_IMG, new PRINT_IMG_Instruction());
            addFunction(FunctionCode.PRINT_RECT, new PRINT_RECT_Instruction());
            addFunction(FunctionCode.PRINT_SPACE, new PRINT_SPACE_Instruction());

            addFunction(FunctionCode.TOOLTIP_SETCOLOR, new TOOLTIP_SETCOLOR_Instruction());
            addFunction(FunctionCode.TOOLTIP_SETDELAY, new TOOLTIP_SETDELAY_Instruction());
            addFunction(FunctionCode.TOOLTIP_SETDURATION, new TOOLTIP_SETDURATION_Instruction());

            addFunction(FunctionCode.INPUTMOUSEKEY, new INPUTMOUSEKEY_Instruction());
            addFunction(FunctionCode.AWAIT, new AWAIT_Instruction());
            #region 式中関数の引数違い
            addFunction(FunctionCode.VARSIZE, argb[FunctionArgType.SP_VAR], METHOD_SAFE | EXTENDED);                //動作が違うのでMETHOD化できない
            addFunction(FunctionCode.GETTIME, argb[FunctionArgType.VOID], METHOD_SAFE | EXTENDED);                  //2つに代入する必要があるのでMETHOD化できない
            addFunction(FunctionCode.POWER, argb[FunctionArgType.SP_POWER], METHOD_SAFE | EXTENDED);                //引数が違うのでMETHOD化できない。
            addFunction(FunctionCode.PRINTCPERLINE, argb[FunctionArgType.SP_GETINT], METHOD_SAFE | EXTENDED);       //よく考えたら引数の仕様違うや
            addFunction(FunctionCode.SAVENOS, argb[FunctionArgType.SP_GETINT], METHOD_SAFE | EXTENDED);             //引数の仕様が違うので(ry
            addFunction(FunctionCode.ENCODETOUNI, argb[FunctionArgType.FORM_STR_NULLABLE], METHOD_SAFE | EXTENDED); //式中関数版を追加。処理が全然違う
            #endregion

            Dictionary <string, FunctionMethod> methodList = FunctionMethodCreator.GetMethodList();
            foreach (KeyValuePair <string, FunctionMethod> pair in methodList)
            {
                string key = pair.Key;
                if (!funcDic.ContainsKey(key))
                {
                    funcDic.Add(key, new FunctionIdentifier(key, pair.Value, methodInstruction));
                }
            }
            funcMatch[FunctionCode.IF]           = "ENDIF";
            funcMatch[FunctionCode.SELECTCASE]   = "ENDSELECT";
            funcMatch[FunctionCode.REPEAT]       = "REND";
            funcMatch[FunctionCode.FOR]          = "NEXT";
            funcMatch[FunctionCode.WHILE]        = "WEND";
            funcMatch[FunctionCode.TRYCGOTO]     = "CATCH";
            funcMatch[FunctionCode.TRYCJUMP]     = "CATCH";
            funcMatch[FunctionCode.TRYCCALL]     = "CATCH";
            funcMatch[FunctionCode.TRYCGOTOFORM] = "CATCH";
            funcMatch[FunctionCode.TRYCJUMPFORM] = "CATCH";
            funcMatch[FunctionCode.TRYCCALLFORM] = "CATCH";
            funcMatch[FunctionCode.CATCH]        = "ENDCATCH";
            funcMatch[FunctionCode.DO]           = "LOOP";
            funcMatch[FunctionCode.PRINTDATA]    = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATAL]   = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATAW]   = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATAK]   = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATAKL]  = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATAKW]  = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATAD]   = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATADL]  = "ENDDATA";
            funcMatch[FunctionCode.PRINTDATADW]  = "ENDDATA";
            funcMatch[FunctionCode.DATALIST]     = "ENDLIST";
            funcMatch[FunctionCode.STRDATA]      = "ENDDATA";
            funcMatch[FunctionCode.NOSKIP]       = "ENDNOSKIP";
            funcMatch[FunctionCode.TRYCALLLIST]  = "ENDFUNC";
            funcMatch[FunctionCode.TRYGOTOLIST]  = "ENDFUNC";
            funcMatch[FunctionCode.TRYJUMPLIST]  = "ENDFUNC";
            funcParent[FunctionCode.REND]        = FunctionCode.REPEAT;
            funcParent[FunctionCode.NEXT]        = FunctionCode.FOR;
            funcParent[FunctionCode.WEND]        = FunctionCode.WHILE;
            funcParent[FunctionCode.LOOP]        = FunctionCode.DO;
        }
Beispiel #23
0
        public IEnumerable <CommandDefinition> CreateGenerateCommandDefinitions(ICollection <CommandDefinition> generateCommands,
                                                                                IEnumerable <TemplateDescription> allTemplates)
        {
            HashSet <string> generators = new HashSet <string>();
            Dictionary <string, List <templateGenerateStep> > generatorsDictionary = new Dictionary <string, List <templateGenerateStep> >();

            foreach (TemplateDescription template in allTemplates)
            {
                if (template.isHidden)
                {
                    continue;
                }

                foreach (string generator in (template.GeneratedFile ?? Enumerable.Empty <templateGeneratedFile>())
                         .Select(g => g.generator.ToLowerInvariant()))
                {
                    generators.Add(generator);
                }

                foreach (string generator in generators)
                {
                    if (generatorsDictionary.ContainsKey(generator))
                    {
                        if (template.GenerateStep != null && template.GenerateStep.Where(step => step.generator == generator).Any())
                        {
                            if (generatorsDictionary[generator] == null)
                            {
                                generatorsDictionary[generator] = new List <templateGenerateStep>(template.GenerateStep.Where(step => step.generator == generator));
                            }
                            else
                            {
                                generatorsDictionary[generator].AddRange(template.GenerateStep.Where(step => step.generator == generator));
                            }
                        }
                    }
                    else
                    {
                        generatorsDictionary.Add(generator, template.GenerateStep != null
                                         ? new List <templateGenerateStep>(template.GenerateStep.Where(step => step.generator == generator))
                                         : null);
                    }
                }
            }

            generateCommands.Clear();
            foreach (string generator in generatorsDictionary.Keys)
            {
                generateCommands.Add(AddArguments(CommandDefinitionBuilder.Create()
                                                  .SetName(generator)
                                                  .SetHelp($"Generates all files with the '{generator}' generator.")
                                                  .AddExample($"generate {generator} --{EntityKeys.PathKey} Path/To/Project",
                                                              $"generate all {generator} files in default location."),
                                                  generator,
                                                  generatorsDictionary[generator]));
            }

            generateCommands.Add(AddArguments(CommandDefinitionBuilder.Create()
                                              .SetName("all")
                                              .SetHelp($"Generates all files.")
                                              .AddExample($"generate all --{EntityKeys.PathKey} Path/To/Project",
                                                          $"generate all files in default location."),
                                              "all",
                                              allTemplates.Where(t => !t.isHidden && t.GenerateStep != null)
                                              .SelectMany(t => t.GenerateStep)
                                              .Where(t => t != null)
                                              ));

            return(generateCommands);

            CommandDefinition AddArguments(CommandDefinitionBuilder definitionBuilder,
                                           string generatorName,
                                           IEnumerable <templateGenerateStep> generateSteps = null)
            {
                definitionBuilder = definitionBuilder.CreateArgument()
                                    .SetName(EntityKeys.PathKey)
                                    .SetShortName('p')
                                    .SetHelp(
                    "The path to the project settings file or the project root directory. " +
                    "Default is the current directory.")
                                    .SetArgumentType(ArgumentType.SingleValue)
                                    .Build()
                                    .CreateArgument()
                                    .SetName(EntityKeys.SourceDirectoryKey)
                                    .SetShortName('s')
                                    .SetHelp(
                    "The path of the source directories separated by ','. Default is the 'src' directory " +
                    "if such a directory exists. If not, the directory " +
                    "defined with the '--path' option is used. Relative paths are relative " +
                    "to the directory defined with the '--path' option. If any path contains a ' ' quotation " +
                    "marks should be used around all paths, e.g. \"path1,path With Space,path2\".")
                                    .SetArgumentType(ArgumentType.MultipleValue)
                                    .Build()
                                    .CreateArgument()
                                    .SetName(EntityKeys.IncludeDirectoryKey)
                                    .SetShortName('i')
                                    .SetHelp(
                    "Overrides the includes used to find header files. Usually CMake is used to determine " +
                    "the include paths. If that is not possible or wanted the value of this argument is " +
                    "used instead of the CMake determined include paths. Relative paths are relative " +
                    "to the directory defined with the '--path' option. If any path contains a ' ' quotation " +
                    "marks should be used around all paths, e.g. \"path1,path With Space,path2\". Additionally " +
                    "to these paths the include paths determined by the SDK will always be considered and " +
                    "do not need to be specified additionally.")
                                    .SetArgumentType(ArgumentType.MultipleValue)
                                    .Build()
                                    .CreateArgument()
                                    .SetName(Constants.NoIncludePathDetection)
                                    .SetShortName('n')
                                    .SetHelp("Disables the automatic include path detection using CMake. This option is not necessary if the " +
                                             $"'-{EntityKeys.IncludeDirectoryKey}' option is used, as that option will automatically disable " +
                                             "the CMake detection. The system paths defined by the SDK are still used.")
                                    .SetArgumentType(ArgumentType.Bool)
                                    .Build()
                                    .CreateArgument()
                                    .SetName(Constants.OutputArgumentName)
                                    .SetShortName('o')
                                    .SetHelp("The path where the files will be generated in. " +
                                             "Default is the 'intermediate' directory. Relative paths are relative " +
                                             "to the directory defined with the '--path' option.")
                                    .SetArgumentType(ArgumentType.SingleValue)
                                    .Build();

                if (generateSteps != null)
                {
                    foreach (templateArgumentDefinition argument in generateSteps.Where(step => step.Arguments != null)
                             .SelectMany(step => step.Arguments))
                    {
                        ArgumentBuilder argumentBuilder = definitionBuilder.CreateArgument()
                                                          .SetName(argument.name);
                        if (argument.shortnameSpecified)
                        {
                            argumentBuilder = argumentBuilder.SetShortName(argument.shortname[0]);
                        }
                        if (argument.helpSpecified)
                        {
                            argumentBuilder = argumentBuilder.SetHelp(argument.help);
                        }

                        ArgumentType argumentType = argument.hasvalueSpecified && argument.hasvalue
                                                    ? argument.multiplicitySpecified && argument.multiplicity == multiplicity.OneOrMore
                                                        ? ArgumentType.MultipleValue
                                                        : ArgumentType.SingleValue
                                                    : ArgumentType.Bool;
                        argumentBuilder   = argumentBuilder.SetArgumentType(argumentType);
                        definitionBuilder = argumentBuilder.Build();
                    }

                    foreach (templateExample example in generateSteps.Where(step => step.Example != null)
                             .SelectMany(step => step.Example))
                    {
                        StringBuilder exampleBuilder = new StringBuilder($"generate {generatorName.ToLowerInvariant()}");
                        ParseExample(null, example, exampleBuilder, false);
                        definitionBuilder.AddExample(exampleBuilder.ToString(), example.Description ?? string.Empty);
                    }
                }
                return(definitionBuilder.Build());
            }
        }
        public void Then_Argument_Name_Must_Be_A_Valid_GraphQL_Name(string name, string because)
        {
            Action method = () => ArgumentBuilder.Build(name);

            FluentActions.Invoking(method).Should().ThrowInvalidGraphQLNameException("name", because);
        }
        private ArgumentString GetInternal(string?firstRevision, string?secondRevision, string?fileName = null, string?oldFileName = null, bool isTracked = true)
        {
            // Combined Diff artificial commit should not be included in diffs
            if (firstRevision == GitRevision.CombinedDiffGuid || secondRevision == GitRevision.CombinedDiffGuid)
            {
                throw new ArgumentOutOfRangeException(nameof(firstRevision), firstRevision,
                                                      "CombinedDiff artificial commit cannot be explicitly compared: " +
                                                      firstRevision + ", " + secondRevision);
            }

            var extra = new ArgumentBuilder();

            firstRevision  = ArtificialToDiffOptions(firstRevision);
            secondRevision = ArtificialToDiffOptions(secondRevision);

            // Note: As artificial are options, diff unstage..unstage and
            // stage..stage will show output, different from e.g. HEAD..HEAD
            // Diff-to-itself is not always disabled or is transient why this is not handled as error in release builds
            Debug.Assert(!(firstRevision == secondRevision && (string.IsNullOrEmpty(firstRevision) || firstRevision == StagedOpt)),
                         "Unexpectedly two identical artificial revisions to diff: " + firstRevision +
                         ". This will be displayed as diff to HEAD, not an identical diff.");

            // As empty (unstaged) and --cached (staged) are options (not revisions),
            // order must be preserved with -R
            if (firstRevision != secondRevision && (string.IsNullOrEmpty(firstRevision) ||
                                                    (firstRevision == StagedOpt && !string.IsNullOrEmpty(secondRevision))))
            {
                extra.Add("-R");
            }

            // Special case: Remove options comparing worktree-index
            if ((string.IsNullOrEmpty(firstRevision) && secondRevision == StagedOpt) ||
                (firstRevision == StagedOpt && string.IsNullOrEmpty(secondRevision)))
            {
                firstRevision = secondRevision = "";
            }

            // Reorder options - not strictly required
            if (secondRevision == StagedOpt)
            {
                extra.Add(StagedOpt);
                secondRevision = "";
            }

            if (string.IsNullOrWhiteSpace(fileName))
            {
                extra.Add(firstRevision);
                extra.Add(secondRevision);
            }
            else
            {
                // Untracked files can only be compared to /dev/null
                // The UI should normally only allow this for worktree to index, but it can be included in multi selections
                if (!isTracked)
                {
                    extra.Add("--no-index");
                    oldFileName = fileName;
                    fileName    = "/dev/null";
                }
                else
                {
                    extra.Add(firstRevision);
                    extra.Add(secondRevision);
                }

                extra.Add("--");
                extra.Add(fileName.QuoteNE());
                extra.Add(oldFileName.QuoteNE());
            }

            return(extra);
        }
 public static ExecutionResults ExecuteIn(string workingDirectory, string arguments, bool isTeamCity = false, bool logToFile = true)
 {
     var logFile = logToFile ? Path.Combine(workingDirectory, "log.txt") : null;
     var args = new ArgumentBuilder(workingDirectory, arguments, isTeamCity, logFile);
     return ExecuteIn(args);
 }
Beispiel #27
0
        internal override void InternalExecute()
        {
            if (string.IsNullOrEmpty(_pathToNuGetExecutable))
                _pathToNuGetExecutable = _fileSystemHelper.Find("nuget.exe");

            if (string.IsNullOrEmpty(_pathToNuGetExecutable))
                throw new FileNotFoundException("Could not locate nuget.exe. Please specify it manually using PathToNuGetExecutable()");

            var stream = _fileSystemHelper.CreateFile(_deployFolder.File(_projectId + ".nuspec").ToString());
            using (var fs = new StreamWriter(stream))
            {
                fs.Write(CreateSchema());
            }

            //ensure latest version of nuget
            Defaults.Logger.WriteDebugMessage("Updating NuGet to the latest version");
            var ab = new ArgumentBuilder {StartOfEntireArgumentString = "Update -self"};
            _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).Execute();

            //configure the API key
            Defaults.Logger.WriteDebugMessage("Configuring the API Key");
            ab.StartOfEntireArgumentString = "setApiKey " + _apiKey;
            _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).Execute();

            //package it
            Defaults.Logger.WriteDebugMessage("Creating the package");
            ab.StartOfEntireArgumentString = "Pack " + _projectId + ".nuspec";
            var inWorkingDirectory = _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).InWorkingDirectory(_deployFolder);
            inWorkingDirectory.Execute();

            //NuGet Push YourPackage.nupkg
            Defaults.Logger.WriteDebugMessage("publishing the package");
            ab.StartOfEntireArgumentString = "Push " + _projectId + "." + _version + ".nupkg";
            _executable.ExecutablePath(_pathToNuGetExecutable).UseArgumentBuilder(ab).InWorkingDirectory(_deployFolder).Execute();
        }
Beispiel #28
0
        public static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language)
        {
            Log.Information($"XivGame::LaunchGame(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})");

            try
            {
                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamNative.Initialize();

                        if (SteamApi.IsSteamRunning() && SteamApi.Initialize(STEAM_APP_ID))
                        {
                            Log.Information("Steam initialized.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not initialize Steam.");
                    }
                }

                var game = new Process {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardError  = false,
                        RedirectStandardInput  = false,
                        RedirectStandardOutput = false
                    }
                };

                if (isDx11)
                {
                    game.StartInfo.FileName = gamePath + "/game/ffxiv_dx11.exe";
                }
                else
                {
                    game.StartInfo.FileName = gamePath + "/game/ffxiv.exe";
                }

                game.StartInfo.Arguments =
                    $"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int) language} ver={GetLocalGameVer(gamePath)}";
                game.StartInfo.Arguments += " " + additionalArguments;

                var ticks = (uint)Environment.TickCount;
                var key   = ticks & 0xFFF0_0000;

                var argumentBuilder = new ArgumentBuilder()
                                      .Append("DEV.DataPathType", "1")
                                      .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                                      .Append("DEV.TestSID", sessionId)
                                      .Append("DEV.UseSqPack", "1")
                                      .Append("SYS.Region", region.ToString())
                                      .Append("language", ((int)language).ToString())
                                      .Append("ver", GetLocalGameVer(gamePath));

                if (isSteamServiceAccount)
                {
                    // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
                    game.StartInfo.Environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
                    argumentBuilder.Append("IsSteam", "1");
                }

                // This is a bit of a hack; ideally additionalArguments would be a dictionary or some KeyValue structure
                if (additionalArguments != null && additionalArguments != "")
                {
                    var regex = new Regex(@"\s*(?<key>[^=]+)\s*=\s*(?<value>[^\s]+)\s*", RegexOptions.Compiled);
                    foreach (Match match in regex.Matches(additionalArguments))
                    {
                        argumentBuilder.Append(match.Groups["key"].Value, match.Groups["value"].Value);
                    }
                }


                game.StartInfo.WorkingDirectory = Path.Combine(gamePath.FullName, "game");

                game.Start();

                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamApi.Uninitialize();
                        SteamNative.Uninitialize();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not uninitialize Steam.");
                    }
                }

                Thread.Sleep(4000);

                Environment.Exit(0);

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                    {
                        throw new Exception("Game exited prematurely");
                    }

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    break;
                }

                return(game);
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.",
                                "XG LaunchGame").ShowDialog();
            }

            return(null);
        }
Beispiel #29
0
 public MSTestRunner(IExecutable executable)
 {
     _executable      = executable;
     _argumentBuilder = new ArgumentBuilder("/", ":");
 }
    static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
    {
        var executable = PathHelper.GetExecutable();
        var output     = new StringBuilder();

        var environmentalVariables =
            new[]
        {
            new KeyValuePair <string, string>(TeamCity.EnvironmentVariableName, arguments.IsTeamCity ? "8.0.0" : null),
            new KeyValuePair <string, string>(AppVeyor.EnvironmentVariableName, null),
            new KeyValuePair <string, string>(TravisCI.EnvironmentVariableName, null),
            new KeyValuePair <string, string>(VsoAgent.EnvironmentVariableName, null),
        };

        var exitCode = -1;

        try
        {
            var args = PathHelper.GetExecutableArgs(arguments.ToString());

            Console.WriteLine("Executing: {0} {1}", executable, args);
            Console.WriteLine();

            exitCode = ProcessHelper.Run(
                s => output.AppendLine(s),
                s => output.AppendLine(s),
                null,
                executable,
                args,
                arguments.WorkingDirectory,
                environmentalVariables);
        }
        catch (Exception exception)
        {
            // NOTE: It's the exit code and output from the process we want to test,
            //       not the internals of the ProcessHelper. That's why we're catching
            //       any exceptions here, because problems in the process being executed
            //       should be visible in the output or exit code. @asbjornu
            Console.WriteLine(exception);
        }

        Console.WriteLine("Output from GitVersion.exe");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(output.ToString());
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        if (string.IsNullOrWhiteSpace(arguments.LogFile) || !File.Exists(arguments.LogFile))
        {
            return(new ExecutionResults(exitCode, output.ToString(), null));
        }

        var logContents = File.ReadAllText(arguments.LogFile);

        Console.WriteLine("Log from GitVersion.exe");
        Console.WriteLine("-------------------------------------------------------");
        Console.WriteLine(logContents);
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("-------------------------------------------------------");

        return(new ExecutionResults(exitCode, output.ToString(), logContents));
    }
Beispiel #31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            accountingMasterPage = (AccountingMasterPage)Page.Master;
            accountingMasterPage.InitializeMasterPageComponents();
            dataAccess = accountingMasterPage.dataAccess;


            // action:
            //    null -  Sem ação, apenas lista os mailings
            //    0    -  Excluir mailing, lista os restantes
            //    1    -  Teste execução do mailing
            int?action    = null;
            int?mailingId = null;

            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["action"]))
                {
                    action = int.Parse(Request.QueryString["action"]);
                }

                if (!String.IsNullOrEmpty(Request.QueryString["mailingId"]))
                {
                    mailingId = int.Parse(Request.QueryString["mailingId"]);
                }
            }
            catch (System.FormatException)
            {
                // Remove todos os controles da página
                configurationArea.Controls.Clear();
                controlArea.Controls.Clear();

                // Mostra aviso de inconsistência nos parâmetros
                WarningMessage.Show(controlArea, ArgumentBuilder.GetWarning());
                return;
            }

            Tenant tenant = (Tenant)Session["tenant"];

            mailingDAO = new MailingDAO(dataAccess.GetConnection());

            if (mailingId != null)
            {
                switch (action)
                {
                case 0:
                    mailingDAO.RemoveMailing(mailingId.Value);
                    Response.Redirect("ConfigMailing.aspx");     // Limpa a QueryString para evitar erros
                    break;

                case 1:
                    Mailing mailing = mailingDAO.GetMailing(tenant.id, mailingId);
                    TestMailing(mailing);
                    break;

                default:
                    break;
                }
            }

            List <Object> mailingList = mailingDAO.GetAllMailings(tenant.id);

            String[] columnNames = new String[] { "Frequência de envio", "Relatório", "Destinatários" };
            //String testScript = "window.location='ConfigMailing.aspx?action=1&mailingId=' + {0};";
            String alterScript  = "window.open('MailingSettings.aspx?mailingId=' + {0}, 'Settings', 'width=540,height=600');";
            String removeScript = "var confirmed = confirm('Deseja realmente excluir este item?'); if (confirmed) window.location='ConfigMailing.aspx?action=0&mailingId=' + {0};";

            EditableListButton[] buttons = new EditableListButton[]
            {
                // Botões que devem aparecer para os items da lista
                //new EditableListButton("Testar", testScript, ButtonTypeEnum.Execute),
                new EditableListButton("Editar", alterScript, ButtonTypeEnum.Edit),
                new EditableListButton("Excluir", removeScript, ButtonTypeEnum.Remove)
            };
            EditableList editableList = new EditableList(configurationArea, columnNames, buttons);

            foreach (Mailing mailing in mailingList)
            {
                ReportFrequencyEnum frequency  = (ReportFrequencyEnum)mailing.frequency;
                ReportTypeEnum      reportType = (ReportTypeEnum)mailing.reportType;

                String[] mailingProperties = new String[]
                {
                    AssociatedText.GetFieldDescription(typeof(ReportFrequencyEnum), frequency.ToString()),
                    AssociatedText.GetFieldDescription(typeof(ReportTypeEnum), reportType.ToString()),
                    mailing.recipients
                };
                // A lista de mailings não possui item default, isDefaultItem é sempre "false"
                editableList.InsertItem(mailing.id, false, mailingProperties);
            }
            editableList.DrawList();

            // O clique do botão chama o script de alteração passando "id = 0", a tela de alteração
            // interpreta "id = 0" como "criar um novo", o id é então gerado no banco de dados.
            btnNovo.Attributes.Add("onClick", String.Format(alterScript, 0));
        }
Beispiel #32
0
 public TestAccessor(ArgumentBuilder builder)
 {
     _builder = builder;
 }
Beispiel #33
0
        public void Argument_infers_arity_of_IEnumerable_types_as_OneOrMore(Type type)
        {
            var argument = ArgumentBuilder.CreateArgument(type);

            argument.Arity.Should().BeEquivalentTo(ArgumentArity.OneOrMore);
        }
Beispiel #34
0
        static void Main(string[] args)
        {
            ArgumentBuilder ab = new ArgumentBuilder(
                new ArgumentPattern("input", "One or more converter input files", ArgumentType.STRING, null, true, "-i"),
                new ArgumentPattern("output", "An optional specified output file.", ArgumentType.STRING, null, "-o"),
                new ArgumentPattern("outputType", "The output format type (h3d/gfmbdlp/gfx)", ArgumentType.STRING, "h3d", "-t", "--type"),
                new ArgumentPattern("outputVersion", "The output format version", ArgumentType.INT, (int)0x21, "-v", "--version"),
                new ArgumentPattern("filter", "Output format filters (model/texture/animation/all)", ArgumentType.STRING, "all", true, "-f", "--filter")
                );

            Console.WriteLine("SPICA Embedded Command Line Interface\n");
            ab.parse(args);

            ArgumentContent inputs = ab.getContent("input");

            if (inputs.contents.Count == 0)
            {
                Console.WriteLine("No inputs given. Stopping.\n");

                printHelp(ab);
            }
            else
            {
                string formatName = ab.getContent("outputType").stringValue();
                string formatExtension;
                switch (formatName)
                {
                case "h3d":
                    formatExtension = "bch";
                    break;

                case "gfbmdlp":
                    formatExtension = formatName;
                    break;

                case "gfx":
                    formatExtension = "bcres";
                    break;

                default:
                    Console.WriteLine("Unknown output type: " + formatName);
                    return;
                }

                H3D Scene = new H3D();

                Scene.BackwardCompatibility = (byte)ab.getContent("outputVersion").intValue();
                Scene.ForwardCompatibility  = Scene.BackwardCompatibility;

                for (int i = 0; i < inputs.contents.Count; i++)
                {
                    string inPath = inputs.stringValue(i);
                    if (File.Exists(inPath))
                    {
                        Scene.Merge(FormatIdentifier.IdentifyAndOpen(inPath));
                    }
                }

                ArgumentContent flt = ab.getContent("filter");

                bool deleteModel = true;
                bool deleteTex   = true;
                bool deleteAnime = true;

                for (int i = 0; i < flt.contents.Count; i++)
                {
                    string filter = flt.stringValue(i);
                    switch (filter)
                    {
                    case "model":
                        deleteModel = false;
                        break;

                    case "texture":
                        deleteModel = false;
                        break;

                    case "animation":
                        deleteAnime = false;
                        break;

                    case "all":
                        deleteAnime = false;
                        deleteModel = false;
                        deleteTex   = false;
                        break;

                    default:
                        Console.WriteLine("Warning: unknown filter - " + filter);
                        break;
                    }
                }

                if (deleteModel)
                {
                    Scene.Models.Clear();
                }
                if (deleteTex)
                {
                    Scene.Textures.Clear();
                }
                if (deleteAnime)
                {
                    Scene.MaterialAnimations.Clear();
                    Scene.SkeletalAnimations.Clear();
                    Scene.VisibilityAnimations.Clear();
                    Scene.FogAnimations.Clear();
                    Scene.CameraAnimations.Clear();
                    Scene.LightAnimations.Clear();
                }

                string          outputFilePath = Path.Combine(Directory.GetParent(inputs.stringValue(0)).FullName, Path.GetFileNameWithoutExtension(inputs.stringValue(0)) + "." + formatExtension);
                ArgumentContent outCnt         = ab.getContent("output", true);
                if (outCnt != null)
                {
                    outputFilePath = outCnt.stringValue();
                }

                switch (formatName)
                {
                case "h3d":
                    H3D.Save(outputFilePath, Scene);
                    break;

                case "gfbmdlp":
                    using (BinaryWriter Writer = new BinaryWriter(new FileStream(outputFilePath, FileMode.Create, FileAccess.Write)))
                    {
                        GFModelPack ModelPack = new GFModelPack(Scene);
                        ModelPack.Write(Writer);
                        Writer.Close();
                    }
                    break;

                case "gfx":
                    Gfx.Save(outputFilePath, new Gfx(Scene));
                    break;
                }
            }
        }
Beispiel #35
0
 public static ExecutionResults ExecuteIn(string workingDirectory, string arguments, bool isTeamCity = false)
 {
     var args = new ArgumentBuilder(workingDirectory, arguments, isTeamCity);
     return ExecuteIn(args);
 }
        protected override bool CompileCore(
            CompilerOutputType outputType,
            SupportedArchitecture architecture,
            IEnumerable <string> libraries,
            IEnumerable <string> sourceFilePaths,
            string targetFilePath,
            CompilerOption options,
            IDictionary <string, string> defineConstants)
        {
            ArgumentBuilder clBuilder   = new ArgumentBuilder("/", ":");
            ArgumentBuilder linkBuilder = new ArgumentBuilder("/", ":");

            foreach (var defineConstant in defineConstants)
            {
                DefineConstant(clBuilder, defineConstant.Key, defineConstant.Value);
            }
            DefineConstant(clBuilder, "_WIN32");

            // Suppresses error C4996 for 'getenv' (in debuggees/kitchensink/src/environment.cpp)
            DefineConstant(clBuilder, "_CRT_SECURE_NO_WARNINGS");

            if (options.HasFlag(CompilerOption.GenerateSymbols))
            {
                clBuilder.AppendNamedArgument("ZI", null);
                clBuilder.AppendNamedArgument("Debug", null);
            }

            if (!options.HasFlag(CompilerOption.OptimizeLevel1) &&
                !options.HasFlag(CompilerOption.OptimizeLevel2) &&
                !options.HasFlag(CompilerOption.OptimizeLevel3))
            {
                // Disable optimization
                clBuilder.AppendNamedArgument("Od", null);
            }

            // Add options that are set by default in VS
            AddDefaultOptions(clBuilder);

            if (this.Settings.Properties != null)
            {
                // Get the include folders from the compiler properties
                string rawIncludes;
                if (!this.Settings.Properties.TryGetValue("Include", out rawIncludes))
                {
                    rawIncludes = String.Empty;
                }

                IEnumerable <string> includes = rawIncludes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
                foreach (string include in includes)
                {
                    clBuilder.AppendNamedArgumentQuoted("I", include, string.Empty);
                }

                // Get the lib folders from the compiler properties
                string rawLibs;
                if (!this.Settings.Properties.TryGetValue("Lib", out rawLibs))
                {
                    rawLibs = String.Empty;
                }

                IEnumerable <string> libs = rawLibs.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
                foreach (string lib in libs)
                {
                    linkBuilder.AppendNamedArgumentQuoted("LIBPATH", lib);
                }
            }

            switch (outputType)
            {
            case CompilerOutputType.SharedLibrary:
                // Create.DLL
                clBuilder.AppendNamedArgument("LD", null);
                clBuilder.AppendNamedArgument("Fo", Path.GetDirectoryName(targetFilePath) + Path.DirectorySeparatorChar);
                clBuilder.AppendNamedArgument("Fe", targetFilePath);
                break;

            case CompilerOutputType.ObjectFile:
                // Name obj
                clBuilder.AppendNamedArgument("Fo", targetFilePath);
                break;

            case CompilerOutputType.Unspecified:
            // Treat Unspecified as Executable, since executable is the default
            case CompilerOutputType.Executable:
                // Compiling an executable does not have a command line option, it's the default
                // Name exe
                clBuilder.AppendNamedArgument("Fo", Path.GetDirectoryName(targetFilePath) + Path.DirectorySeparatorChar);
                clBuilder.AppendNamedArgument("Fe", targetFilePath);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(outputType), "Unhandled output type: " + outputType);
            }

            // Specify the PDB name
            clBuilder.AppendNamedArgument("Fd", Path.ChangeExtension(targetFilePath, "pdb"));

            // Define a constant for the platform name.
            DefineConstant(clBuilder, "DEBUGGEE_PLATFORM", GetPlatformName());
            DefineConstant(clBuilder, "DEBUGGEE_COMPILER", "Visual C++");

            foreach (string sourceFilePath in sourceFilePaths)
            {
                clBuilder.AppendArgument(sourceFilePath);
            }

            foreach (string library in libraries)
            {
                clBuilder.AppendArgument(library);
            }

            switch (architecture)
            {
            case SupportedArchitecture.x64:
                DefineConstant(clBuilder, "DEBUGGEE_ARCH", "64");
                linkBuilder.AppendNamedArgument("MACHINE", "X64");
                break;

            case SupportedArchitecture.x86:
                DefineConstant(clBuilder, "DEBUGGEE_ARCH", "32");
                linkBuilder.AppendNamedArgument("MACHINE", "X86");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(architecture), "Unhandled target architecture: " + architecture);
            }

            // Pass the linker arguments (Note, the link parameter doesn't use the ":" suffix)
            clBuilder.AppendNamedArgument("link", linkBuilder.ToString(), overrideSuffix: " ");

            return(0 == this.RunCompiler(clBuilder.ToString(), targetFilePath));
        }