Browse Source

Fixed ArgumentException thrown when duplicate binary file ids are in a WiX file and the dialog is opened in the designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4073 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 16 years ago
parent
commit
41a0fdebbc
  1. 4
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixBinaries.cs
  2. 92
      src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs
  3. 1
      src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

4
src/AddIns/BackendBindings/WixBinding/Project/Src/WixBinaries.cs

@ -99,7 +99,9 @@ namespace ICSharpCode.WixBinding @@ -99,7 +99,9 @@ namespace ICSharpCode.WixBinding
document.Load(textFileReader.Create(fileName));
document.FileName = fileName;
foreach (WixBinaryElement element in document.GetBinaries()) {
binaries.Add(element.Id, element.FileName);
if (!binaries.ContainsKey(element.Id)) {
binaries.Add(element.Id, element.FileName);
}
}
} catch (FileNotFoundException) {
} catch (XmlException) {

92
src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.WixBinding;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using System;
using System.Drawing;
using System.Collections.Generic;
using System.IO;
using WixBinding.Tests.Utils;
namespace WixBinding.Tests.Document
{
/// <summary>
/// Tests that WixBinaries class does not try to add the same binary id to the hash table.
/// </summary>
[TestFixture]
public class DuplicateBinaryIdTestFixture : ITextFileReader
{
WixBinaries binaries;
string projectDirectory;
[TestFixtureSetUp]
public void SetUpFixture()
{
WixProject p = WixBindingTestsHelper.CreateEmptyWixProject();
projectDirectory = p.Directory;
p.Name = "MySetup";
FileProjectItem item = new FileProjectItem(p, ItemType.Compile);
item.Include = "Setup.wxs";
string docFileName = item.FileName;
ProjectService.AddProjectItem(p, item);
item = new FileProjectItem(p, ItemType.Compile);
item.Include = "Binaries.wxs";
ProjectService.AddProjectItem(p, item);
WixDocument doc = new WixDocument(p);
doc.FileName = docFileName;
doc.LoadXml(GetMainWixXml());
binaries = new WixBinaries(doc, this);
}
[Test]
public void GetDialogBitmapFileName()
{
string expectedFileName = Path.Combine(projectDirectory, "Bitmaps/Dialog.bmp");
Assert.AreEqual(expectedFileName, binaries.GetBinaryFileName("Dialog"));
}
public TextReader Create(string fileName)
{
fileName = Path.GetFileName(fileName);
if (fileName == "Binaries.wxs") {
return new StringReader(GetWixFragmentXml());
}
return new StringReader(GetMainWixXml());
}
string GetMainWixXml()
{
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
"\t<Product Name=\"MySetup\" \r\n" +
"\t Manufacturer=\"\" \r\n" +
"\t Id=\"F4A71A3A-C271-4BE8-B72C-F47CC956B3AA\" \r\n" +
"\t Language=\"1033\" \r\n" +
"\t Version=\"1.0.0.0\">\r\n" +
"\t\t<Package Id=\"6B8BE64F-3768-49CA-8BC2-86A76424DFE9\"/>\r\n" +
"\t</Product>\r\n" +
"</Wix>";
}
string GetWixFragmentXml()
{
return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
"\t<Fragment>\r\n" +
"\t\t<Binary Id='Dialog' SourceFile='Bitmaps/Dialog.bmp'/>\r\n" +
"\t\t<Binary Id='Dialog' SourceFile='Bitmaps/Dialog.bmp'/>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
}
}
}

1
src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Diff\MissingDirectoryTestFixture.cs" />
<Compile Include="Document\DuplicateBinaryIdTestFixture.cs" />
<Compile Include="Document\GenerateComponentIdFromDirectoryWithDotsTestFixture.cs" />
<Compile Include="Document\NewWixFileElementTests.cs" />
<Compile Include="Gui\AddDialogsToSetupDialogListTestFixture.cs" />

Loading…
Cancel
Save