aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2019-10-23 12:53:27 -0700
committerRob Mensching <rob@firegiant.com>2019-10-23 12:57:55 -0700
commit752301ba571020717862d2232e3fad585de6a39a (patch)
treea97ceeb6b762af2dd18d0d561dadeaceda3bf387 /src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
parent11355d03334e300886512411d4649536a5ee65e3 (diff)
downloadwix-752301ba571020717862d2232e3fad585de6a39a.tar.gz
wix-752301ba571020717862d2232e3fad585de6a39a.tar.bz2
wix-752301ba571020717862d2232e3fad585de6a39a.zip
Fix custom tables, small fixes in linker and update latest Data
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs119
1 files changed, 118 insertions, 1 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
index ebb494c0..17cac83a 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs
@@ -11,14 +11,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind
11 using WixToolset.Data.WindowsInstaller; 11 using WixToolset.Data.WindowsInstaller;
12 using WixToolset.Data.WindowsInstaller.Rows; 12 using WixToolset.Data.WindowsInstaller.Rows;
13 using WixToolset.Extensibility; 13 using WixToolset.Extensibility;
14 using WixToolset.Extensibility.Services;
14 15
15 internal class CreateOutputFromIRCommand 16 internal class CreateOutputFromIRCommand
16 { 17 {
17 private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB 18 private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB
18 private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) 19 private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB)
19 20
20 public CreateOutputFromIRCommand(IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions) 21 private static readonly char[] ColonCharacter = new[] { ':' };
22
23 public CreateOutputFromIRCommand(IMessaging messaging, IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions)
21 { 24 {
25 this.Messaging = messaging;
22 this.Section = section; 26 this.Section = section;
23 this.TableDefinitions = tableDefinitions; 27 this.TableDefinitions = tableDefinitions;
24 this.BackendExtensions = backendExtensions; 28 this.BackendExtensions = backendExtensions;
@@ -26,6 +30,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
26 30
27 private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; } 31 private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; }
28 32
33 private IMessaging Messaging { get; }
34
29 private TableDefinitionCollection TableDefinitions { get; } 35 private TableDefinitionCollection TableDefinitions { get; }
30 36
31 private IntermediateSection Section { get; } 37 private IntermediateSection Section { get; }
@@ -49,6 +55,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
49 { 55 {
50 switch (tuple.Definition.Type) 56 switch (tuple.Definition.Type)
51 { 57 {
58 case TupleDefinitionType.AppSearch:
59 this.AddTupleDefaultly(tuple, output);
60 output.EnsureTable(this.TableDefinitions["Signature"]);
61 break;
62
52 case TupleDefinitionType.Binary: 63 case TupleDefinitionType.Binary:
53 this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); 64 this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true);
54 break; 65 break;
@@ -133,6 +144,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
133 this.AddMoveFileTuple((MoveFileTuple)tuple, output); 144 this.AddMoveFileTuple((MoveFileTuple)tuple, output);
134 break; 145 break;
135 146
147 case TupleDefinitionType.ProgId:
148 this.AddTupleDefaultly(tuple, output);
149 output.EnsureTable(this.TableDefinitions["Extension"]);
150 break;
151
136 case TupleDefinitionType.Property: 152 case TupleDefinitionType.Property:
137 this.AddPropertyTuple((PropertyTuple)tuple, output); 153 this.AddPropertyTuple((PropertyTuple)tuple, output);
138 break; 154 break;
@@ -197,6 +213,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind
197 this.AddTupleFromExtension(tuple, output); 213 this.AddTupleFromExtension(tuple, output);
198 break; 214 break;
199 215
216 case TupleDefinitionType.WixCustomRow:
217 this.AddWixCustomRowTuple((WixCustomRowTuple)tuple, output);
218 break;
219
220 case TupleDefinitionType.WixEnsureTable:
221 this.AddWixEnsureTableTuple((WixEnsureTableTuple)tuple, output);
222 break;
223
200 // ignored. 224 // ignored.
201 case TupleDefinitionType.WixFile: 225 case TupleDefinitionType.WixFile:
202 case TupleDefinitionType.WixComponentGroup: 226 case TupleDefinitionType.WixComponentGroup:
@@ -204,6 +228,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
204 case TupleDefinitionType.WixFeatureGroup: 228 case TupleDefinitionType.WixFeatureGroup:
205 break; 229 break;
206 230
231 // Already processed.
232 case TupleDefinitionType.WixCustomTable:
233 break;
234
207 default: 235 default:
208 this.AddTupleDefaultly(tuple, output); 236 this.AddTupleDefaultly(tuple, output);
209 break; 237 break;
@@ -382,6 +410,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind
382 row[7] = tuple.FirstControlRef; 410 row[7] = tuple.FirstControlRef;
383 row[8] = tuple.DefaultControlRef; 411 row[8] = tuple.DefaultControlRef;
384 row[9] = tuple.CancelControlRef; 412 row[9] = tuple.CancelControlRef;
413
414 output.EnsureTable(this.TableDefinitions["ListBox"]);
385 } 415 }
386 416
387 private void AddDirectoryTuple(DirectoryTuple tuple, Output output) 417 private void AddDirectoryTuple(DirectoryTuple tuple, Output output)
@@ -929,6 +959,93 @@ namespace WixToolset.Core.WindowsInstaller.Bind
929 row[2] = tuple.Sequence; 959 row[2] = tuple.Sequence;
930 } 960 }
931 } 961 }
962
963 private void AddWixCustomRowTuple(WixCustomRowTuple tuple, Output output)
964 {
965 var customTableDefinition = this.TableDefinitions[tuple.Table];
966
967 if (customTableDefinition.Unreal)
968 {
969
970 return;
971 }
972
973 var customTable = output.EnsureTable(customTableDefinition);
974 var customRow = customTable.CreateRow(tuple.SourceLineNumbers);
975
976#if TODO // SectionId seems like a good thing to preserve.
977 customRow.SectionId = tuple.SectionId;
978#endif
979
980 var data = tuple.FieldDataSeparated;
981
982 for (var i = 0; i < data.Length; ++i)
983 {
984 var foundColumn = false;
985 var item = data[i].Split(ColonCharacter, 2);
986
987 for (var j = 0; j < customRow.Fields.Length; ++j)
988 {
989 if (customRow.Fields[j].Column.Name == item[0])
990 {
991 if (0 < item[1].Length)
992 {
993 if (ColumnType.Number == customRow.Fields[j].Column.Type)
994 {
995 try
996 {
997 customRow.Fields[j].Data = Convert.ToInt32(item[1], CultureInfo.InvariantCulture);
998 }
999 catch (FormatException)
1000 {
1001 this.Messaging.Write(ErrorMessages.IllegalIntegerValue(tuple.SourceLineNumbers, customTableDefinition.Columns[i].Name, customTableDefinition.Name, item[1]));
1002 }
1003 catch (OverflowException)
1004 {
1005 this.Messaging.Write(ErrorMessages.IllegalIntegerValue(tuple.SourceLineNumbers, customTableDefinition.Columns[i].Name, customTableDefinition.Name, item[1]));
1006 }
1007 }
1008 else if (ColumnCategory.Identifier == customRow.Fields[j].Column.Category)
1009 {
1010 if (Common.IsIdentifier(item[1]) || Common.IsValidBinderVariable(item[1]) || ColumnCategory.Formatted == customRow.Fields[j].Column.Category)
1011 {
1012 customRow.Fields[j].Data = item[1];
1013 }
1014 else
1015 {
1016 this.Messaging.Write(ErrorMessages.IllegalIdentifier(tuple.SourceLineNumbers, "Data", item[1]));
1017 }
1018 }
1019 else
1020 {
1021 customRow.Fields[j].Data = item[1];
1022 }
1023 }
1024 foundColumn = true;
1025 break;
1026 }
1027 }
1028
1029 if (!foundColumn)
1030 {
1031 this.Messaging.Write(ErrorMessages.UnexpectedCustomTableColumn(tuple.SourceLineNumbers, item[0]));
1032 }
1033 }
1034
1035 for (var i = 0; i < customTableDefinition.Columns.Length; ++i)
1036 {
1037 if (!customTableDefinition.Columns[i].Nullable && (null == customRow.Fields[i].Data || 0 == customRow.Fields[i].Data.ToString().Length))
1038 {
1039 this.Messaging.Write(ErrorMessages.NoDataForColumn(tuple.SourceLineNumbers, customTableDefinition.Columns[i].Name, customTableDefinition.Name));
1040 }
1041 }
1042 }
1043
1044 private void AddWixEnsureTableTuple(WixEnsureTableTuple tuple, Output output)
1045 {
1046 var tableDefinition = this.TableDefinitions[tuple.Table];
1047 output.EnsureTable(tableDefinition);
1048 }
932 1049
933 private void AddWixMediaTemplateTuple(WixMediaTemplateTuple tuple, Output output) 1050 private void AddWixMediaTemplateTuple(WixMediaTemplateTuple tuple, Output output)
934 { 1051 {