aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/ForTestingUseOnlyExtension/ForTestingUseOnlyBurnBackendExtension.cs
blob: cb97984fc4694aecc32babb17e61ffba3e1b3a80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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.

namespace ForTestingUseOnly
{
    using System.Collections.Generic;
    using System.Linq;
    using ForTestingUseOnly.Symbols;
    using WixToolset.Data;
    using WixToolset.Data.Symbols;
    using WixToolset.Extensibility;

    /// <summary>
    /// Extension for doing completely unsupported things in the name of testing.
    /// </summary>
    public class ForTestingUseOnlyBurnBackendExtension : BaseBurnBackendBinderExtension
    {
        private static readonly IntermediateSymbolDefinition[] BurnSymbolDefinitions =
        {
            ForTestingUseOnlySymbolDefinitions.ForTestingUseOnlyBundle,
        };

        protected override IReadOnlyCollection<IntermediateSymbolDefinition> SymbolDefinitions => BurnSymbolDefinitions;

        public override void SymbolsFinalized(IntermediateSection section)
        {
            base.SymbolsFinalized(section);

            this.FinalizeBundleSymbol(section);
        }

        private void FinalizeBundleSymbol(IntermediateSection section)
        {
            var forTestingUseOnlyBundleSymbol = section.Symbols.OfType<ForTestingUseOnlyBundleSymbol>().SingleOrDefault();
            if (null == forTestingUseOnlyBundleSymbol)
            {
                return;
            }

            var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single();
            bundleSymbol.ProviderKey = bundleSymbol.BundleCode = forTestingUseOnlyBundleSymbol.BundleCode;
        }
    }
}