Skip to content

Commit

Permalink
#1732: If any of Extensions.GenericEntities, MIMETypes, or Verbs are …
Browse files Browse the repository at this point in the history
…set, all must be set
  • Loading branch information
oleg-shilo committed Jan 22, 2025
1 parent 2c72aac commit c9deed0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
19 changes: 17 additions & 2 deletions Source/src/WixSharp.Samples/Wix# Samples/ComServer/setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//css_ref Wix_bin\WixToolset.Dtf.WindowsInstaller.dll;
//css_ref System.Core.dll;
using System;
using System.Diagnostics;
using WixSharp;

class Script
Expand All @@ -25,7 +26,7 @@ static public void Build()
var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
new File(@"Files\Bin\MyApp.exe",
new File(new Id("MyApp.exe"), @"Files\Bin\MyApp.exe",
new TypeLib
{
Id = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"),
Expand All @@ -50,6 +51,21 @@ static public void Build()
{
Id = "prog.id",
Description="some description"
,Extensions = new[]
{
new Extension
{
ContentType = "text/plain",
Verbs = new []
{
new Verb
{
TargetFile = "MyApp.exe",
}
},

}
}
}
}
}
Expand All @@ -58,7 +74,6 @@ static public void Build()

project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
// project.PreserveTempFiles = true;

project.BuildMsi();
}

Expand Down
29 changes: 13 additions & 16 deletions Source/src/WixSharp/ComRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,17 +576,17 @@ public Extension()
/// Extensibility point in the WiX XML Schema.
/// Schema extensions can register additional attributes at this point in the schema.
/// </summary>
public IGenericEntity[] GenericEntities;
public IGenericEntity[] GenericEntities = new IGenericEntity[0];

/// <summary>
/// MIME content-types for an <see cref="Extension"/>.
/// </summary>
public MimeType[] MIMETypes;
public MimeType[] MIMETypes = new MimeType[0];

/// <summary>
/// Verb definitions for an <see cref="Extension"/>.
/// </summary>
public Verb[] Verbs;
public Verb[] Verbs = new Verb[0];

/// <summary>
/// Adds itself as an XML content into the WiX source being generated from the <see cref="Project" />.
Expand All @@ -606,20 +606,17 @@ public void Process(ProcessingContext context)
if (!Advertise.HasValue)
Advertise = false;

if (GenericEntities?.Length > 0 || MIMETypes?.Length > 0 || Verbs?.Length > 0)
var extensionContext = new ProcessingContext
{
var extensionContext = new ProcessingContext
{
Project = context.Project,
Parent = this,
FeatureComponents = context.FeatureComponents,
XParent = element
};

_ = GenericEntities.ForEach(e => e.Process(extensionContext));
_ = MIMETypes.ForEach(t => t.Process(extensionContext));
_ = Verbs.ForEach(v => v.Process(extensionContext));
}
Project = context.Project,
Parent = this,
FeatureComponents = context.FeatureComponents,
XParent = element
};

GenericEntities.ForEach(e => e.Process(extensionContext));
MIMETypes.ForEach(t => t.Process(extensionContext));
Verbs.ForEach(v => v.Process(extensionContext));

context.XParent.Add(element);
}
Expand Down

0 comments on commit c9deed0

Please sign in to comment.