Beispiel #1
0
        bool ParseAndTypeCheck()
        {
            Dafny.ModuleDecl module      = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
            Dafny.BuiltIns   builtIns    = new Dafny.BuiltIns();
            Dafny.Errors     parseErrors = new VSErrors(this);
            int    errorCount            = Dafny.Parser.Parse(_snapshot.GetText(), _filename, module, builtIns, parseErrors);
            string errString             = Dafny.Main.ParseIncludes(module, builtIns, new List <string>(), parseErrors);

            if (errorCount != 0 || errString != null)
            {
                return(false);
            }
            Dafny.Program program = new Dafny.Program(_filename, module, builtIns);

            var r = new VSResolver(program, this);

            r.ResolveProgram(program);
            if (r.ErrorCount != 0)
            {
                return(false);
            }

            program.AdditionalInformation.AddRange(r.AdditionalInformation);
            _program = program;
            return(true); // success
        }
Beispiel #2
0
        public override bool Build(string projectFileName, string[] targetNames, IDictionary targetOutputs)
        {
            try
            {
                this.buildManager.BeginBuild(this.buildParameters);

                BuildRequestData buildRequestData = new BuildRequestData(this.currentProjectInstance, targetNames, null, BuildRequestDataFlags.ReplaceExistingProjectInstance);

                BuildSubmission submission = this.buildManager.PendBuildRequest(buildRequestData);

                BuildResult buildResult = submission.Execute();

                bool buildSucceeded = buildResult.OverallResult == BuildResultCode.Success;

                this.buildManager.EndBuild();

                // Fill in empty lists for each target so that heat will look at the item group later.
                foreach (string target in targetNames)
                {
                    targetOutputs.Add(target, new List <object>());
                }

                return(buildSucceeded);
            }
            catch (Exception e)
            {
                throw new WixException(VSErrors.CannotBuildProject(projectFileName, e.Message));
            }
        }
Beispiel #3
0
 void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e)
 {
     if (this.HarvesterCore != null)
     {
         // BuildErrorEventArgs adds LineNumber, ColumnNumber, File, amongst other parameters.
         string line = String.Format(CultureInfo.InvariantCulture, "{0}({1},{2}): {3}", e.File, e.LineNumber, e.ColumnNumber, e.Message);
         this.HarvesterCore.OnMessage(VSErrors.BuildErrorDuringHarvesting(line));
     }
 }
Beispiel #4
0
 public override void Load(string projectFileName)
 {
     try
     {
         this.currentProject         = this.projectCollection.LoadProject(projectFileName);
         this.currentProjectInstance = this.currentProject.CreateProjectInstance();
     }
     catch (Exception e)
     {
         throw new WixException(VSErrors.CannotLoadProject(projectFileName, e.Message));
     }
 }
Beispiel #5
0
        /// <summary>
        /// Parse the command line options for this extension.
        /// </summary>
        /// <param name="type">The active harvester type.</param>
        /// <param name="args">The option arguments.</param>
        public override void ParseOptions(string type, string[] args)
        {
            if ("project" == type)
            {
                string[]     allOutputGroups  = VSProjectHarvester.GetOutputGroupNames();
                bool         suppressUniqueId = false;
                bool         generateWixVars  = false;
                GenerateType generateType     = GenerateType.Components;
                string       directoryIds     = null;
                string       projectName      = null;
                string       configuration    = null;
                string       platform         = null;
                ArrayList    outputGroups     = new ArrayList();

                for (int i = 0; i < args.Length; i++)
                {
                    if ("-configuration" == args[i])
                    {
                        configuration = args[++i];
                    }
                    else if ("-directoryid" == args[i])
                    {
                        if (!CommandLine.IsValidArg(args, ++i))
                        {
                            throw new WixException(VSErrors.InvalidDirectoryId(args[i]));
                        }

                        directoryIds = args[i];
                    }
                    else if ("-generate" == args[i])
                    {
                        if (!CommandLine.IsValidArg(args, ++i))
                        {
                            throw new WixException(VSErrors.InvalidOutputType(args[i]));
                        }

                        string genType = args[i].ToUpperInvariant();
                        switch (genType)
                        {
                        case "LAYOUT":
                            generateType = GenerateType.Layout;
                            break;

                        case "CONTAINER":
                            generateType = GenerateType.Container;
                            break;

                        case "COMPONENTS":
                            generateType = GenerateType.Components;
                            break;

                        case "PACKAGEGROUP":
                            generateType = GenerateType.PackageGroup;
                            break;

                        case "PAYLOADGROUP":
                            generateType = GenerateType.PayloadGroup;
                            break;

                        default:
                            throw new WixException(VSErrors.InvalidOutputType(genType));
                        }
                    }
                    else if ("-platform" == args[i])
                    {
                        platform = args[++i];
                    }
                    else if ("-pog" == args[i])
                    {
                        if (!CommandLine.IsValidArg(args, ++i))
                        {
                            throw new WixException(VSErrors.InvalidOutputGroup(args[i]));
                        }

                        string pogName = args[i];
                        bool   found   = false;
                        foreach (string availableOutputGroup in allOutputGroups)
                        {
                            if (String.Equals(pogName, availableOutputGroup, StringComparison.Ordinal))
                            {
                                outputGroups.Add(availableOutputGroup);
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            throw new WixException(VSErrors.InvalidOutputGroup(pogName));
                        }
                    }
                    else if (args[i].StartsWith("-pog:", StringComparison.Ordinal))
                    {
                        this.MessageHandler.Display(this, WixWarnings.DeprecatedCommandLineSwitch("pog:", "pog"));

                        string pogName = args[i].Substring(5);
                        bool   found   = false;
                        foreach (string availableOutputGroup in allOutputGroups)
                        {
                            if (String.Equals(pogName, availableOutputGroup, StringComparison.Ordinal))
                            {
                                outputGroups.Add(availableOutputGroup);
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            throw new WixException(VSErrors.InvalidOutputGroup(pogName));
                        }
                    }
                    else if ("-projectname" == args[i])
                    {
                        if (!CommandLine.IsValidArg(args, ++i))
                        {
                            throw new WixException(VSErrors.InvalidProjectName(args[i]));
                        }

                        projectName = args[i];
                    }
                    else if ("-suid" == args[i])
                    {
                        suppressUniqueId = true;
                    }
                    else if ("-wixvar" == args[i])
                    {
                        generateWixVars = true;
                    }
                }

                if (outputGroups.Count == 0)
                {
                    throw new WixException(VSErrors.NoOutputGroupSpecified());
                }

                VSProjectHarvester harvester = new VSProjectHarvester(
                    (string[])outputGroups.ToArray(typeof(string)));

                harvester.SetUniqueIdentifiers = !suppressUniqueId;
                harvester.GenerateWixVars      = generateWixVars;
                harvester.GenerateType         = generateType;
                harvester.DirectoryIds         = directoryIds;
                harvester.ProjectName          = projectName;
                harvester.Configuration        = configuration;
                harvester.Platform             = platform;

                this.Core.Harvester.Extension = harvester;
            }
        }
Beispiel #6
0
    bool ParseAndTypeCheck() {
      Dafny.ModuleDecl module = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
      Dafny.BuiltIns builtIns = new Dafny.BuiltIns();
      Dafny.Errors parseErrors = new VSErrors(this);
      int errorCount = Dafny.Parser.Parse(_snapshot.GetText(), _filename, module, builtIns, parseErrors);
      string errString = Dafny.Main.ParseIncludes(module, builtIns, new List<string>(), parseErrors);
      if (errorCount != 0 || errString != null)
        return false;
      Dafny.Program program = new Dafny.Program(_filename, module, builtIns);

      var r = new VSResolver(program, this);
      r.ResolveProgram(program);
      if (r.ErrorCount != 0)
        return false;

      program.AdditionalInformation.AddRange(r.AdditionalInformation);
      _program = program;
      return true;  // success
    }