diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-01-01 10:30:42 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-01-01 22:47:02 -0800 |
| commit | 60d7baefb4e87bf0ddaae58a653faee0be0429f6 (patch) | |
| tree | e520865fd6da2368c5d33a4c98cca457bd8a8343 /src/wixext/NetFxDecompiler.cs | |
| parent | 9c66865ab3e4b3c4cbcb721e22fd668dd4350afa (diff) | |
| download | wix-60d7baefb4e87bf0ddaae58a653faee0be0429f6.tar.gz wix-60d7baefb4e87bf0ddaae58a653faee0be0429f6.tar.bz2 wix-60d7baefb4e87bf0ddaae58a653faee0be0429f6.zip | |
Initial code commit
Diffstat (limited to 'src/wixext/NetFxDecompiler.cs')
| -rw-r--r-- | src/wixext/NetFxDecompiler.cs | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/src/wixext/NetFxDecompiler.cs b/src/wixext/NetFxDecompiler.cs new file mode 100644 index 00000000..e30905d1 --- /dev/null +++ b/src/wixext/NetFxDecompiler.cs | |||
| @@ -0,0 +1,139 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Extensions | ||
| 4 | { | ||
| 5 | #if TODO_CONSIDER_DECOMPILER | ||
| 6 | using System; | ||
| 7 | using System.Collections; | ||
| 8 | using System.Diagnostics; | ||
| 9 | using System.Globalization; | ||
| 10 | using WixToolset.Data; | ||
| 11 | using WixToolset.Extensibility; | ||
| 12 | using NetFx = WixToolset.Extensions.Serialize.NetFx; | ||
| 13 | using Wix = WixToolset.Data.Serialize; | ||
| 14 | |||
| 15 | /// <summary> | ||
| 16 | /// The decompiler for the WiX Toolset .NET Framework Extension. | ||
| 17 | /// </summary> | ||
| 18 | public sealed class NetFxDecompiler : DecompilerExtension | ||
| 19 | { | ||
| 20 | /// <summary> | ||
| 21 | /// Creates a decompiler for NetFx Extension. | ||
| 22 | /// </summary> | ||
| 23 | public NetFxDecompiler() | ||
| 24 | { | ||
| 25 | this.TableDefinitions = NetFxExtensionData.GetExtensionTableDefinitions(); | ||
| 26 | } | ||
| 27 | |||
| 28 | /// <summary> | ||
| 29 | /// Get the extensions library to be removed. | ||
| 30 | /// </summary> | ||
| 31 | /// <param name="tableDefinitions">Table definitions for library.</param> | ||
| 32 | /// <returns>Library to remove from decompiled output.</returns> | ||
| 33 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) | ||
| 34 | { | ||
| 35 | return NetFxExtensionData.GetExtensionLibrary(tableDefinitions); | ||
| 36 | } | ||
| 37 | |||
| 38 | /// <summary> | ||
| 39 | /// Decompiles an extension table. | ||
| 40 | /// </summary> | ||
| 41 | /// <param name="table">The table to decompile.</param> | ||
| 42 | public override void DecompileTable(Table table) | ||
| 43 | { | ||
| 44 | switch (table.Name) | ||
| 45 | { | ||
| 46 | case "NetFxNativeImage": | ||
| 47 | this.DecompileNetFxNativeImageTable(table); | ||
| 48 | break; | ||
| 49 | default: | ||
| 50 | base.DecompileTable(table); | ||
| 51 | break; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | /// <summary> | ||
| 56 | /// Decompile the NetFxNativeImage table. | ||
| 57 | /// </summary> | ||
| 58 | /// <param name="table">The table to decompile.</param> | ||
| 59 | private void DecompileNetFxNativeImageTable(Table table) | ||
| 60 | { | ||
| 61 | foreach (Row row in table.Rows) | ||
| 62 | { | ||
| 63 | NetFx.NativeImage nativeImage = new NetFx.NativeImage(); | ||
| 64 | |||
| 65 | nativeImage.Id = (string)row[0]; | ||
| 66 | |||
| 67 | switch ((int)row[2]) | ||
| 68 | { | ||
| 69 | case 0: | ||
| 70 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item0; | ||
| 71 | break; | ||
| 72 | case 1: | ||
| 73 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item1; | ||
| 74 | break; | ||
| 75 | case 2: | ||
| 76 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item2; | ||
| 77 | break; | ||
| 78 | case 3: | ||
| 79 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item3; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | |||
| 83 | if (null != row[3]) | ||
| 84 | { | ||
| 85 | int attributes = (int)row[3]; | ||
| 86 | |||
| 87 | if (0x1 == (attributes & 0x1)) | ||
| 88 | { | ||
| 89 | nativeImage.Debug = NetFx.YesNoType.yes; | ||
| 90 | } | ||
| 91 | |||
| 92 | if (0x2 == (attributes & 0x2)) | ||
| 93 | { | ||
| 94 | nativeImage.Dependencies = NetFx.YesNoType.no; | ||
| 95 | } | ||
| 96 | |||
| 97 | if (0x4 == (attributes & 0x4)) | ||
| 98 | { | ||
| 99 | nativeImage.Profile = NetFx.YesNoType.yes; | ||
| 100 | } | ||
| 101 | |||
| 102 | if (0x8 == (attributes & 0x8) && 0x10 == (attributes & 0x10)) | ||
| 103 | { | ||
| 104 | nativeImage.Platform = NetFx.NativeImage.PlatformType.all; | ||
| 105 | } | ||
| 106 | else if (0x8 == (attributes & 0x8)) | ||
| 107 | { | ||
| 108 | nativeImage.Platform = NetFx.NativeImage.PlatformType.Item32bit; | ||
| 109 | } | ||
| 110 | else if (0x10 == (attributes & 0x10)) | ||
| 111 | { | ||
| 112 | nativeImage.Platform = NetFx.NativeImage.PlatformType.Item64bit; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | if (null != row[4]) | ||
| 117 | { | ||
| 118 | nativeImage.AssemblyApplication = (string)row[4]; | ||
| 119 | } | ||
| 120 | |||
| 121 | if (null != row[5]) | ||
| 122 | { | ||
| 123 | nativeImage.AppBaseDirectory = (string)row[5]; | ||
| 124 | } | ||
| 125 | |||
| 126 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", (string)row[1]); | ||
| 127 | if (null != file) | ||
| 128 | { | ||
| 129 | file.AddChild(nativeImage); | ||
| 130 | } | ||
| 131 | else | ||
| 132 | { | ||
| 133 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "File_", (string)row[1], "File")); | ||
| 134 | } | ||
| 135 | } | ||
| 136 | } | ||
| 137 | } | ||
| 138 | #endif | ||
| 139 | } | ||
