Feature condition in WiX4. How? #7601
-
Condition element is no longer supported in WiX4 schema. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
Great, thank you |
Beta Was this translation helpful? Give feedback.
-
Though it is quite unexpected for an API/schema to define relationships this way.
Ironically the description above it also confirms that Condition is a child element of Feature. Like in WiX3. And yet Feature Level documentation states that Level is also defined as a child Level element, with Condition and Value attributes. Seems like the API is not finalized yet. Or it is in fact a defect. As I did some experiments: <Feature Id="feature1_" Title="feature1" Level="3" AllowAbsent="yes">
<Level Condition="1"/> Produces <Feature Id="feature1_" Title="feature1" Level="3" AllowAbsent="yes">
<Level Value="1" Condition="1"/> Builds OK. Feature column Level has value <Feature Id="feature1_" Title="feature1" AllowAbsent="yes">
<Level Value="1" Condition="1"/> Builds OK. Feature column Level has value |
Beta Was this translation helpful? Give feedback.
-
Typo in the documentation. The fix should be out soon-ish.
That is a typo in the error message. The
The scenario you present here is akin to doing the following in C# code: var feature = new Feature { Level = 3 }
if (true)
{
feature.Level = 1;
} I don't think that is even flagged as a warning. So while it is totally valid, it is an absolute waste of processor cycles. |
Beta Was this translation helpful? Give feedback.
-
If you are saying that the problem is the "waste of processor cycle", I am not sure I agree with that. It goes against API good design principles. Regardless of the syntax, C#, Java, WiX etc,. If it was up to me I would drop I would find soon that the user can specify both. Doesn't matter how silly it is, after all, it was me who allowed that, I designed the API. So I would raise a warning about which value is actually used by the compiler (as candle/wix does in some other cases). BTW thank you for raising that defect on my behalf. And thank you for helping me out with the question. Discovering the |
Beta Was this translation helpful? Give feedback.
-
I was not trying to. You have missed my point. I was trying to convince you that having both options available is an API antipattern. I will try again but using a different example. This is how .NET defines public class AssemblyName
{
public ProcessorArchitecture ProcessorArchitecture { get; set; }
public string? Name { get; set; }
public Version? Version { get; set; }
. . .
} If I am designing this type and following your approach I would need to allow access to the nested elements of the public class AssemblyName
{
public ProcessorArchitecture ProcessorArchitecture { get; set; }
public string? Name { get; set; }
public Version? Version { get; set; }
public int? MajorVersion { get; set; }
public int? MinorVersion { get; set; }
public int? BuildVersion { get; set; }
public int? RevisionVersion { get; set; }
. . .
} I do not see this as a good API design decision. Let me help you to debate my point. That approach is not completely unheard of in .NET. Even in the very same namespace you will find: class Assembly
{
public string? FullName { get; }
public AssemblyName GetName();
. . . But in this case, there is a clear distinction of the intent expressed via different member names and different member types (method vs property). Thus if you ask me this is still an acceptable API design. However, if C# syntax allows and I redefine this type as: class Assembly
{
public string? Name { get; set; }
public AssemblyName Name { get; set; }
. . . Then I would also consider it as an antipattern. |
Beta Was this translation helpful? Give feedback.
Feature Level element.