Example #1
0
        public static EventManifest LoadManifest(Stream input, string inputName)
        {
            var diagSink = new DiagnosticSink();
            var diags    = new DiagnosticsEngine(diagSink);

            var parser   = EventManifestParser.CreateWithWinmeta(diags);
            var manifest = parser.ParseManifest(input, inputName);

            diagSink.AssertNoErrors();

            MessageHelpers.AssignMessageIds(diags, manifest, () => new StableMessageIdGenerator(diags));

            diagSink.AssertNoErrors();
            return(manifest);
        }
        public int Execute()
        {
            bool hasManifests        = options.Inputs != null && options.Inputs.Count > 0;
            bool hasResOnlyManifests =
                options.ResourceGenOnlyInputs != null &&
                options.ResourceGenOnlyInputs.Count > 0;

            if (!hasManifests && !hasResOnlyManifests)
            {
                diags.ReportError("No input manifest specified.");
                Program.ShowBriefHelp();
                return(ExitCode.UserError);
            }

            if (hasManifests && options.Inputs.Count > 1)
            {
                diags.ReportError("Too many input manifests specified.");
                Program.ShowBriefHelp();
                return(ExitCode.UserError);
            }

            var parser = EventManifestParser.CreateWithWinmeta(
                diags, options.SchemaPath, options.WinmetaPath);

            var compilation = EventManifestCompilation.Create(diags, options);

            if (compilation == null)
            {
                return(ExitCode.Error);
            }

            var trap            = diags.TrapError();
            var manifests       = options.Inputs.Select(x => parser.ParseManifest(x)).ToList();
            var resGenManifests = options.ResourceGenOnlyInputs.Select(x => parser.ParseManifest(x)).ToList();

            if (trap.ErrorOccurred)
            {
                return(ExitCode.Error);
            }

            if (!compilation.AddManifests(manifests) ||
                !compilation.AddResourceGenManifests(resGenManifests))
            {
                return(ExitCode.Error);
            }

            return(compilation.Emit() ? ExitCode.Success : ExitCode.Error);
        }
Example #3
0
        public SolutionTraceSettingsContext(ISolutionBrowser solutionBrowser = null)
        {
            this.solutionBrowser = solutionBrowser;

            ProjectsInSolution  = FindProjects();
            ManifestsInSolution = ThreadingExtensions.CreateAsyncLazy(FindManifests);

            manifestCache = new FileLruCache <EventManifest>(
                10, path => {
                var diags = new DiagnosticCollector();

                var parser   = EventManifestParser.CreateWithWinmeta(diags);
                var manifest = parser.ParseManifest(path);
                if (manifest == null || diags.Diagnostics.Count != 0)
                {
                    throw new Exception(
                        string.Join("\r\n", diags.Diagnostics.Select(x => x.Message)));
                }

                return(manifest);
            });
        }
Example #4
0
 protected ValidationTest()
 {
     diags  = new DiagnosticsCollector();
     parser = EventManifestParser.CreateWithWinmeta(diags);
 }