Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Fix #145 - Crash when alias has no file name
Browse files Browse the repository at this point in the history
  • Loading branch information
jibedoubleve committed Oct 4, 2020
1 parent b66a53d commit 1ec6c7d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -13,6 +13,10 @@
<PackageTags>Wox slickrun plugin</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Probel.Lanceur.Core\Probel.Lanceur.Core.csproj" />
<ProjectReference Include="..\..\Probel.Lanceur.SharedKernel\Probel.Lanceur.SharedKernel.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Libraries/Probel.UwpHelpers/UwpAppFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class UwpAppFactory
#region Fields

private readonly AppxPackageHelper _helper = new AppxPackageHelper();
private readonly ILogService _log= LogServiceFactory.Get();
private readonly ILogService _log = LogServiceFactory.Get();

#endregion Fields

Expand Down Expand Up @@ -331,7 +331,7 @@ public UwpApp Create(Package package)

public bool IsUwp(string userId, string alias, out Package package)
{
if (alias == null)
if (string.IsNullOrWhiteSpace(alias))
{
package = null;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Probel.Lanceur.Core/Entities/AliasTextCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static IEnumerable<AliasText> Refresh(this IEnumerable<AliasText> collect
var template = "package:";
foreach (var item in collection)
{
if (item.FileName.ToLower().StartsWith(template))
if (item?.FileName?.ToLower()?.StartsWith(template) ?? false)
{
item.IsPackaged = true;

Expand Down
25 changes: 25 additions & 0 deletions src/Probel.Lanceur/Converters/StringToBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace Probel.Lanceur.Converters
{
public class StringToBooleanConverter : IValueConverter
{
#region Methods

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string str) { return !string.IsNullOrWhiteSpace(str); }
else if (value == null) { return false; }
else { return value; }
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

#endregion Methods
}
}
1 change: 1 addition & 0 deletions src/Probel.Lanceur/Probel.Lanceur.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
<Compile Include="Converters\AliasToFileNameConverter.cs" />
<Compile Include="Converters\NotificationEnumToStringConverter.cs" />
<Compile Include="Converters\PathToHumanizedPathConverter.cs" />
<Compile Include="Converters\StringToBooleanConverter.cs" />
<Compile Include="Converters\UsageToColorConverter.cs" />
<Compile Include="Converters\HexaToColourConverter.cs" />
<Compile Include="Converters\InvertBooleanToVisibilityConverter.cs" />
Expand Down
3 changes: 3 additions & 0 deletions src/Probel.Lanceur/Views/EditAliasView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<Thickness x:Key="DefaultBorder">5 5 5 5</Thickness>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<conv:InvertBooleanToVisibilityConverter x:Key="InvertBooleanToVisibilityConverter" />
<conv:StringToBooleanConverter x:Key="StringToBooleanConverter" />
<ObjectDataProvider
x:Key="RunAsDataProvider"
MethodName="GetValues"
Expand Down Expand Up @@ -99,13 +100,15 @@
Width="120"
Margin="5,5,0,5"
Content="Create"
IsEnabled="{Binding Alias.FileName, Converter={StaticResource StringToBooleanConverter}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource AccentedSquareButtonStyle}"
Visibility="{Binding IsCreation, Converter={StaticResource InvertBooleanToVisibilityConverter}}" />
<Button
x:Name="UpdateAlias"
Width="120"
Margin="5,5,0,5"
Content="Save"
IsEnabled="{Binding Alias.FileName, Converter={StaticResource StringToBooleanConverter}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource AccentedSquareButtonStyle}"
Visibility="{Binding IsCreation, Converter={StaticResource BooleanToVisibilityConverter}}" />
<Button
Expand Down

0 comments on commit 1ec6c7d

Please sign in to comment.