From 271601dfe0990917ef6331fbddcfd1b400882eb2 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 26 Mar 2020 13:31:04 -0400 Subject: Add intermediate levels to track how IR has been lowered. --- src/WixToolset.Data/ErrorMessages.cs | 18 +++++++++++ src/WixToolset.Data/Intermediate.cs | 35 ++++++++++++++++++++-- src/WixToolset.Data/IntermediateLevels.cs | 9 ++++++ .../WindowsInstaller/IntermediateLevels.cs | 9 ++++++ src/test/WixToolsetTest.Data/SerializeFixture.cs | 10 ++++++- 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 src/WixToolset.Data/IntermediateLevels.cs create mode 100644 src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs diff --git a/src/WixToolset.Data/ErrorMessages.cs b/src/WixToolset.Data/ErrorMessages.cs index 43398ad2..1740f6c9 100644 --- a/src/WixToolset.Data/ErrorMessages.cs +++ b/src/WixToolset.Data/ErrorMessages.cs @@ -2249,6 +2249,21 @@ namespace WixToolset.Data return Message(null, Ids.WixiplSourceFileIsExclusive, "When an intermediate post link source file is specified, it must be the only source file provided."); } + public static Message IntermediatesMustBeCompiled(string invalidIntermediates) + { + return Message(null, Ids.IntermediatesMustBeCompiled, "Intermediates being linked must have been compiled. Intermediates with these ids were not compiled: {0}", invalidIntermediates); + } + + public static Message IntermediatesMustBeLinked(string invalidIntermediate) + { + return Message(null, Ids.IntermediatesMustBeLinked, "Intermediates being resolved must have been linked. This intermediate was not linked: {0}", invalidIntermediate); + } + + public static Message IntermediatesMustBeResolved(string invalidIntermediate) + { + return Message(null, Ids.IntermediatesMustBeResolved, "Intermediates being bound must have been resolved. This intermediate was not resolved: {0}", invalidIntermediate); + } + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); @@ -2646,6 +2661,9 @@ namespace WixToolset.Data WixiplSourceFileIsExclusive = 392, UnableToConvertFieldToNumber = 393, CouldNotDetermineProductCodeFromTransformSummaryInfo = 394, + IntermediatesMustBeCompiled = 395, + IntermediatesMustBeLinked = 396, + IntermediatesMustBeResolved = 397, } } } diff --git a/src/WixToolset.Data/Intermediate.cs b/src/WixToolset.Data/Intermediate.cs index 7fc7d6c3..d1c38cf0 100644 --- a/src/WixToolset.Data/Intermediate.cs +++ b/src/WixToolset.Data/Intermediate.cs @@ -29,9 +29,14 @@ namespace WixToolset.Data this.Sections = new List(); } - public Intermediate(string id, IEnumerable sections, IDictionary localizationsByCulture) + public Intermediate(string id, IEnumerable sections, IDictionary localizationsByCulture) : this(id, level: null, sections, localizationsByCulture) + { + } + + public Intermediate(string id, string level, IEnumerable sections, IDictionary localizationsByCulture) { this.Id = id; + this.Level = level; this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary(StringComparer.OrdinalIgnoreCase); this.Sections = (sections != null) ? new List(sections) : new List(); } @@ -41,6 +46,11 @@ namespace WixToolset.Data /// public string Id { get; } + /// + /// Get the id for the intermediate. + /// + public string Level { get; private set; } + /// /// Get the localizations contained in this intermediate. /// @@ -181,6 +191,25 @@ namespace WixToolset.Data return intermediates; } + /// + /// Updates the intermediate level to the specified level. + /// + /// Intermediate level. + public void UpdateLevel(string level) + { + this.Level = String.IsNullOrEmpty(this.Level) ? level : String.Concat(this.Level, ";", level); + } + + /// + /// Returns whether a specifed intermediate level has been set for this intermediate. + /// + /// Intermediate level. + /// True if the specifed intermediate level has been set for this intermediate. + public bool HasLevel(string level) + { + return this.Level?.Contains(level) == true; + } + /// /// Saves an intermediate to a path on disk. /// @@ -277,6 +306,7 @@ namespace WixToolset.Data private static Intermediate FinalizeLoad(JsonObject json, Uri baseUri, ITupleDefinitionCreator creator) { var id = json.GetValueOrDefault("id"); + var level = json.GetValueOrDefault("level"); var sections = new List(); @@ -296,7 +326,7 @@ namespace WixToolset.Data localizations.Add(localization.Culture, localization); } - return new Intermediate(id, sections, localizations); + return new Intermediate(id, level, sections, localizations); } private void SaveEmbedFiles(WixOutput wixout) @@ -351,6 +381,7 @@ namespace WixToolset.Data var jsonObject = new JsonObject { { "id", this.Id }, + { "level", this.Level }, { "version", Intermediate.CurrentVersion.ToString() } }; diff --git a/src/WixToolset.Data/IntermediateLevels.cs b/src/WixToolset.Data/IntermediateLevels.cs new file mode 100644 index 00000000..738cabaa --- /dev/null +++ b/src/WixToolset.Data/IntermediateLevels.cs @@ -0,0 +1,9 @@ +namespace WixToolset.Data +{ + public static class IntermediateLevels + { + public const string Compiled = "compiled"; + public const string Linked = "linked"; + public const string Resolved = "resolved"; + } +} diff --git a/src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs b/src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs new file mode 100644 index 00000000..1eb0ef2d --- /dev/null +++ b/src/WixToolset.Data/WindowsInstaller/IntermediateLevels.cs @@ -0,0 +1,9 @@ +namespace WixToolset.Data.WindowsInstaller +{ + public static class IntermediateLevels + { + // TODO: These are placeholder names until we (hopefully) come up with better ones. + public const string PartiallyBound = "msiPartiallyBound"; + public const string FullyBound = "msiFullyBound"; + } +} diff --git a/src/test/WixToolsetTest.Data/SerializeFixture.cs b/src/test/WixToolsetTest.Data/SerializeFixture.cs index 34e50f36..55460d54 100644 --- a/src/test/WixToolsetTest.Data/SerializeFixture.cs +++ b/src/test/WixToolsetTest.Data/SerializeFixture.cs @@ -26,13 +26,21 @@ namespace WixToolsetTest.Data Location = ComponentLocation.Either, }); - var intermediate = new Intermediate("TestIntermediate", new[] { section }, null); + var intermediate = new Intermediate("TestIntermediate", IntermediateLevels.Compiled, new[] { section }, null); + + intermediate.UpdateLevel(IntermediateLevels.Linked); + intermediate.UpdateLevel(IntermediateLevels.Resolved); var path = Path.GetTempFileName(); intermediate.Save(path); var loaded = Intermediate.Load(path); + Assert.True(loaded.HasLevel(IntermediateLevels.Compiled)); + Assert.True(loaded.HasLevel(IntermediateLevels.Linked)); + Assert.True(loaded.HasLevel(IntermediateLevels.Resolved)); + Assert.False(loaded.HasLevel(WixToolset.Data.WindowsInstaller.IntermediateLevels.PartiallyBound)); + var tuple = (ComponentTuple)loaded.Sections.Single().Tuples.Single(); Assert.Equal("TestComponent", tuple.Id.Id); -- cgit v1.2.3-55-g6feb