diff options
| author | Rob Mensching <rob@firegiant.com> | 2021-01-04 14:32:17 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2021-01-04 14:37:26 -0800 |
| commit | 539c7ceb96d787bf485217d51c7a4bcad712b0b3 (patch) | |
| tree | 4f48ea7f9530975abe76bb7d8e2fec9a3db65b1a /src | |
| parent | 2c1f4a40640536f52d7eff717980e9be7785672a (diff) | |
| download | wix-539c7ceb96d787bf485217d51c7a4bcad712b0b3.tar.gz wix-539c7ceb96d787bf485217d51c7a4bcad712b0b3.tar.bz2 wix-539c7ceb96d787bf485217d51c7a4bcad712b0b3.zip | |
Rename Tuple to Symbol
Diffstat (limited to 'src')
| -rw-r--r-- | src/MessagesToMessages/Properties/launchSettings.json | 2 | ||||
| -rw-r--r-- | src/TablesAndTuples/ColumnDefinitionEnums.cs | 2 | ||||
| -rw-r--r-- | src/TablesAndTuples/Program.cs | 130 | ||||
| -rw-r--r-- | src/TablesAndTuples/WixColumnDefinition.cs | 2 | ||||
| -rw-r--r-- | src/TablesAndTuples/WixTableDefinition.cs | 38 | ||||
| -rw-r--r-- | src/WixBuildTools.XsdGen/ElementCollection.cs | 82 |
6 files changed, 128 insertions, 128 deletions
diff --git a/src/MessagesToMessages/Properties/launchSettings.json b/src/MessagesToMessages/Properties/launchSettings.json index a7e764be..dc7570f6 100644 --- a/src/MessagesToMessages/Properties/launchSettings.json +++ b/src/MessagesToMessages/Properties/launchSettings.json | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | { | 1 | { |
| 2 | "profiles": { | 2 | "profiles": { |
| 3 | "TablesAndTuples": { | 3 | "TablesAndSymbols": { |
| 4 | "commandName": "Project", | 4 | "commandName": "Project", |
| 5 | "commandLineArgs": "E:\\src\\wixtoolset\\Core\\src\\WixToolset.Core\\Data\\messages.xml E:\\src\\wixtoolset\\Data\\src\\WixToolset.Data", | 5 | "commandLineArgs": "E:\\src\\wixtoolset\\Core\\src\\WixToolset.Core\\Data\\messages.xml E:\\src\\wixtoolset\\Data\\src\\WixToolset.Data", |
| 6 | "workingDirectory": "E:\\src\\wixtoolset\\Core\\src\\WixToolset.Core\\" | 6 | "workingDirectory": "E:\\src\\wixtoolset\\Core\\src\\WixToolset.Core\\" |
diff --git a/src/TablesAndTuples/ColumnDefinitionEnums.cs b/src/TablesAndTuples/ColumnDefinitionEnums.cs index ac50e1cd..1499500e 100644 --- a/src/TablesAndTuples/ColumnDefinitionEnums.cs +++ b/src/TablesAndTuples/ColumnDefinitionEnums.cs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | namespace TablesAndTuples | 1 | namespace TablesAndSymbols |
| 2 | { | 2 | { |
| 3 | public enum ColumnCategory | 3 | public enum ColumnCategory |
| 4 | { | 4 | { |
diff --git a/src/TablesAndTuples/Program.cs b/src/TablesAndTuples/Program.cs index 83766930..634acf9d 100644 --- a/src/TablesAndTuples/Program.cs +++ b/src/TablesAndTuples/Program.cs | |||
| @@ -7,7 +7,7 @@ using System.Text.RegularExpressions; | |||
| 7 | using System.Xml.Linq; | 7 | using System.Xml.Linq; |
| 8 | using SimpleJson; | 8 | using SimpleJson; |
| 9 | 9 | ||
| 10 | namespace TablesAndTuples | 10 | namespace TablesAndSymbols |
| 11 | { | 11 | { |
| 12 | class Program | 12 | class Program |
| 13 | { | 13 | { |
| @@ -65,11 +65,11 @@ namespace TablesAndTuples | |||
| 65 | 65 | ||
| 66 | foreach (var tableDefinition in tableDefinitions) | 66 | foreach (var tableDefinition in tableDefinitions) |
| 67 | { | 67 | { |
| 68 | if (tableDefinition.Tupleless) | 68 | if (tableDefinition.Symbolless) |
| 69 | { | 69 | { |
| 70 | continue; | 70 | continue; |
| 71 | } | 71 | } |
| 72 | var tupleType = tableDefinition.TupleDefinitionName; | 72 | var symbolType = tableDefinition.SymbolDefinitionName; |
| 73 | 73 | ||
| 74 | var fields = new JsonArray(); | 74 | var fields = new JsonArray(); |
| 75 | var firstField = true; | 75 | var firstField = true; |
| @@ -79,7 +79,7 @@ namespace TablesAndTuples | |||
| 79 | if (firstField) | 79 | if (firstField) |
| 80 | { | 80 | { |
| 81 | firstField = false; | 81 | firstField = false; |
| 82 | if (tableDefinition.TupleIdIsPrimaryKey) | 82 | if (tableDefinition.SymbolIdIsPrimaryKey) |
| 83 | { | 83 | { |
| 84 | continue; | 84 | continue; |
| 85 | } | 85 | } |
| @@ -121,12 +121,12 @@ namespace TablesAndTuples | |||
| 121 | 121 | ||
| 122 | var obj = new JsonObject | 122 | var obj = new JsonObject |
| 123 | { | 123 | { |
| 124 | { tupleType, fields } | 124 | { symbolType, fields } |
| 125 | }; | 125 | }; |
| 126 | array.Add(obj); | 126 | array.Add(obj); |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | array.Sort(CompareTupleDefinitions); | 129 | array.Sort(CompareSymbolDefinitions); |
| 130 | 130 | ||
| 131 | var strat = new PocoJsonSerializerStrategy(); | 131 | var strat = new PocoJsonSerializerStrategy(); |
| 132 | var json = SimpleJson.SimpleJson.SerializeObject(array, strat); | 132 | var json = SimpleJson.SimpleJson.SerializeObject(array, strat); |
| @@ -147,28 +147,28 @@ namespace TablesAndTuples | |||
| 147 | private static void ReadJsonWriteCs(string inputPath, string outputFolder, string prefix) | 147 | private static void ReadJsonWriteCs(string inputPath, string outputFolder, string prefix) |
| 148 | { | 148 | { |
| 149 | var json = File.ReadAllText(inputPath); | 149 | var json = File.ReadAllText(inputPath); |
| 150 | var tuples = SimpleJson.SimpleJson.DeserializeObject(json) as JsonArray; | 150 | var symbols = SimpleJson.SimpleJson.DeserializeObject(json) as JsonArray; |
| 151 | 151 | ||
| 152 | var tupleNames = new List<string>(); | 152 | var symbolNames = new List<string>(); |
| 153 | 153 | ||
| 154 | foreach (var tupleDefinition in tuples.Cast<JsonObject>()) | 154 | foreach (var symbolDefinition in symbols.Cast<JsonObject>()) |
| 155 | { | 155 | { |
| 156 | var tupleName = tupleDefinition.Keys.Single(); | 156 | var symbolName = symbolDefinition.Keys.Single(); |
| 157 | var fields = tupleDefinition.Values.Single() as JsonArray; | 157 | var fields = symbolDefinition.Values.Single() as JsonArray; |
| 158 | 158 | ||
| 159 | var list = GetFields(fields).ToList(); | 159 | var list = GetFields(fields).ToList(); |
| 160 | 160 | ||
| 161 | tupleNames.Add(tupleName); | 161 | symbolNames.Add(symbolName); |
| 162 | 162 | ||
| 163 | var text = GenerateTupleFileText(prefix, tupleName, list); | 163 | var text = GenerateSymbolFileText(prefix, symbolName, list); |
| 164 | 164 | ||
| 165 | var pathTuple = Path.Combine(outputFolder, tupleName + "Tuple.cs"); | 165 | var pathSymbol = Path.Combine(outputFolder, symbolName + "Symbol.cs"); |
| 166 | Console.WriteLine("Writing: {0}", pathTuple); | 166 | Console.WriteLine("Writing: {0}", pathSymbol); |
| 167 | File.WriteAllText(pathTuple, text); | 167 | File.WriteAllText(pathSymbol, text); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | var content = TupleNamesFileContent(prefix, tupleNames); | 170 | var content = SymbolNamesFileContent(prefix, symbolNames); |
| 171 | var pathNames = Path.Combine(outputFolder, String.Concat(prefix, "TupleDefinitions.cs")); | 171 | var pathNames = Path.Combine(outputFolder, String.Concat(prefix, "SymbolDefinitions.cs")); |
| 172 | Console.WriteLine("Writing: {0}", pathNames); | 172 | Console.WriteLine("Writing: {0}", pathNames); |
| 173 | File.WriteAllText(pathNames, content); | 173 | File.WriteAllText(pathNames, content); |
| 174 | } | 174 | } |
| @@ -215,7 +215,7 @@ namespace TablesAndTuples | |||
| 215 | var unrealDef = | 215 | var unrealDef = |
| 216 | " unreal: true,"; | 216 | " unreal: true,"; |
| 217 | var endTableDef = String.Join(Environment.NewLine, | 217 | var endTableDef = String.Join(Environment.NewLine, |
| 218 | " tupleIdIsPrimaryKey: {1}", | 218 | " symbolIdIsPrimaryKey: {1}", |
| 219 | " );", | 219 | " );", |
| 220 | ""); | 220 | ""); |
| 221 | var startAllTablesDef = String.Join(Environment.NewLine, | 221 | var startAllTablesDef = String.Join(Environment.NewLine, |
| @@ -234,8 +234,8 @@ namespace TablesAndTuples | |||
| 234 | sb.AppendLine(startClassDef.Replace("{1}", ns).Replace("{2}", prefix)); | 234 | sb.AppendLine(startClassDef.Replace("{1}", ns).Replace("{2}", prefix)); |
| 235 | foreach (var tableDefinition in tableDefinitions) | 235 | foreach (var tableDefinition in tableDefinitions) |
| 236 | { | 236 | { |
| 237 | var tupleDefinition = tableDefinition.Tupleless ? "null" : $"{prefix}TupleDefinitions.{tableDefinition.TupleDefinitionName}"; | 237 | var symbolDefinition = tableDefinition.Symbolless ? "null" : $"{prefix}SymbolDefinitions.{tableDefinition.SymbolDefinitionName}"; |
| 238 | sb.AppendLine(startTableDef.Replace("{1}", tableDefinition.VariableName).Replace("{2}", tableDefinition.Name).Replace("{3}", tupleDefinition)); | 238 | sb.AppendLine(startTableDef.Replace("{1}", tableDefinition.VariableName).Replace("{2}", tableDefinition.Name).Replace("{3}", symbolDefinition)); |
| 239 | foreach (var columnDefinition in tableDefinition.Columns) | 239 | foreach (var columnDefinition in tableDefinition.Columns) |
| 240 | { | 240 | { |
| 241 | sb.Append(columnDef.Replace("{1}", columnDefinition.Name).Replace("{2}", columnDefinition.Type.ToString()).Replace("{3}", columnDefinition.Length.ToString()) | 241 | sb.Append(columnDef.Replace("{1}", columnDefinition.Name).Replace("{2}", columnDefinition.Type.ToString()).Replace("{3}", columnDefinition.Length.ToString()) |
| @@ -287,7 +287,7 @@ namespace TablesAndTuples | |||
| 287 | { | 287 | { |
| 288 | sb.AppendLine(unrealDef); | 288 | sb.AppendLine(unrealDef); |
| 289 | } | 289 | } |
| 290 | sb.AppendLine(endTableDef.Replace("{1}", tableDefinition.TupleIdIsPrimaryKey.ToString().ToLower())); | 290 | sb.AppendLine(endTableDef.Replace("{1}", tableDefinition.SymbolIdIsPrimaryKey.ToString().ToLower())); |
| 291 | } | 291 | } |
| 292 | sb.AppendLine(startAllTablesDef); | 292 | sb.AppendLine(startAllTablesDef); |
| 293 | foreach (var tableDefinition in tableDefinitions) | 293 | foreach (var tableDefinition in tableDefinitions) |
| @@ -300,7 +300,7 @@ namespace TablesAndTuples | |||
| 300 | return sb.ToString(); | 300 | return sb.ToString(); |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | private static string GenerateTupleFileText(string prefix, string tupleName, List<(string Name, string Type, string ClrType, string AsFunction)> tupleFields) | 303 | private static string GenerateSymbolFileText(string prefix, string symbolName, List<(string Name, string Type, string ClrType, string AsFunction)> symbolFields) |
| 304 | { | 304 | { |
| 305 | var ns = prefix ?? "Data"; | 305 | var ns = prefix ?? "Data"; |
| 306 | var toString = String.IsNullOrEmpty(prefix) ? null : ".ToString()"; | 306 | var toString = String.IsNullOrEmpty(prefix) ? null : ".ToString()"; |
| @@ -312,52 +312,52 @@ namespace TablesAndTuples | |||
| 312 | "{"); | 312 | "{"); |
| 313 | var usingDataDef = | 313 | var usingDataDef = |
| 314 | " using WixToolset.Data;"; | 314 | " using WixToolset.Data;"; |
| 315 | var startTupleDef = String.Join(Environment.NewLine, | 315 | var startSymbolDef = String.Join(Environment.NewLine, |
| 316 | " using WixToolset.{2}.Tuples;", | 316 | " using WixToolset.{2}.Symbols;", |
| 317 | "", | 317 | "", |
| 318 | " public static partial class {3}TupleDefinitions", | 318 | " public static partial class {3}SymbolDefinitions", |
| 319 | " {", | 319 | " {", |
| 320 | " public static readonly IntermediateTupleDefinition {1} = new IntermediateTupleDefinition(", | 320 | " public static readonly IntermediateSymbolDefinition {1} = new IntermediateSymbolDefinition(", |
| 321 | " {3}TupleDefinitionType.{1}{4},", | 321 | " {3}SymbolDefinitionType.{1}{4},", |
| 322 | " new{5}[]", | 322 | " new{5}[]", |
| 323 | " {"); | 323 | " {"); |
| 324 | var fieldDef = | 324 | var fieldDef = |
| 325 | " new IntermediateFieldDefinition(nameof({1}TupleFields.{2}), IntermediateFieldType.{3}),"; | 325 | " new IntermediateFieldDefinition(nameof({1}SymbolFields.{2}), IntermediateFieldType.{3}),"; |
| 326 | var endTupleDef = String.Join(Environment.NewLine, | 326 | var endSymbolDef = String.Join(Environment.NewLine, |
| 327 | " },", | 327 | " },", |
| 328 | " typeof({1}Tuple));", | 328 | " typeof({1}Symbol));", |
| 329 | " }", | 329 | " }", |
| 330 | "}", | 330 | "}", |
| 331 | "", | 331 | "", |
| 332 | "namespace WixToolset.{2}.Tuples", | 332 | "namespace WixToolset.{2}.Symbols", |
| 333 | "{"); | 333 | "{"); |
| 334 | var startEnumDef = String.Join(Environment.NewLine, | 334 | var startEnumDef = String.Join(Environment.NewLine, |
| 335 | " public enum {1}TupleFields", | 335 | " public enum {1}SymbolFields", |
| 336 | " {"); | 336 | " {"); |
| 337 | var fieldEnum = | 337 | var fieldEnum = |
| 338 | " {2},"; | 338 | " {2},"; |
| 339 | var startTuple = String.Join(Environment.NewLine, | 339 | var startSymbol = String.Join(Environment.NewLine, |
| 340 | " }", | 340 | " }", |
| 341 | "", | 341 | "", |
| 342 | " public class {1}Tuple : IntermediateTuple", | 342 | " public class {1}Symbol : IntermediateSymbol", |
| 343 | " {", | 343 | " {", |
| 344 | " public {1}Tuple() : base({3}TupleDefinitions.{1}, null, null)", | 344 | " public {1}Symbol() : base({3}SymbolDefinitions.{1}, null, null)", |
| 345 | " {", | 345 | " {", |
| 346 | " }", | 346 | " }", |
| 347 | "", | 347 | "", |
| 348 | " public {1}Tuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base({3}TupleDefinitions.{1}, sourceLineNumber, id)", | 348 | " public {1}Symbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base({3}SymbolDefinitions.{1}, sourceLineNumber, id)", |
| 349 | " {", | 349 | " {", |
| 350 | " }", | 350 | " }", |
| 351 | "", | 351 | "", |
| 352 | " public IntermediateField this[{1}TupleFields index] => this.Fields[(int)index];"); | 352 | " public IntermediateField this[{1}SymbolFields index] => this.Fields[(int)index];"); |
| 353 | var fieldProp = String.Join(Environment.NewLine, | 353 | var fieldProp = String.Join(Environment.NewLine, |
| 354 | "", | 354 | "", |
| 355 | " public {4} {2}", | 355 | " public {4} {2}", |
| 356 | " {", | 356 | " {", |
| 357 | " get => {6}this.Fields[(int){1}TupleFields.{2}]{5};", | 357 | " get => {6}this.Fields[(int){1}SymbolFields.{2}]{5};", |
| 358 | " set => this.Set((int){1}TupleFields.{2}, value);", | 358 | " set => this.Set((int){1}SymbolFields.{2}, value);", |
| 359 | " }"); | 359 | " }"); |
| 360 | var endTuple = String.Join(Environment.NewLine, | 360 | var endSymbol = String.Join(Environment.NewLine, |
| 361 | " }", | 361 | " }", |
| 362 | "}"); | 362 | "}"); |
| 363 | 363 | ||
| @@ -368,36 +368,36 @@ namespace TablesAndTuples | |||
| 368 | { | 368 | { |
| 369 | sb.AppendLine(usingDataDef); | 369 | sb.AppendLine(usingDataDef); |
| 370 | } | 370 | } |
| 371 | sb.AppendLine(startTupleDef.Replace("{1}", tupleName).Replace("{2}", ns).Replace("{3}", prefix).Replace("{4}", toString).Replace("{5}", tupleFields.Any() ? null : " IntermediateFieldDefinition")); | 371 | sb.AppendLine(startSymbolDef.Replace("{1}", symbolName).Replace("{2}", ns).Replace("{3}", prefix).Replace("{4}", toString).Replace("{5}", symbolFields.Any() ? null : " IntermediateFieldDefinition")); |
| 372 | foreach (var field in tupleFields) | 372 | foreach (var field in symbolFields) |
| 373 | { | 373 | { |
| 374 | sb.AppendLine(fieldDef.Replace("{1}", tupleName).Replace("{2}", field.Name).Replace("{3}", field.Type)); | 374 | sb.AppendLine(fieldDef.Replace("{1}", symbolName).Replace("{2}", field.Name).Replace("{3}", field.Type)); |
| 375 | } | 375 | } |
| 376 | sb.AppendLine(endTupleDef.Replace("{1}", tupleName).Replace("{2}", ns).Replace("{3}", prefix)); | 376 | sb.AppendLine(endSymbolDef.Replace("{1}", symbolName).Replace("{2}", ns).Replace("{3}", prefix)); |
| 377 | if (ns != "Data") | 377 | if (ns != "Data") |
| 378 | { | 378 | { |
| 379 | sb.AppendLine(usingDataDef); | 379 | sb.AppendLine(usingDataDef); |
| 380 | sb.AppendLine(); | 380 | sb.AppendLine(); |
| 381 | } | 381 | } |
| 382 | sb.AppendLine(startEnumDef.Replace("{1}", tupleName)); | 382 | sb.AppendLine(startEnumDef.Replace("{1}", symbolName)); |
| 383 | foreach (var field in tupleFields) | 383 | foreach (var field in symbolFields) |
| 384 | { | 384 | { |
| 385 | sb.AppendLine(fieldEnum.Replace("{1}", tupleName).Replace("{2}", field.Name)); | 385 | sb.AppendLine(fieldEnum.Replace("{1}", symbolName).Replace("{2}", field.Name)); |
| 386 | } | 386 | } |
| 387 | sb.AppendLine(startTuple.Replace("{1}", tupleName).Replace("{2}", ns).Replace("{3}", prefix)); | 387 | sb.AppendLine(startSymbol.Replace("{1}", symbolName).Replace("{2}", ns).Replace("{3}", prefix)); |
| 388 | foreach (var field in tupleFields) | 388 | foreach (var field in symbolFields) |
| 389 | { | 389 | { |
| 390 | var useCast = ns == "Data" && field.AsFunction != "AsPath()"; | 390 | var useCast = ns == "Data" && field.AsFunction != "AsPath()"; |
| 391 | var cast = useCast ? $"({field.ClrType})" : null; | 391 | var cast = useCast ? $"({field.ClrType})" : null; |
| 392 | var asFunction = useCast ? null : $".{field.AsFunction}"; | 392 | var asFunction = useCast ? null : $".{field.AsFunction}"; |
| 393 | sb.AppendLine(fieldProp.Replace("{1}", tupleName).Replace("{2}", field.Name).Replace("{3}", field.Type).Replace("{4}", field.ClrType).Replace("{5}", asFunction).Replace("{6}", cast)); | 393 | sb.AppendLine(fieldProp.Replace("{1}", symbolName).Replace("{2}", field.Name).Replace("{3}", field.Type).Replace("{4}", field.ClrType).Replace("{5}", asFunction).Replace("{6}", cast)); |
| 394 | } | 394 | } |
| 395 | sb.Append(endTuple); | 395 | sb.Append(endSymbol); |
| 396 | 396 | ||
| 397 | return sb.ToString(); | 397 | return sb.ToString(); |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | private static string TupleNamesFileContent(string prefix, List<string> tupleNames) | 400 | private static string SymbolNamesFileContent(string prefix, List<string> symbolNames) |
| 401 | { | 401 | { |
| 402 | var ns = prefix ?? "Data"; | 402 | var ns = prefix ?? "Data"; |
| 403 | 403 | ||
| @@ -409,20 +409,20 @@ namespace TablesAndTuples | |||
| 409 | " using System;", | 409 | " using System;", |
| 410 | " using WixToolset.Data;", | 410 | " using WixToolset.Data;", |
| 411 | "", | 411 | "", |
| 412 | " public enum {3}TupleDefinitionType", | 412 | " public enum {3}SymbolDefinitionType", |
| 413 | " {"); | 413 | " {"); |
| 414 | var namesFormat = | 414 | var namesFormat = |
| 415 | " {1},"; | 415 | " {1},"; |
| 416 | var midpoint = String.Join(Environment.NewLine, | 416 | var midpoint = String.Join(Environment.NewLine, |
| 417 | " }", | 417 | " }", |
| 418 | "", | 418 | "", |
| 419 | " public static partial class {3}TupleDefinitions", | 419 | " public static partial class {3}SymbolDefinitions", |
| 420 | " {", | 420 | " {", |
| 421 | " public static readonly Version Version = new Version(\"4.0.0\");", | 421 | " public static readonly Version Version = new Version(\"4.0.0\");", |
| 422 | "", | 422 | "", |
| 423 | " public static IntermediateTupleDefinition ByName(string name)", | 423 | " public static IntermediateSymbolDefinition ByName(string name)", |
| 424 | " {", | 424 | " {", |
| 425 | " if (!Enum.TryParse(name, out {3}TupleDefinitionType type))", | 425 | " if (!Enum.TryParse(name, out {3}SymbolDefinitionType type))", |
| 426 | " {", | 426 | " {", |
| 427 | " return null;", | 427 | " return null;", |
| 428 | " }", | 428 | " }", |
| @@ -430,14 +430,14 @@ namespace TablesAndTuples | |||
| 430 | " return ByType(type);", | 430 | " return ByType(type);", |
| 431 | " }", | 431 | " }", |
| 432 | "", | 432 | "", |
| 433 | " public static IntermediateTupleDefinition ByType({3}TupleDefinitionType type)", | 433 | " public static IntermediateSymbolDefinition ByType({3}SymbolDefinitionType type)", |
| 434 | " {", | 434 | " {", |
| 435 | " switch (type)", | 435 | " switch (type)", |
| 436 | " {"); | 436 | " {"); |
| 437 | 437 | ||
| 438 | var caseFormat = String.Join(Environment.NewLine, | 438 | var caseFormat = String.Join(Environment.NewLine, |
| 439 | " case {3}TupleDefinitionType.{1}:", | 439 | " case {3}SymbolDefinitionType.{1}:", |
| 440 | " return {3}TupleDefinitions.{1};", | 440 | " return {3}SymbolDefinitions.{1};", |
| 441 | ""); | 441 | ""); |
| 442 | 442 | ||
| 443 | var footer = String.Join(Environment.NewLine, | 443 | var footer = String.Join(Environment.NewLine, |
| @@ -451,14 +451,14 @@ namespace TablesAndTuples | |||
| 451 | var sb = new StringBuilder(); | 451 | var sb = new StringBuilder(); |
| 452 | 452 | ||
| 453 | sb.AppendLine(header.Replace("{2}", ns).Replace("{3}", prefix)); | 453 | sb.AppendLine(header.Replace("{2}", ns).Replace("{3}", prefix)); |
| 454 | foreach (var tupleName in tupleNames) | 454 | foreach (var symbolName in symbolNames) |
| 455 | { | 455 | { |
| 456 | sb.AppendLine(namesFormat.Replace("{1}", tupleName).Replace("{2}", ns).Replace("{3}", prefix)); | 456 | sb.AppendLine(namesFormat.Replace("{1}", symbolName).Replace("{2}", ns).Replace("{3}", prefix)); |
| 457 | } | 457 | } |
| 458 | sb.AppendLine(midpoint.Replace("{2}", ns).Replace("{3}", prefix)); | 458 | sb.AppendLine(midpoint.Replace("{2}", ns).Replace("{3}", prefix)); |
| 459 | foreach (var tupleName in tupleNames) | 459 | foreach (var symbolName in symbolNames) |
| 460 | { | 460 | { |
| 461 | sb.AppendLine(caseFormat.Replace("{1}", tupleName).Replace("{2}", ns).Replace("{3}", prefix)); | 461 | sb.AppendLine(caseFormat.Replace("{1}", symbolName).Replace("{2}", ns).Replace("{3}", prefix)); |
| 462 | } | 462 | } |
| 463 | sb.AppendLine(footer); | 463 | sb.AppendLine(footer); |
| 464 | 464 | ||
| @@ -514,7 +514,7 @@ namespace TablesAndTuples | |||
| 514 | throw new ArgumentException(fieldType); | 514 | throw new ArgumentException(fieldType); |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | private static int CompareTupleDefinitions(object x, object y) | 517 | private static int CompareSymbolDefinitions(object x, object y) |
| 518 | { | 518 | { |
| 519 | var first = (JsonObject)x; | 519 | var first = (JsonObject)x; |
| 520 | var second = (JsonObject)y; | 520 | var second = (JsonObject)y; |
diff --git a/src/TablesAndTuples/WixColumnDefinition.cs b/src/TablesAndTuples/WixColumnDefinition.cs index a40bacfa..2d60c9dc 100644 --- a/src/TablesAndTuples/WixColumnDefinition.cs +++ b/src/TablesAndTuples/WixColumnDefinition.cs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | using System; | 1 | using System; |
| 2 | using System.Xml; | 2 | using System.Xml; |
| 3 | 3 | ||
| 4 | namespace TablesAndTuples | 4 | namespace TablesAndSymbols |
| 5 | { | 5 | { |
| 6 | class WixColumnDefinition | 6 | class WixColumnDefinition |
| 7 | { | 7 | { |
diff --git a/src/TablesAndTuples/WixTableDefinition.cs b/src/TablesAndTuples/WixTableDefinition.cs index a826a174..61dcbb0a 100644 --- a/src/TablesAndTuples/WixTableDefinition.cs +++ b/src/TablesAndTuples/WixTableDefinition.cs | |||
| @@ -2,43 +2,43 @@ using System.Collections.Generic; | |||
| 2 | using System.Linq; | 2 | using System.Linq; |
| 3 | using System.Xml; | 3 | using System.Xml; |
| 4 | 4 | ||
| 5 | namespace TablesAndTuples | 5 | namespace TablesAndSymbols |
| 6 | { | 6 | { |
| 7 | class WixTableDefinition | 7 | class WixTableDefinition |
| 8 | { | 8 | { |
| 9 | public WixTableDefinition(string name, IEnumerable<WixColumnDefinition> columns, bool unreal, bool tupleless, string tupleDefinitionName, bool? tupleIdIsPrimaryKey) | 9 | public WixTableDefinition(string name, IEnumerable<WixColumnDefinition> columns, bool unreal, bool symbolless, string symbolDefinitionName, bool? symbolIdIsPrimaryKey) |
| 10 | { | 10 | { |
| 11 | this.Name = name; | 11 | this.Name = name; |
| 12 | this.VariableName = name.Replace("_", ""); | 12 | this.VariableName = name.Replace("_", ""); |
| 13 | this.Unreal = unreal; | 13 | this.Unreal = unreal; |
| 14 | this.Columns = columns?.ToArray(); | 14 | this.Columns = columns?.ToArray(); |
| 15 | this.Tupleless = tupleless; | 15 | this.Symbolless = symbolless; |
| 16 | this.TupleDefinitionName = tupleless ? null : tupleDefinitionName ?? this.VariableName; | 16 | this.SymbolDefinitionName = symbolless ? null : symbolDefinitionName ?? this.VariableName; |
| 17 | this.TupleIdIsPrimaryKey = tupleIdIsPrimaryKey ?? DeriveTupleIdIsPrimaryKey(this.Columns); | 17 | this.SymbolIdIsPrimaryKey = symbolIdIsPrimaryKey ?? DeriveSymbolIdIsPrimaryKey(this.Columns); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | public string Name { get; } | 20 | public string Name { get; } |
| 21 | 21 | ||
| 22 | public string VariableName { get; } | 22 | public string VariableName { get; } |
| 23 | 23 | ||
| 24 | public string TupleDefinitionName { get; } | 24 | public string SymbolDefinitionName { get; } |
| 25 | 25 | ||
| 26 | public bool Unreal { get; } | 26 | public bool Unreal { get; } |
| 27 | 27 | ||
| 28 | public WixColumnDefinition[] Columns { get; } | 28 | public WixColumnDefinition[] Columns { get; } |
| 29 | 29 | ||
| 30 | public bool TupleIdIsPrimaryKey { get; } | 30 | public bool SymbolIdIsPrimaryKey { get; } |
| 31 | 31 | ||
| 32 | public bool Tupleless { get; } | 32 | public bool Symbolless { get; } |
| 33 | 33 | ||
| 34 | static WixTableDefinition Read(XmlReader reader) | 34 | static WixTableDefinition Read(XmlReader reader) |
| 35 | { | 35 | { |
| 36 | var empty = reader.IsEmptyElement; | 36 | var empty = reader.IsEmptyElement; |
| 37 | string name = null; | 37 | string name = null; |
| 38 | string tupleDefinitionName = null; | 38 | string symbolDefinitionName = null; |
| 39 | var unreal = false; | 39 | var unreal = false; |
| 40 | bool? tupleIdIsPrimaryKey = null; | 40 | bool? symbolIdIsPrimaryKey = null; |
| 41 | var tupleless = false; | 41 | var symbolless = false; |
| 42 | 42 | ||
| 43 | while (reader.MoveToNextAttribute()) | 43 | while (reader.MoveToNextAttribute()) |
| 44 | { | 44 | { |
| @@ -47,14 +47,14 @@ namespace TablesAndTuples | |||
| 47 | case "name": | 47 | case "name": |
| 48 | name = reader.Value; | 48 | name = reader.Value; |
| 49 | break; | 49 | break; |
| 50 | case "tupleDefinitionName": | 50 | case "symbolDefinitionName": |
| 51 | tupleDefinitionName = reader.Value; | 51 | symbolDefinitionName = reader.Value; |
| 52 | break; | 52 | break; |
| 53 | case "tupleIdIsPrimaryKey": | 53 | case "symbolIdIsPrimaryKey": |
| 54 | tupleIdIsPrimaryKey = reader.Value.Equals("yes"); | 54 | symbolIdIsPrimaryKey = reader.Value.Equals("yes"); |
| 55 | break; | 55 | break; |
| 56 | case "tupleless": | 56 | case "symbolless": |
| 57 | tupleless = reader.Value.Equals("yes"); | 57 | symbolless = reader.Value.Equals("yes"); |
| 58 | break; | 58 | break; |
| 59 | case "unreal": | 59 | case "unreal": |
| 60 | unreal = reader.Value.Equals("yes"); | 60 | unreal = reader.Value.Equals("yes"); |
| @@ -101,10 +101,10 @@ namespace TablesAndTuples | |||
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | return new WixTableDefinition(name, columns.ToArray(), unreal, tupleless, tupleDefinitionName, tupleIdIsPrimaryKey); | 104 | return new WixTableDefinition(name, columns.ToArray(), unreal, symbolless, symbolDefinitionName, symbolIdIsPrimaryKey); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | static bool DeriveTupleIdIsPrimaryKey(WixColumnDefinition[] columns) | 107 | static bool DeriveSymbolIdIsPrimaryKey(WixColumnDefinition[] columns) |
| 108 | { | 108 | { |
| 109 | return columns[0].PrimaryKey && | 109 | return columns[0].PrimaryKey && |
| 110 | columns[0].Type == ColumnType.String && | 110 | columns[0].Type == ColumnType.String && |
diff --git a/src/WixBuildTools.XsdGen/ElementCollection.cs b/src/WixBuildTools.XsdGen/ElementCollection.cs index e364dd11..3f0bff16 100644 --- a/src/WixBuildTools.XsdGen/ElementCollection.cs +++ b/src/WixBuildTools.XsdGen/ElementCollection.cs | |||
| @@ -111,7 +111,7 @@ namespace WixToolset.Serialize | |||
| 111 | if (collectionItem.ElementType.IsAssignableFrom(element.GetType())) | 111 | if (collectionItem.ElementType.IsAssignableFrom(element.GetType())) |
| 112 | { | 112 | { |
| 113 | collectionItem.AddElement(element); | 113 | collectionItem.AddElement(element); |
| 114 | 114 | ||
| 115 | if (!containerUsed) | 115 | if (!containerUsed) |
| 116 | { | 116 | { |
| 117 | this.containersUsed++; | 117 | this.containersUsed++; |
| @@ -176,7 +176,7 @@ namespace WixToolset.Serialize | |||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | collectionItem.RemoveElement(element); | 178 | collectionItem.RemoveElement(element); |
| 179 | 179 | ||
| 180 | if (collectionItem.Elements.Count == 0) | 180 | if (collectionItem.Elements.Count == 0) |
| 181 | { | 181 | { |
| 182 | this.containersUsed--; | 182 | this.containersUsed--; |
| @@ -277,7 +277,7 @@ namespace WixToolset.Serialize | |||
| 277 | { | 277 | { |
| 278 | return nestedFilter; | 278 | return nestedFilter; |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | continue; | 281 | continue; |
| 282 | } | 282 | } |
| 283 | } | 283 | } |
| @@ -353,10 +353,10 @@ namespace WixToolset.Serialize | |||
| 353 | { | 353 | { |
| 354 | throw new ArgumentException( | 354 | throw new ArgumentException( |
| 355 | String.Format( | 355 | String.Format( |
| 356 | CultureInfo.InvariantCulture, | 356 | CultureInfo.InvariantCulture, |
| 357 | "Element must be a subclass of {0}, but was of type {1}.", | 357 | "Element must be a subclass of {0}, but was of type {1}.", |
| 358 | this.elementType.Name, | 358 | this.elementType.Name, |
| 359 | element.GetType().Name), | 359 | element.GetType().Name), |
| 360 | "element"); | 360 | "element"); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| @@ -374,10 +374,10 @@ namespace WixToolset.Serialize | |||
| 374 | { | 374 | { |
| 375 | throw new ArgumentException( | 375 | throw new ArgumentException( |
| 376 | String.Format( | 376 | String.Format( |
| 377 | CultureInfo.InvariantCulture, | 377 | CultureInfo.InvariantCulture, |
| 378 | "Element must be a subclass of {0}, but was of type {1}.", | 378 | "Element must be a subclass of {0}, but was of type {1}.", |
| 379 | this.elementType.Name, | 379 | this.elementType.Name, |
| 380 | element.GetType().Name), | 380 | element.GetType().Name), |
| 381 | "element"); | 381 | "element"); |
| 382 | } | 382 | } |
| 383 | 383 | ||
| @@ -454,13 +454,13 @@ namespace WixToolset.Serialize | |||
| 454 | { | 454 | { |
| 455 | if (this.collectionStack != null && this.collectionStack.Count > 0) | 455 | if (this.collectionStack != null && this.collectionStack.Count > 0) |
| 456 | { | 456 | { |
| 457 | CollectionTuple tuple = (CollectionTuple)this.collectionStack.Peek(); | 457 | CollectionSymbol symbol = (CollectionSymbol)this.collectionStack.Peek(); |
| 458 | object container = tuple.Collection.items[tuple.ContainerIndex]; | 458 | object container = symbol.Collection.items[symbol.ContainerIndex]; |
| 459 | 459 | ||
| 460 | CollectionItem collectionItem = container as CollectionItem; | 460 | CollectionItem collectionItem = container as CollectionItem; |
| 461 | if (collectionItem != null) | 461 | if (collectionItem != null) |
| 462 | { | 462 | { |
| 463 | return collectionItem.Elements[tuple.ItemIndex]; | 463 | return collectionItem.Elements[symbol.ItemIndex]; |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | throw new InvalidOperationException(String.Format( | 466 | throw new InvalidOperationException(String.Format( |
| @@ -499,12 +499,12 @@ namespace WixToolset.Serialize | |||
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | this.collectionStack = new Stack(); | 501 | this.collectionStack = new Stack(); |
| 502 | this.collectionStack.Push(new CollectionTuple(this.collection)); | 502 | this.collectionStack.Push(new CollectionSymbol(this.collection)); |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | CollectionTuple tuple = (CollectionTuple)this.collectionStack.Peek(); | 505 | CollectionSymbol symbol = (CollectionSymbol)this.collectionStack.Peek(); |
| 506 | 506 | ||
| 507 | if (this.FindNext(tuple)) | 507 | if (this.FindNext(symbol)) |
| 508 | { | 508 | { |
| 509 | return true; | 509 | return true; |
| 510 | } | 510 | } |
| @@ -532,50 +532,50 @@ namespace WixToolset.Serialize | |||
| 532 | collection.Count)); | 532 | collection.Count)); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | CollectionTuple tuple = new CollectionTuple(collection); | 535 | CollectionSymbol symbol = new CollectionSymbol(collection); |
| 536 | this.collectionStack.Push(tuple); | 536 | this.collectionStack.Push(symbol); |
| 537 | this.FindNext(tuple); | 537 | this.FindNext(symbol); |
| 538 | } | 538 | } |
| 539 | 539 | ||
| 540 | /// <summary> | 540 | /// <summary> |
| 541 | /// Finds the next item from a given tuple. | 541 | /// Finds the next item from a given symbol. |
| 542 | /// </summary> | 542 | /// </summary> |
| 543 | /// <param name="tuple">The tuple to start looking from.</param> | 543 | /// <param name="symbol">The symbol to start looking from.</param> |
| 544 | /// <returns>True if a next element is found, false otherwise.</returns> | 544 | /// <returns>True if a next element is found, false otherwise.</returns> |
| 545 | private bool FindNext(CollectionTuple tuple) | 545 | private bool FindNext(CollectionSymbol symbol) |
| 546 | { | 546 | { |
| 547 | object container = tuple.Collection.items[tuple.ContainerIndex]; | 547 | object container = symbol.Collection.items[symbol.ContainerIndex]; |
| 548 | 548 | ||
| 549 | CollectionItem collectionItem = container as CollectionItem; | 549 | CollectionItem collectionItem = container as CollectionItem; |
| 550 | if (collectionItem != null) | 550 | if (collectionItem != null) |
| 551 | { | 551 | { |
| 552 | if (tuple.ItemIndex + 1 < collectionItem.Elements.Count) | 552 | if (symbol.ItemIndex + 1 < collectionItem.Elements.Count) |
| 553 | { | 553 | { |
| 554 | tuple.ItemIndex++; | 554 | symbol.ItemIndex++; |
| 555 | return true; | 555 | return true; |
| 556 | } | 556 | } |
| 557 | } | 557 | } |
| 558 | 558 | ||
| 559 | ElementCollection elementCollection = container as ElementCollection; | 559 | ElementCollection elementCollection = container as ElementCollection; |
| 560 | if (elementCollection != null && elementCollection.Count > 0 && tuple.ItemIndex == -1) | 560 | if (elementCollection != null && elementCollection.Count > 0 && symbol.ItemIndex == -1) |
| 561 | { | 561 | { |
| 562 | tuple.ItemIndex++; | 562 | symbol.ItemIndex++; |
| 563 | this.PushCollection(elementCollection); | 563 | this.PushCollection(elementCollection); |
| 564 | return true; | 564 | return true; |
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | tuple.ItemIndex = 0; | 567 | symbol.ItemIndex = 0; |
| 568 | 568 | ||
| 569 | for (int i = tuple.ContainerIndex + 1; i < tuple.Collection.items.Count; ++i) | 569 | for (int i = symbol.ContainerIndex + 1; i < symbol.Collection.items.Count; ++i) |
| 570 | { | 570 | { |
| 571 | object nestedContainer = tuple.Collection.items[i]; | 571 | object nestedContainer = symbol.Collection.items[i]; |
| 572 | 572 | ||
| 573 | CollectionItem nestedCollectionItem = nestedContainer as CollectionItem; | 573 | CollectionItem nestedCollectionItem = nestedContainer as CollectionItem; |
| 574 | if (nestedCollectionItem != null) | 574 | if (nestedCollectionItem != null) |
| 575 | { | 575 | { |
| 576 | if (nestedCollectionItem.Elements.Count > 0) | 576 | if (nestedCollectionItem.Elements.Count > 0) |
| 577 | { | 577 | { |
| 578 | tuple.ContainerIndex = i; | 578 | symbol.ContainerIndex = i; |
| 579 | return true; | 579 | return true; |
| 580 | } | 580 | } |
| 581 | } | 581 | } |
| @@ -583,7 +583,7 @@ namespace WixToolset.Serialize | |||
| 583 | ElementCollection nestedElementCollection = nestedContainer as ElementCollection; | 583 | ElementCollection nestedElementCollection = nestedContainer as ElementCollection; |
| 584 | if (nestedElementCollection != null && nestedElementCollection.Count > 0) | 584 | if (nestedElementCollection != null && nestedElementCollection.Count > 0) |
| 585 | { | 585 | { |
| 586 | tuple.ContainerIndex = i; | 586 | symbol.ContainerIndex = i; |
| 587 | this.PushCollection(nestedElementCollection); | 587 | this.PushCollection(nestedElementCollection); |
| 588 | return true; | 588 | return true; |
| 589 | } | 589 | } |
| @@ -596,23 +596,23 @@ namespace WixToolset.Serialize | |||
| 596 | /// Class representing a single point in the collection. Consists of an ElementCollection, | 596 | /// Class representing a single point in the collection. Consists of an ElementCollection, |
| 597 | /// a container index, and an index into the container. | 597 | /// a container index, and an index into the container. |
| 598 | /// </summary> | 598 | /// </summary> |
| 599 | private class CollectionTuple | 599 | private class CollectionSymbol |
| 600 | { | 600 | { |
| 601 | private ElementCollection collection; | 601 | private ElementCollection collection; |
| 602 | private int containerIndex; | 602 | private int containerIndex; |
| 603 | private int itemIndex = -1; | 603 | private int itemIndex = -1; |
| 604 | 604 | ||
| 605 | /// <summary> | 605 | /// <summary> |
| 606 | /// Creates a new CollectionTuple. | 606 | /// Creates a new CollectionSymbol. |
| 607 | /// </summary> | 607 | /// </summary> |
| 608 | /// <param name="collection">The collection for the tuple.</param> | 608 | /// <param name="collection">The collection for the symbol.</param> |
| 609 | public CollectionTuple(ElementCollection collection) | 609 | public CollectionSymbol(ElementCollection collection) |
| 610 | { | 610 | { |
| 611 | this.collection = collection; | 611 | this.collection = collection; |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | /// <summary> | 614 | /// <summary> |
| 615 | /// Gets the collection for the tuple. | 615 | /// Gets the collection for the symbol. |
| 616 | /// </summary> | 616 | /// </summary> |
| 617 | public ElementCollection Collection | 617 | public ElementCollection Collection |
| 618 | { | 618 | { |
