Skip to content

Commit

Permalink
Update SessionExtensions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Jul 7, 2024
1 parent 7c8a0c6 commit 7412042
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions setup/Util/SessionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Linq;

using Microsoft.Deployment.WindowsInstaller;
Expand All @@ -9,8 +10,13 @@ public static class SessionExtensions
{
public static bool IsFeatureEnabledPartial(this Session session, string partialName)
{
FeatureInfo featureInfo =
session.Features.Single(f => f.Name.Contains(partialName, StringComparison.OrdinalIgnoreCase));
FeatureInfo? featureInfo =
session.Features.SingleOrDefault(f => f.Name.Contains(partialName, StringComparison.OrdinalIgnoreCase));

if (featureInfo is null)
{
return false;
}

return featureInfo.RequestState != InstallState.Unknown;
}
Expand Down

0 comments on commit 7412042

Please sign in to comment.