Store short filenames in separate fields
Rob Mensching committed
Jul 5, 2020 at 23:27 UTC
92bb1d2d74e46714459c2d0fc23f185329745718
2 files changed
+57
-7
src/WixToolset.Converters.Symbolizer/ConvertSymbols.cs
+56
-6
@@ -197,7 +197,20 @@ namespace WixToolset.Converters.Symbolizer
197
case "DrLocator":
198
return DefaultSymbolFromRow(typeof(DrLocatorSymbol), row, columnZeroIsId: false);
199
case "DuplicateFile":
200
- return DefaultSymbolFromRow(typeof(DuplicateFileSymbol), row, columnZeroIsId: true);
200
+ {
201
+ var splitName = FieldAsString(row, 3)?.Split('|');
202
+
203
+ var symbol = new DuplicateFileSymbol(SourceLineNumber4(row.SourceLineNumbers), new Identifier(AccessModifier.Public, FieldAsString(row, 0)))
204
+ {
205
+ ComponentRef = FieldAsString(row, 1),
206
+ FileRef = FieldAsString(row, 2),
207
+ DestinationName = splitName == null ? null : splitName.Length > 1 ? splitName[1] : splitName[0],
208
+ DestinationShortName = splitName == null ? null : splitName.Length > 1 ? splitName[0] : null,
209
+ DestinationFolder = FieldAsString(row, 4)
210
+ };
211
+
212
+ return symbol;
213
+ }
214
case "Error":
215
return DefaultSymbolFromRow(typeof(ErrorSymbol), row, columnZeroIsId: false);
216
case "Extension":
@@ -246,11 +259,13 @@ namespace WixToolset.Converters.Symbolizer
259
symbolAttributes |= (attributes & WindowsInstallerConstants.MsidbFileAttributesCompressed) == WindowsInstallerConstants.MsidbFileAttributesCompressed ? FileSymbolAttributes.Compressed : 0;
260
261
var id = FieldAsString(row, 0);
262
+ var splitName = FieldAsString(row, 2).Split('|');
263
264
var symbol = new FileSymbol(SourceLineNumber4(row.SourceLineNumbers), new Identifier(AccessModifier.Public, id))
265
{
266
ComponentRef = FieldAsString(row, 1),
253
- Name = FieldAsString(row, 2),
267
+ Name = splitName.Length > 1 ? splitName[1] : splitName[0],
268
+ ShortName = splitName.Length > 1 ? splitName[0] : null,
269
FileSize = FieldAsInt(row, 3),
270
Version = FieldAsString(row, 4),
271
Language = FieldAsString(row, 5),
@@ -278,7 +293,6 @@ namespace WixToolset.Converters.Symbolizer
293
symbol.DiskId = FieldAsNullableInt(wixFileRow, 5) ?? 0;
294
symbol.Source = new IntermediateFieldPathValue { Path = FieldAsString(wixFileRow, 6) };
295
symbol.PatchGroup = FieldAsInt(wixFileRow, 8);
281
- symbol.Attributes |= FieldAsInt(wixFileRow, 9) != 0 ? FileSymbolAttributes.GeneratedShortFileName : 0;
296
symbol.PatchAttributes = (PatchAttributeType)FieldAsInt(wixFileRow, 10);
297
}
298
@@ -288,8 +302,41 @@ namespace WixToolset.Converters.Symbolizer
302
return null;
303
case "Icon":
304
return DefaultSymbolFromRow(typeof(IconSymbol), row, columnZeroIsId: true);
305
+ case "IniFile":
306
+ {
307
+ var splitName = FieldAsString(row, 1).Split('|');
308
+ var action = FieldAsInt(row, 6);
309
+
310
+ var symbol = new IniFileSymbol(SourceLineNumber4(row.SourceLineNumbers), new Identifier(AccessModifier.Public, FieldAsString(row, 0)))
311
+ {
312
+ FileName = splitName.Length > 1 ? splitName[1] : splitName[0],
313
+ ShortFileName = splitName.Length > 1 ? splitName[0] : null,
314
+ DirProperty = FieldAsString(row, 2),
315
+ Section = FieldAsString(row, 3),
316
+ Key = FieldAsString(row, 4),
317
+ Value = FieldAsString(row, 5),
318
+ Action = action == 3 ? InifFileActionType.AddTag : action == 1 ? InifFileActionType.CreateLine : InifFileActionType.AddLine,
319
+ ComponentRef = FieldAsString(row, 7),
320
+ };
321
+
322
+ return symbol;
323
+ }
324
case "IniLocator":
292
- return DefaultSymbolFromRow(typeof(IniLocatorSymbol), row, columnZeroIsId: false);
325
+ {
326
+ var splitName = FieldAsString(row, 1).Split('|');
327
+
328
+ var symbol = new IniLocatorSymbol(SourceLineNumber4(row.SourceLineNumbers), new Identifier(AccessModifier.Public, FieldAsString(row, 0)))
329
+ {
330
+ FileName = splitName.Length > 1 ? splitName[1] : splitName[0],
331
+ ShortFileName = splitName.Length > 1 ? splitName[0] : null,
332
+ Section = FieldAsString(row, 2),
333
+ Key = FieldAsString(row, 3),
334
+ Field = FieldAsInt(row, 4),
335
+ Type = FieldAsInt(row, 5),
336
+ };
337
+
338
+ return symbol;
339
+ }
340
case "LockPermissions":
341
return DefaultSymbolFromRow(typeof(LockPermissionsSymbol), row, columnZeroIsId: false);
342
case "Media":
@@ -423,12 +470,15 @@ namespace WixToolset.Converters.Symbolizer
470
}
471
case "RemoveFile":
472
{
473
+ var splitName = FieldAsString(row, 2).Split('|');
474
var installMode = FieldAsInt(row, 4);
475
+
476
return new RemoveFileSymbol(SourceLineNumber4(row.SourceLineNumbers), new Identifier(AccessModifier.Public, FieldAsString(row, 0)))
477
{
478
ComponentRef = FieldAsString(row, 1),
430
- FileName = FieldAsString(row, 2),
431
- DirProperty = FieldAsString(row, 3),
479
+ FileName = splitName.Length > 1 ? splitName[1] : splitName[0],
480
+ ShortFileName = splitName.Length > 1 ? splitName[0] : null,
481
+ DirPropertyRef = FieldAsString(row, 3),
482
OnInstall = (installMode & WindowsInstallerConstants.MsidbRemoveFileInstallModeOnInstall) == WindowsInstallerConstants.MsidbRemoveFileInstallModeOnInstall ? (bool?)true : null,
483
OnUninstall = (installMode & WindowsInstallerConstants.MsidbRemoveFileInstallModeOnRemove) == WindowsInstallerConstants.MsidbRemoveFileInstallModeOnRemove ? (bool?)true : null
484
};
src/test/WixToolsetTest.Converters.Symbolizer/ConvertSymbolsFixture.cs
+1
-1
@@ -317,7 +317,7 @@ namespace WixToolsetTest.Converters.Symbolizer
317
fileSymbol.Source.Path,
318
null, // assembly processor arch
319
fileSymbol.PatchGroup,
320
- (fileSymbol.Attributes & FileSymbolAttributes.GeneratedShortFileName) != 0 ? 1 : 0,
320
+ 0,
321
(int)fileSymbol.PatchAttributes,
322
fileSymbol.RetainLengths,
323
fileSymbol.IgnoreOffsets,