aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/CompilerCore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/CompilerCore.cs')
-rw-r--r--src/WixToolset.Core/CompilerCore.cs150
1 files changed, 13 insertions, 137 deletions
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs
index ea235a97..e87ad886 100644
--- a/src/WixToolset.Core/CompilerCore.cs
+++ b/src/WixToolset.Core/CompilerCore.cs
@@ -17,7 +17,6 @@ namespace WixToolset.Core
17 using WixToolset.Extensibility; 17 using WixToolset.Extensibility;
18 using WixToolset.Extensibility.Data; 18 using WixToolset.Extensibility.Data;
19 using WixToolset.Extensibility.Services; 19 using WixToolset.Extensibility.Services;
20 using Wix = WixToolset.Data.Serialize;
21 20
22 internal enum ValueListKind 21 internal enum ValueListKind
23 { 22 {
@@ -50,9 +49,7 @@ namespace WixToolset.Core
50 private const string IllegalLongFilenameCharacters = @"[\\\?|><:/\*""]"; // illegal: \ ? | > < : / * " 49 private const string IllegalLongFilenameCharacters = @"[\\\?|><:/\*""]"; // illegal: \ ? | > < : / * "
51 private static readonly Regex IllegalLongFilename = new Regex(IllegalLongFilenameCharacters, RegexOptions.Compiled); 50 private static readonly Regex IllegalLongFilename = new Regex(IllegalLongFilenameCharacters, RegexOptions.Compiled);
52 51
53 public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB 52 //public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB
54 public const int MinValueOfMaxCabSizeForLargeFileSplitting = 20; // 20 MB
55 public const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB)
56 53
57 54
58 // Built-in variables (from burn\engine\variable.cpp, "vrgBuiltInVariables", around line 113) 55 // Built-in variables (from burn\engine\variable.cpp, "vrgBuiltInVariables", around line 113)
@@ -354,43 +351,20 @@ namespace WixToolset.Core
354 } 351 }
355 352
356 /// <summary> 353 /// <summary>
357 /// Creates a row in the active section. 354 /// Creates a tuple in the active section.
358 /// </summary> 355 /// </summary>
359 /// <param name="sourceLineNumbers">Source and line number of current row.</param> 356 /// <param name="sourceLineNumbers">Source and line number of current row.</param>
360 /// <param name="tupleType">Name of table to create row in.</param> 357 /// <param name="tupleType">Type of tuple to create.</param>
361 /// <returns>New row.</returns> 358 /// <param name="identifier">Optional identifier.</param>
362 public IntermediateTuple CreateRow(SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null) 359 /// <returns>New tuple.</returns>
363 { 360 public IntermediateTuple CreateTuple(SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, Identifier identifier = null)
364 return this.CreateRow(sourceLineNumbers, tupleType, this.ActiveSection, identifier);
365 }
366
367 /// <summary>
368 /// Creates a row in the active given <paramref name="section"/>.
369 /// </summary>
370 /// <param name="sourceLineNumbers">Source and line number of current row.</param>
371 /// <param name="tupleType">Name of table to create row in.</param>
372 /// <param name="section">The section to which the row is added. If null, the row is added to the active section.</param>
373 /// <returns>New row.</returns>
374 internal IntermediateTuple CreateRow(SourceLineNumber sourceLineNumbers, TupleDefinitionType tupleType, IntermediateSection section, Identifier identifier = null)
375 { 361 {
376 var tupleDefinition = TupleDefinitions.ByType(tupleType); 362 var tupleDefinition = TupleDefinitions.ByType(tupleType);
377 var row = tupleDefinition.CreateTuple(sourceLineNumbers, identifier); 363 var tuple = tupleDefinition.CreateTuple(sourceLineNumbers, identifier);
378 364
379 if (null != identifier) 365 this.ActiveSection.Tuples.Add(tuple);
380 {
381 if (row.Definition.FieldDefinitions[0].Type == IntermediateFieldType.Number)
382 {
383 row.Set(0, Convert.ToInt32(identifier.Id));
384 }
385 else
386 {
387 row.Set(0, identifier.Id);
388 }
389 }
390
391 section.Tuples.Add(row);
392 366
393 return row; 367 return tuple;
394 } 368 }
395 369
396 /// <summary> 370 /// <summary>
@@ -406,20 +380,6 @@ namespace WixToolset.Core
406 } 380 }
407 381
408 /// <summary> 382 /// <summary>
409 /// Creates a patch resource reference to the list of resoures to be filtered when producing a patch. This method should only be used when processing children of a patch family.
410 /// </summary>
411 /// <param name="sourceLineNumbers">Source and line number of current row.</param>
412 /// <param name="tableName">Name of table to create row in.</param>
413 /// <param name="primaryKeys">Array of keys that make up the primary key of the table.</param>
414 /// <returns>New row.</returns>
415 public void CreatePatchFamilyChildReference(SourceLineNumber sourceLineNumbers, string tableName, params string[] primaryKeys)
416 {
417 var patchReferenceRow = this.CreateRow(sourceLineNumbers, TupleDefinitionType.WixPatchRef);
418 patchReferenceRow.Set(0, tableName);
419 patchReferenceRow.Set(1, String.Join("/", primaryKeys));
420 }
421
422 /// <summary>
423 /// Creates a Registry row in the active section. 383 /// Creates a Registry row in the active section.
424 /// </summary> 384 /// </summary>
425 /// <param name="sourceLineNumbers">Source and line number of the current row.</param> 385 /// <param name="sourceLineNumbers">Source and line number of the current row.</param>
@@ -430,7 +390,7 @@ namespace WixToolset.Core
430 /// <param name="componentId">The component which will control installation/uninstallation of the registry entry.</param> 390 /// <param name="componentId">The component which will control installation/uninstallation of the registry entry.</param>
431 public Identifier CreateRegistryRow(SourceLineNumber sourceLineNumbers, RegistryRootType root, string key, string name, string value, string componentId) 391 public Identifier CreateRegistryRow(SourceLineNumber sourceLineNumbers, RegistryRootType root, string key, string name, string value, string componentId)
432 { 392 {
433 return this.parseHelper.CreateRegistryRow(this.ActiveSection, sourceLineNumbers, root, key, name, value, componentId, true); 393 return this.parseHelper.CreateRegistryTuple(this.ActiveSection, sourceLineNumbers, root, key, name, value, componentId, true);
434 } 394 }
435 395
436 /// <summary> 396 /// <summary>
@@ -466,7 +426,7 @@ namespace WixToolset.Core
466 { 426 {
467 if (!this.EncounteredError) 427 if (!this.EncounteredError)
468 { 428 {
469 this.parseHelper.CreateWixGroupRow(this.ActiveSection, sourceLineNumbers, parentType, parentId, childType, childId); 429 this.parseHelper.CreateWixGroupTuple(this.ActiveSection, sourceLineNumbers, parentType, parentId, childType, childId);
470 } 430 }
471 } 431 }
472 432
@@ -753,39 +713,6 @@ namespace WixToolset.Core
753 } 713 }
754 714
755 /// <summary> 715 /// <summary>
756 /// Gets a yes/no/always value and displays an error for an illegal value.
757 /// </summary>
758 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
759 /// <param name="attribute">The attribute containing the value to get.</param>
760 /// <returns>The attribute's YesNoAlwaysType value.</returns>
761 [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")]
762 public YesNoAlwaysType GetAttributeYesNoAlwaysValue(SourceLineNumber sourceLineNumbers, XAttribute attribute)
763 {
764 string value = this.GetAttributeValue(sourceLineNumbers, attribute);
765
766 if (0 < value.Length)
767 {
768 switch (Wix.Enums.ParseYesNoAlwaysType(value))
769 {
770 case Wix.YesNoAlwaysType.@always:
771 return YesNoAlwaysType.Always;
772 case Wix.YesNoAlwaysType.no:
773 return YesNoAlwaysType.No;
774 case Wix.YesNoAlwaysType.yes:
775 return YesNoAlwaysType.Yes;
776 case Wix.YesNoAlwaysType.NotSet:
777 // Previous code never returned 'NotSet'!
778 break;
779 default:
780 this.Write(ErrorMessages.IllegalYesNoAlwaysValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
781 break;
782 }
783 }
784
785 return YesNoAlwaysType.IllegalValue;
786 }
787
788 /// <summary>
789 /// Gets a short filename value and displays an error for an illegal short filename value. 716 /// Gets a short filename value and displays an error for an illegal short filename value.
790 /// </summary> 717 /// </summary>
791 /// <param name="sourceLineNumbers">Source line information about the owner element.</param> 718 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
@@ -855,57 +782,6 @@ namespace WixToolset.Core
855 } 782 }
856 783
857 /// <summary> 784 /// <summary>
858 /// Gets an InstallUninstallType value and displays an error for an illegal value.
859 /// </summary>
860 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
861 /// <param name="attribute">The attribute containing the value to get.</param>
862 /// <returns>The attribute's InstallUninstallType value.</returns>
863 [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")]
864 public Wix.InstallUninstallType GetAttributeInstallUninstallValue(SourceLineNumber sourceLineNumbers, XAttribute attribute)
865 {
866 Wix.InstallUninstallType installUninstall = Wix.InstallUninstallType.NotSet;
867 string value = this.GetAttributeValue(sourceLineNumbers, attribute);
868
869 if (0 < value.Length)
870 {
871 installUninstall = Wix.Enums.ParseInstallUninstallType(value);
872
873 if (Wix.InstallUninstallType.IllegalValue == installUninstall)
874 {
875 // TODO: Find a way to expose the valid values programatically!
876 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
877 "install", "uninstall", "both"));
878 }
879 }
880
881 return installUninstall;
882 }
883
884 /// <summary>
885 /// Gets an ExitType value and displays an error for an illegal value.
886 /// </summary>
887 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
888 /// <param name="attribute">The attribute containing the value to get.</param>
889 /// <returns>The attribute's ExitType value.</returns>
890 [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")]
891 public Wix.ExitType GetAttributeExitValue(SourceLineNumber sourceLineNumbers, XAttribute attribute)
892 {
893 string value = this.GetAttributeValue(sourceLineNumbers, attribute);
894
895 Wix.ExitType result = Wix.ExitType.NotSet;
896 if (!Enum.TryParse<Wix.ExitType>(value, out result))
897 {
898 result = Wix.ExitType.IllegalValue;
899
900 // TODO: Find a way to expose the valid values programatically!
901 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
902 "success", "cancel", "error", "suspend"));
903 }
904
905 return result;
906 }
907
908 /// <summary>
909 /// Gets a Bundle variable value and displays an error for an illegal value. 785 /// Gets a Bundle variable value and displays an error for an illegal value.
910 /// </summary> 786 /// </summary>
911 /// <param name="sourceLineNumbers">Source line information about the owner element.</param> 787 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
@@ -1062,7 +938,7 @@ namespace WixToolset.Core
1062 internal void VerifyRequiredVersion(SourceLineNumber sourceLineNumbers, string requiredVersion) 938 internal void VerifyRequiredVersion(SourceLineNumber sourceLineNumbers, string requiredVersion)
1063 { 939 {
1064 // an null or empty string means any version will work 940 // an null or empty string means any version will work
1065 if (!string.IsNullOrEmpty(requiredVersion)) 941 if (!String.IsNullOrEmpty(requiredVersion))
1066 { 942 {
1067 Assembly caller = Assembly.GetCallingAssembly(); 943 Assembly caller = Assembly.GetCallingAssembly();
1068 AssemblyName name = caller.GetName(); 944 AssemblyName name = caller.GetName();
@@ -1147,7 +1023,7 @@ namespace WixToolset.Core
1147 /// <returns>Identifier for the newly created row.</returns> 1023 /// <returns>Identifier for the newly created row.</returns>
1148 internal Identifier CreateDirectoryRow(SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null) 1024 internal Identifier CreateDirectoryRow(SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null)
1149 { 1025 {
1150 return this.parseHelper.CreateDirectoryRow(this.ActiveSection, sourceLineNumbers, id, parentId, name, this.activeSectionInlinedDirectoryIds, shortName, sourceName, shortSourceName); 1026 return this.parseHelper.CreateDirectoryTuple(this.ActiveSection, sourceLineNumbers, id, parentId, name, this.activeSectionInlinedDirectoryIds, shortName, sourceName, shortSourceName);
1151 } 1027 }
1152 1028
1153 /// <summary> 1029 /// <summary>