Replace serialization and update WixSdk
Bob Arnson committed
Aug 26, 2020 at 18:43 UTC
07df3ee2da149531ed665624cb8fbf8ec752d9cd
2 files changed
+84
-127
global.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"msbuild-sdks": {
3
- "WixToolset.Sdk": "4.0.0-build-0150"
3
+ "WixToolset.Sdk": "4.0.0-build-0153"
4
},
5
"sdk": {
6
"allowPrerelease": false
src/wixext/UtilCompiler.cs
+83
-126
@@ -478,7 +478,7 @@ namespace WixToolset.Util
478
string after = null;
479
string guid = null;
480
string productCode = null;
481
- var result = Serialize.ComponentSearch.ResultType.NotSet;
481
+ var attributes = WixComponentSearchAttributes.KeyPath;
482
483
foreach (var attrib in element.Attributes())
484
{
@@ -499,14 +499,21 @@ namespace WixToolset.Util
499
productCode = this.ParseHelper.GetAttributeGuidValue(sourceLineNumbers, attrib);
500
break;
501
case "Result":
502
- var resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
503
- if (!Serialize.ComponentSearch.TryParseResultType(resultValue, out result))
502
+ var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
503
+ switch (result)
504
{
505
- this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName,
506
- resultValue,
507
- Serialize.ComponentSearch.ResultType.directory.ToString(),
508
- Serialize.ComponentSearch.ResultType.state.ToString(),
509
- Serialize.ComponentSearch.ResultType.keyPath.ToString()));
505
+ case "directory":
506
+ attributes = WixComponentSearchAttributes.WantDirectory;
507
+ break;
508
+ case "keyPath":
509
+ attributes = WixComponentSearchAttributes.KeyPath;
510
+ break;
511
+ case "state":
512
+ attributes = WixComponentSearchAttributes.State;
513
+ break;
514
+ default:
515
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "directory", "keyPath", "state"));
516
+ break;
517
}
518
break;
519
default:
@@ -527,7 +534,7 @@ namespace WixToolset.Util
534
535
if (null == id)
536
{
530
- id = this.ParseHelper.CreateIdentifier("wcs", variable, condition, after, guid, productCode, result.ToString());
537
+ id = this.ParseHelper.CreateIdentifier("wcs", variable, condition, after, guid, productCode, attributes.ToString());
538
}
539
540
this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
@@ -536,20 +543,6 @@ namespace WixToolset.Util
543
544
if (!this.Messaging.EncounteredError)
545
{
539
- var attributes = WixComponentSearchAttributes.KeyPath;
540
- switch (result)
541
- {
542
- case Serialize.ComponentSearch.ResultType.directory:
543
- attributes = WixComponentSearchAttributes.WantDirectory;
544
- break;
545
- case Serialize.ComponentSearch.ResultType.keyPath:
546
- attributes = WixComponentSearchAttributes.KeyPath;
547
- break;
548
- case Serialize.ComponentSearch.ResultType.state:
549
- attributes = WixComponentSearchAttributes.State;
550
- break;
551
- }
552
-
546
section.AddSymbol(new WixComponentSearchSymbol(sourceLineNumbers, id)
547
{
548
Guid = guid,
@@ -1025,7 +1018,7 @@ namespace WixToolset.Util
1018
string condition = null;
1019
string after = null;
1020
string path = null;
1028
- var result = Serialize.DirectorySearch.ResultType.NotSet;
1021
+ var attributes = WixFileSearchAttributes.IsDirectory;
1022
1023
foreach (var attrib in element.Attributes())
1024
{
@@ -1043,11 +1036,15 @@ namespace WixToolset.Util
1036
path = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true);
1037
break;
1038
case "Result":
1046
- string resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
1047
- if (!Serialize.DirectorySearch.TryParseResultType(resultValue, out result))
1039
+ var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
1040
+ switch (result)
1041
{
1049
- this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName,
1050
- resultValue, Serialize.DirectorySearch.ResultType.exists.ToString()));
1042
+ case "exists":
1043
+ attributes |= WixFileSearchAttributes.WantExists;
1044
+ break;
1045
+ default:
1046
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "exists"));
1047
+ break;
1048
}
1049
break;
1050
default:
@@ -1068,7 +1065,7 @@ namespace WixToolset.Util
1065
1066
if (null == id)
1067
{
1071
- id = this.ParseHelper.CreateIdentifier("wds", variable, condition, after, path, result.ToString());
1068
+ id = this.ParseHelper.CreateIdentifier("wds", variable, condition, after, path, attributes.ToString());
1069
}
1070
1071
this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
@@ -1077,14 +1074,6 @@ namespace WixToolset.Util
1074
1075
if (!this.Messaging.EncounteredError)
1076
{
1080
- var attributes = WixFileSearchAttributes.IsDirectory;
1081
- switch (result)
1082
- {
1083
- case Serialize.DirectorySearch.ResultType.exists:
1084
- attributes |= WixFileSearchAttributes.WantExists;
1085
- break;
1086
- }
1087
-
1077
this.CreateWixFileSearchRow(section, sourceLineNumbers, id, path, attributes);
1078
}
1079
}
@@ -1133,7 +1122,7 @@ namespace WixToolset.Util
1122
string condition = null;
1123
string after = null;
1124
string path = null;
1136
- var result = Serialize.FileSearch.ResultType.NotSet;
1125
+ var attributes = WixFileSearchAttributes.Default;
1126
1127
foreach (var attrib in node.Attributes())
1128
{
@@ -1151,13 +1140,18 @@ namespace WixToolset.Util
1140
path = this.ParseHelper.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true);
1141
break;
1142
case "Result":
1154
- string resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
1155
- if (!Serialize.FileSearch.TryParseResultType(resultValue, out result))
1143
+ string result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
1144
+ switch (result)
1145
{
1157
- this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName,
1158
- resultValue,
1159
- Serialize.FileSearch.ResultType.exists.ToString(),
1160
- Serialize.FileSearch.ResultType.version.ToString()));
1146
+ case "exists":
1147
+ attributes |= WixFileSearchAttributes.WantExists;
1148
+ break;
1149
+ case "version":
1150
+ attributes |= WixFileSearchAttributes.WantVersion;
1151
+ break;
1152
+ default:
1153
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "exists", "version"));
1154
+ break;
1155
}
1156
break;
1157
default:
@@ -1178,7 +1172,7 @@ namespace WixToolset.Util
1172
1173
if (null == id)
1174
{
1181
- id = this.ParseHelper.CreateIdentifier("wfs", variable, condition, after, path, result.ToString());
1175
+ id = this.ParseHelper.CreateIdentifier("wfs", variable, condition, after, path, attributes.ToString());
1176
}
1177
1178
this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
@@ -1187,17 +1181,6 @@ namespace WixToolset.Util
1181
1182
if (!this.Messaging.EncounteredError)
1183
{
1190
- var attributes = WixFileSearchAttributes.Default;
1191
- switch (result)
1192
- {
1193
- case Serialize.FileSearch.ResultType.exists:
1194
- attributes |= WixFileSearchAttributes.WantExists;
1195
- break;
1196
- case Serialize.FileSearch.ResultType.version:
1197
- attributes |= WixFileSearchAttributes.WantVersion;
1198
- break;
1199
- }
1200
-
1184
this.CreateWixFileSearchRow(section, sourceLineNumbers, id, path, attributes);
1185
}
1186
}
@@ -2599,8 +2582,7 @@ namespace WixToolset.Util
2582
string after = null;
2583
string productCode = null;
2584
string upgradeCode = null;
2602
-
2603
- var result = Serialize.ProductSearch.ResultType.NotSet;
2585
+ var attributes = WixProductSearchAttributes.Version;
2586
2587
foreach (var attrib in element.Attributes())
2588
{
@@ -2621,15 +2603,24 @@ namespace WixToolset.Util
2603
upgradeCode = this.ParseHelper.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
2604
break;
2605
case "Result":
2624
- var resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2625
- if (!Serialize.ProductSearch.TryParseResultType(resultValue, out result))
2606
+ var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2607
+ switch (result)
2608
{
2627
- this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName,
2628
- resultValue,
2629
- Serialize.ProductSearch.ResultType.version.ToString(),
2630
- Serialize.ProductSearch.ResultType.language.ToString(),
2631
- Serialize.ProductSearch.ResultType.state.ToString(),
2632
- Serialize.ProductSearch.ResultType.assignment.ToString()));
2609
+ case "version":
2610
+ attributes = WixProductSearchAttributes.Version;
2611
+ break;
2612
+ case "language":
2613
+ attributes = WixProductSearchAttributes.Language;
2614
+ break;
2615
+ case "state":
2616
+ attributes = WixProductSearchAttributes.State;
2617
+ break;
2618
+ case "assignment":
2619
+ attributes = WixProductSearchAttributes.Assignment;
2620
+ break;
2621
+ default:
2622
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "version", "language", "state", "assignment"));
2623
+ break;
2624
}
2625
break;
2626
default:
@@ -2655,7 +2646,7 @@ namespace WixToolset.Util
2646
2647
if (null == id)
2648
{
2658
- id = this.ParseHelper.CreateIdentifier("wps", variable, condition, after, (productCode == null ? upgradeCode : productCode), result.ToString());
2649
+ id = this.ParseHelper.CreateIdentifier("wps", variable, condition, after, (productCode == null ? upgradeCode : productCode), attributes.ToString());
2650
}
2651
2652
this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
@@ -2664,23 +2655,6 @@ namespace WixToolset.Util
2655
2656
if (!this.Messaging.EncounteredError)
2657
{
2667
- var attributes = WixProductSearchAttributes.Version;
2668
- switch (result)
2669
- {
2670
- case Serialize.ProductSearch.ResultType.version:
2671
- attributes = WixProductSearchAttributes.Version;
2672
- break;
2673
- case Serialize.ProductSearch.ResultType.language:
2674
- attributes = WixProductSearchAttributes.Language;
2675
- break;
2676
- case Serialize.ProductSearch.ResultType.state:
2677
- attributes = WixProductSearchAttributes.State;
2678
- break;
2679
- case Serialize.ProductSearch.ResultType.assignment:
2680
- attributes = WixProductSearchAttributes.Assignment;
2681
- break;
2682
- }
2683
-
2658
// set an additional flag if this is an upgrade code
2659
if (null != upgradeCode)
2660
{
@@ -2711,8 +2685,7 @@ namespace WixToolset.Util
2685
string value = null;
2686
var expand = YesNoType.NotSet;
2687
var win64 = YesNoType.NotSet;
2714
- var result = Serialize.RegistrySearch.ResultType.NotSet;
2715
- var format = Serialize.RegistrySearch.FormatType.raw;
2688
+ var attributes = WixRegistrySearchAttributes.Raw | WixRegistrySearchAttributes.WantValue;
2689
2690
foreach (var attrib in element.Attributes())
2691
{
@@ -2739,22 +2712,33 @@ namespace WixToolset.Util
2712
expand = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2713
break;
2714
case "Format":
2742
- string formatValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2743
- if (!String.IsNullOrEmpty(formatValue))
2715
+ string format = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2716
+ switch (format)
2717
{
2745
- if (!Serialize.RegistrySearch.TryParseFormatType(formatValue, out format))
2746
- {
2747
- this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName,
2748
- formatValue, Serialize.RegistrySearch.FormatType.raw.ToString(), Serialize.RegistrySearch.FormatType.compatible.ToString()));
2749
- }
2718
+ case "raw":
2719
+ attributes |= WixRegistrySearchAttributes.Raw;
2720
+ break;
2721
+ case "compatible":
2722
+ attributes |= WixRegistrySearchAttributes.Compatible;
2723
+ break;
2724
+ default:
2725
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, format, "raw", "compatible"));
2726
+ break;
2727
}
2728
break;
2729
case "Result":
2753
- var resultValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2754
- if (!Serialize.RegistrySearch.TryParseResultType(resultValue, out result))
2730
+ var result = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
2731
+ switch (result)
2732
{
2756
- this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName,
2757
- resultValue, Serialize.RegistrySearch.ResultType.exists.ToString(), Serialize.RegistrySearch.ResultType.value.ToString()));
2733
+ case "exists":
2734
+ attributes |= WixRegistrySearchAttributes.WantExists;
2735
+ break;
2736
+ case "value":
2737
+ attributes |= WixRegistrySearchAttributes.WantValue;
2738
+ break;
2739
+ default:
2740
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attrib.Parent.Name.LocalName, attrib.Name.LocalName, result, "exists", "value"));
2741
+ break;
2742
}
2743
break;
2744
case "Win64":
@@ -2781,43 +2765,16 @@ namespace WixToolset.Util
2765
this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Key"));
2766
}
2767
2784
- if (Serialize.RegistrySearch.ResultType.NotSet == result)
2785
- {
2786
- result = Serialize.RegistrySearch.ResultType.value;
2787
- }
2788
-
2768
if (null == id)
2769
{
2791
- id = this.ParseHelper.CreateIdentifier("wrs", variable, condition, after, root.ToString(), key, value, result.ToString());
2792
- }
2793
-
2794
- var attributes = WixRegistrySearchAttributes.Raw;
2795
- switch (format)
2796
- {
2797
- case Serialize.RegistrySearch.FormatType.raw:
2798
- attributes = WixRegistrySearchAttributes.Raw;
2799
- break;
2800
- case Serialize.RegistrySearch.FormatType.compatible:
2801
- attributes = WixRegistrySearchAttributes.Compatible;
2802
- break;
2803
- }
2804
-
2805
- switch (result)
2806
- {
2807
- case Serialize.RegistrySearch.ResultType.exists:
2808
- attributes |= WixRegistrySearchAttributes.WantExists;
2809
- break;
2810
- case Serialize.RegistrySearch.ResultType.value:
2811
- attributes |= WixRegistrySearchAttributes.WantValue;
2812
- break;
2770
+ id = this.ParseHelper.CreateIdentifier("wrs", variable, condition, after, root.ToString(), key, value, attributes.ToString());
2771
}
2772
2773
if (expand == YesNoType.Yes)
2774
{
2775
if (0 != (attributes & WixRegistrySearchAttributes.WantExists))
2776
{
2819
- this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, element.Name.LocalName,
2820
- "ExpandEnvironmentVariables", expand.ToString(), "Result", result.ToString()));
2777
+ this.Messaging.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "ExpandEnvironmentVariables", expand.ToString(), "Result", "exists"));
2778
}
2779
2780
attributes |= WixRegistrySearchAttributes.ExpandEnvironmentVariables;