@joebigelow / wix-1 / commits / 302b501f

Fix bug in ParseHelper where it assumed the first column was the id column.

Sean Hall committed Apr 2, 2020 at 18:38 UTC 302b501f9ed2ae840ce598b30792d0fc1b538572
6 files changed +6 -23
src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+1 -17
@@ -981,23 +981,7 @@ namespace WixToolset.Core.ExtensibilityServices
981
982 private static IntermediateTuple CreateTuple(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateTupleDefinition tupleDefinition, Identifier identifier)
983 {
984 - var tuple = tupleDefinition.CreateTuple(sourceLineNumbers, identifier);
985 -
986 - if (null != identifier)
987 - {
988 - if (tuple.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number)
989 - {
990 - tuple.Set(0, Convert.ToInt32(identifier.Id));
991 - }
992 - else
993 - {
994 - tuple.Set(0, identifier.Id);
995 - }
996 - }
997 -
998 - section.Tuples.Add(tuple);
999 -
1000 - return tuple;
984 + return section.AddTuple(tupleDefinition.CreateTuple(sourceLineNumbers, identifier));
985 }
986
987 private static bool TryFindExtension(IEnumerable<ICompilerExtension> extensions, XNamespace ns, out ICompilerExtension extension)
src/test/Example.Extension/ExampleCompilerExtension.cs
+2 -1
@@ -88,7 +88,8 @@ namespace Example.Extension
88
89 if (!this.Messaging.EncounteredError)
90 {
91 - var tuple = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "Example", id);
91 + var tuple = this.ParseHelper.CreateTuple(section, sourceLineNumbers, "Example");
92 + tuple.Set(0, id.Id);
93 tuple.Set(1, value);
94 }
95 }
src/test/Example.Extension/ExampleSearchTuple.cs
-1
@@ -6,7 +6,6 @@ namespace Example.Extension
6
7 public enum ExampleSearchTupleFields
8 {
9 - Example,
9 SearchFor,
10 }
11
src/test/Example.Extension/ExampleTupleDefinitions.cs
-1
@@ -22,7 +22,6 @@ namespace Example.Extension
22 nameof(ExampleSearch),
23 new[]
24 {
25 - new IntermediateFieldDefinition(nameof(ExampleTupleFields.Example), IntermediateFieldType.String),
25 new IntermediateFieldDefinition(nameof(ExampleSearchTupleFields.SearchFor), IntermediateFieldType.String),
26 },
27 typeof(ExampleSearchTuple));
src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
+1 -1
@@ -63,7 +63,7 @@ namespace WixToolsetTest.CoreIntegration
63 Assert.Equal(@"example.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path);
64
65 var example = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).Single();
66 - Assert.Equal("Foo", example.Id.Id);
66 + Assert.Null(example.Id?.Id);
67 Assert.Equal("Foo", example[0].AsString());
68 Assert.Equal("Bar", example[1].AsString());
69 }
src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs
+2 -2
@@ -168,7 +168,7 @@ namespace WixToolsetTest.CoreIntegration
168 Assert.Equal(@"example.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path);
169
170 var example = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).Single();
171 - Assert.Equal("Foo", example.Id.Id);
171 + Assert.Null(example.Id?.Id);
172 Assert.Equal("Foo", example[0].AsString());
173 Assert.Equal("Bar", example[1].AsString());
174 }
@@ -232,7 +232,7 @@ namespace WixToolsetTest.CoreIntegration
232 Assert.Equal(@"other.txt", fileTuples[1][FileTupleFields.Source].PreviousValue.AsPath().Path);
233
234 var examples = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).ToArray();
235 - Assert.Equal(new[] { "Foo", "Other" }, examples.Select(t => t.Id.Id).ToArray());
235 + Assert.Equal(new string[] { null, null }, examples.Select(t => t.Id?.Id).ToArray());
236 Assert.Equal(new[] { "Foo", "Other" }, examples.Select(t => t.AsString(0)).ToArray());
237 Assert.Equal(new[] { "Bar", "Value" }, examples.Select(t => t[1].AsString()).ToArray());
238 }