aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/ForTestingUseOnlyExtension
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-01-05 21:51:00 -0600
committerSean Hall <r.sean.hall@gmail.com>2022-01-06 23:02:07 -0600
commitc2b00d75493798d9f2452d5e5014b14afcb14889 (patch)
tree7788e6a9caf38ff1e921112cd893e53cccb8efbf /src/test/burn/ForTestingUseOnlyExtension
parent5b48edfd77da6a7f1c499ad30ea95b66f26ee56d (diff)
downloadwix-c2b00d75493798d9f2452d5e5014b14afcb14889.tar.gz
wix-c2b00d75493798d9f2452d5e5014b14afcb14889.tar.bz2
wix-c2b00d75493798d9f2452d5e5014b14afcb14889.zip
Always run upgrade related bundles last.
#5128
Diffstat (limited to 'src/test/burn/ForTestingUseOnlyExtension')
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnly.wixext.csproj15
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyBurnBackendExtension.cs43
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyCompiler.cs77
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionData.cs16
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionFactory.cs18
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlyBundleSymbol.cs47
-rw-r--r--src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlySymbolDefinitions.cs43
7 files changed, 259 insertions, 0 deletions
diff --git a/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnly.wixext.csproj b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnly.wixext.csproj
new file mode 100644
index 00000000..c3861a96
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnly.wixext.csproj
@@ -0,0 +1,15 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4<Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>netstandard2.0</TargetFramework>
7 <RootNamespace>ForTestingUseOnly</RootNamespace>
8 <DebugType>embedded</DebugType>
9 <IncludeSymbols>true</IncludeSymbols>
10 </PropertyGroup>
11
12 <ItemGroup>
13 <PackageReference Include="WixToolset.Extensibility" PrivateAssets="all" />
14 </ItemGroup>
15</Project>
diff --git a/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyBurnBackendExtension.cs b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyBurnBackendExtension.cs
new file mode 100644
index 00000000..fff23274
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyBurnBackendExtension.cs
@@ -0,0 +1,43 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace ForTestingUseOnly
4{
5 using System.Collections.Generic;
6 using System.Linq;
7 using ForTestingUseOnly.Symbols;
8 using WixToolset.Data;
9 using WixToolset.Data.Symbols;
10 using WixToolset.Extensibility;
11
12 /// <summary>
13 /// Extension for doing completely unsupported things in the name of testing.
14 /// </summary>
15 public class ForTestingUseOnlyBurnBackendExtension : BaseBurnBackendBinderExtension
16 {
17 private static readonly IntermediateSymbolDefinition[] BurnSymbolDefinitions =
18 {
19 ForTestingUseOnlySymbolDefinitions.ForTestingUseOnlyBundle,
20 };
21
22 protected override IReadOnlyCollection<IntermediateSymbolDefinition> SymbolDefinitions => BurnSymbolDefinitions;
23
24 public override void SymbolsFinalized(IntermediateSection section)
25 {
26 base.SymbolsFinalized(section);
27
28 this.FinalizeBundleSymbol(section);
29 }
30
31 private void FinalizeBundleSymbol(IntermediateSection section)
32 {
33 var forTestingUseOnlyBundleSymbol = section.Symbols.OfType<ForTestingUseOnlyBundleSymbol>().SingleOrDefault();
34 if (null == forTestingUseOnlyBundleSymbol)
35 {
36 return;
37 }
38
39 var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single();
40 bundleSymbol.ProviderKey = bundleSymbol.BundleId = forTestingUseOnlyBundleSymbol.BundleId;
41 }
42 }
43}
diff --git a/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyCompiler.cs b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyCompiler.cs
new file mode 100644
index 00000000..4963c941
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyCompiler.cs
@@ -0,0 +1,77 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace ForTestingUseOnly
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Xml.Linq;
8 using ForTestingUseOnly.Symbols;
9 using WixToolset.Data;
10 using WixToolset.Extensibility;
11
12 /// <summary>
13 /// Extension for doing completely unsupported things in the name of testing.
14 /// </summary>
15 public sealed class ForTestingUseOnlyCompiler : BaseCompilerExtension
16 {
17 public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/fortestinguseonly";
18
19 public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
20 {
21 switch (element.Name.LocalName)
22 {
23 case "ForTestingUseOnlyBundle":
24 this.ParseForTestingUseOnlyBundleElement(intermediate, section, element);
25 break;
26 default:
27 this.ParseHelper.UnexpectedElement(parentElement, element);
28 break;
29 }
30 }
31
32 private void ParseForTestingUseOnlyBundleElement(Intermediate intermediate, IntermediateSection section, XElement element)
33 {
34 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
35 string bundleId = null;
36
37 foreach (var attrib in element.Attributes())
38 {
39 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
40 {
41 switch (attrib.Name.LocalName)
42 {
43 case "Id":
44 bundleId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
45 break;
46 default:
47 this.ParseHelper.UnexpectedAttribute(element, attrib);
48 break;
49 }
50 }
51 else
52 {
53 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
54 }
55 }
56
57 if (null == bundleId)
58 {
59 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
60 }
61 else
62 {
63 bundleId = Guid.Parse(bundleId).ToString("B").ToUpperInvariant();
64 }
65
66 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
67
68 if (!this.Messaging.EncounteredError)
69 {
70 section.AddSymbol(new ForTestingUseOnlyBundleSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "ForTestingUseOnlyBundle"))
71 {
72 BundleId = bundleId,
73 });
74 }
75 }
76 }
77}
diff --git a/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionData.cs b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionData.cs
new file mode 100644
index 00000000..3276b2db
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionData.cs
@@ -0,0 +1,16 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace ForTestingUseOnly
4{
5 using WixToolset.Data;
6 using WixToolset.Extensibility;
7
8 public sealed class ForTestingUseOnlyExtensionData : BaseExtensionData
9 {
10 public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition)
11 {
12 symbolDefinition = ForTestingUseOnlySymbolDefinitions.ByName(name);
13 return symbolDefinition != null;
14 }
15 }
16}
diff --git a/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionFactory.cs b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionFactory.cs
new file mode 100644
index 00000000..f71a0c2e
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyExtensionFactory.cs
@@ -0,0 +1,18 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace ForTestingUseOnly
4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Extensibility;
8
9 public class ForTestingUseOnlyExtensionFactory : BaseExtensionFactory
10 {
11 protected override IReadOnlyCollection<Type> ExtensionTypes => new[]
12 {
13 typeof(ForTestingUseOnlyCompiler),
14 typeof(ForTestingUseOnlyExtensionData),
15 typeof(ForTestingUseOnlyBurnBackendExtension),
16 };
17 }
18}
diff --git a/src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlyBundleSymbol.cs b/src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlyBundleSymbol.cs
new file mode 100644
index 00000000..a17dfe31
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlyBundleSymbol.cs
@@ -0,0 +1,47 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace ForTestingUseOnly
4{
5 using WixToolset.Data;
6 using ForTestingUseOnly.Symbols;
7
8 public static partial class ForTestingUseOnlySymbolDefinitions
9 {
10 public static readonly IntermediateSymbolDefinition ForTestingUseOnlyBundle = new IntermediateSymbolDefinition(
11 ForTestingUseOnlySymbolDefinitionType.ForTestingUseOnlyBundle.ToString(),
12 new[]
13 {
14 new IntermediateFieldDefinition(nameof(ForTestingUseOnlyBundleSymbolFields.BundleId), IntermediateFieldType.String),
15 },
16 typeof(ForTestingUseOnlyBundleSymbol));
17 }
18}
19
20namespace ForTestingUseOnly.Symbols
21{
22 using WixToolset.Data;
23
24 public enum ForTestingUseOnlyBundleSymbolFields
25 {
26 BundleId,
27 }
28
29 public class ForTestingUseOnlyBundleSymbol : IntermediateSymbol
30 {
31 public ForTestingUseOnlyBundleSymbol() : base(ForTestingUseOnlySymbolDefinitions.ForTestingUseOnlyBundle, null, null)
32 {
33 }
34
35 public ForTestingUseOnlyBundleSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(ForTestingUseOnlySymbolDefinitions.ForTestingUseOnlyBundle, sourceLineNumber, id)
36 {
37 }
38
39 public IntermediateField this[ForTestingUseOnlyBundleSymbolFields index] => this.Fields[(int)index];
40
41 public string BundleId
42 {
43 get => this.Fields[(int)ForTestingUseOnlyBundleSymbolFields.BundleId].AsString();
44 set => this.Set((int)ForTestingUseOnlyBundleSymbolFields.BundleId, value);
45 }
46 }
47}
diff --git a/src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlySymbolDefinitions.cs b/src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlySymbolDefinitions.cs
new file mode 100644
index 00000000..82c3833e
--- /dev/null
+++ b/src/test/burn/ForTestingUseOnlyExtension/Symbols/ForTestingUseOnlySymbolDefinitions.cs
@@ -0,0 +1,43 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace ForTestingUseOnly
4{
5 using System;
6 using WixToolset.Data;
7 using WixToolset.Data.Burn;
8
9 public enum ForTestingUseOnlySymbolDefinitionType
10 {
11 ForTestingUseOnlyBundle,
12 }
13
14 public static partial class ForTestingUseOnlySymbolDefinitions
15 {
16 public static IntermediateSymbolDefinition ByName(string name)
17 {
18 if (!Enum.TryParse(name, out ForTestingUseOnlySymbolDefinitionType type))
19 {
20 return null;
21 }
22
23 return ByType(type);
24 }
25
26 public static IntermediateSymbolDefinition ByType(ForTestingUseOnlySymbolDefinitionType type)
27 {
28 switch (type)
29 {
30 case ForTestingUseOnlySymbolDefinitionType.ForTestingUseOnlyBundle:
31 return ForTestingUseOnlySymbolDefinitions.ForTestingUseOnlyBundle;
32
33 default:
34 throw new ArgumentOutOfRangeException(nameof(type));
35 }
36 }
37
38 static ForTestingUseOnlySymbolDefinitions()
39 {
40 ForTestingUseOnlyBundle.AddTag(BurnConstants.BootstrapperApplicationDataSymbolDefinitionTag);
41 }
42 }
43}