Skip to content

Commit

Permalink
Version/2.6.0 (#485)
Browse files Browse the repository at this point in the history
* (#407) Fix NullReferenceException when description too long

* (#408) Display description on 95 chars

* (#407) Fix NullReferenceException when description too long

* (#408) Display description on 95 chars

* (#407) Fix NullReferenceException when description too long

* (#408) Display description on 95 chars

* (#404) Add logging...

* (#408) Fix unit tests

* (#428) Bump to version 2.5.1

* (#428) Update GitVersion.yml

* (#415) Replace CentreMacro with CentreAlias

* (maint) Move ScreenRuler

* (maint) Move AppRestart facility

* (#416) Set default windows position at first boot

* (#416) Fix unit tests

* (#403) Change error message when alias fails to start

* (maint) Rider refactoring advices (#435)

* (#423) Retrieve thumbnails is done a a separate thread (#437)

* (maint) Refactoring (#438)

* Issue/412 (#441)

* (#412) Replace NLogger with Serilog

* (maint) Bump version

* (#412) Implements Microsoft.Extensions.Logging

* (#421) Refactor TimeSpan with Humanizer (#443)

* (#431) Fix autocompletion & syntax colouration (#442)

* Issue/439 (#444)

* (#439) Fix empty synonyms when wrongly written

* (#439) Add Unit test

* (#436) Refactore the KeywordViewModel into more Reactive (#446)

* (#436) Refactor the KeywordViewModel into more Reactive

* (maint) Refactor some unit tests

* (#436) Fix InvalidOperationException when updating synonyms (#447)

* Issue/445 (#448)

* (#445) Add cache when querying user packages

* (maint) IThumbnailRefresher is async

* (#364) Show help to create macros (#449)

* Issue/450 (#451)

* (#450) Add logging and measure time

* (#450) Optimise search (execution time)

* (#450) Optimise alias counters

* (maint) Fix unit tests

* Issue/452 (#454)

* (maint) Fix thumbnail manager

* (#452) Rethrow exception when error in transaction

* (maint) Log SQL on error

* Issue/453 (#455)

* (maint) Refactoring

* (#453) Remove SQL query repetition

* (maint) Adding logs in tests and refactoring

* (#450) Remove useless inner joins from SQL

* Isue/456 (#457)

* (#456) Fix warning when executing empty Lua scripts

* (#456) Unit test

* Issue/458 (#459)

* (maint) Change log level

* (#458) Add more logging

* Issue/458 (#462)

* (#458) Add unit test

* (#458) Fix delete of parameters when updating alias

* (#456) Fix Lua scripting when code is null (#464)

* (#456) Fix Lua scripting when code is null

* (#456) Fix unit test

* (#461) Catch error and add logs (#465)

* Issue/466 (#468)

* (maint) Refactoring

* (#466) Add logging to catch slow process executions

* Issue/467 (#469)

* (maint) Refactoring

* (#467) Fix XAML template

* (#470) Execute powershell command with '-noprofile' (#472)

* Issue/471 (#473)

* (#471) Adding log information

* (#471) Fix failure when Lua script returns 'nil'

* (#471) Fix logging (#474)

* (#476) Fix Lua script error (#477)

* (#479) Remove keyword (#480)

* (#482) Increase resilience for UiNotification (#483)
  • Loading branch information
jibedoubleve authored Feb 18, 2024
1 parent 8334a18 commit a145e10
Show file tree
Hide file tree
Showing 188 changed files with 3,211 additions and 6,647 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
assembly-versioning-scheme: MajorMinorPatchTag
next-version: 2.5.0
next-version: 2.6.0
branches:
master:
is-release-branch: true
Expand Down
Empty file added identifier.sqlite
Empty file.
53 changes: 53 additions & 0 deletions src/Lanceur.Core/BusinessLogic/AliasQueryResultMixin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Lanceur.Core.Models;
using Lanceur.SharedKernel.Mixins;

namespace Lanceur.Core.BusinessLogic
{
public static class AliasQueryResultMixin
{
#region Methods

public static bool IsUwp(this AliasQueryResult alias) => alias.FileName.IsUwp();

/// <summary>
/// Clears all the useless spaces and comas
/// </summary>
/// <param name="alias">The <see cref="AliasQueryResult"/> to sanitize</param>
public static void SanitizeSynonyms(this AliasQueryResult alias)
{
var items = string.Join(',',
alias.Synonyms
.Replace(' ', ',')
.Split(',', StringSplitOptions.RemoveEmptyEntries)
);
alias.Synonyms = items;
}

public static IEnumerable<AliasQueryResult> CloneFromSynonyms(this AliasQueryResult alias)
{
var names = alias.Synonyms.SplitCsv();
var errors = new List<Exception>();
var results = new List<AliasQueryResult>();

foreach (var name in names)
{
try
{
var toAdd = alias.CloneObject();
toAdd.Name = name;
results.Add(toAdd);
}
catch (Exception ex)
{
errors.Add(ex);
}
}

if (errors.Any()) throw new AggregateException($"Errors occured while updating synonyms of alias with these synonyms: {alias.Synonyms}", errors);

return results.ToList();
}

#endregion Methods
}
}
1 change: 1 addition & 0 deletions src/Lanceur.Core/Lanceur.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lanceur.Core.Plugins" Version="2.4.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lanceur.SharedKernel\Lanceur.SharedKernel.csproj" />
Expand Down
20 changes: 10 additions & 10 deletions src/Lanceur.Core/LuaScripting/Script.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public static class ScriptMixins

public static Script Clone(this Script script, string scriptCode)
{
return new Script
return new()
{
Code = scriptCode,
Context = script.Context,
Context = script?.Context ?? new(),
};
}

Expand All @@ -28,22 +28,22 @@ public static Script ToScript(this AliasQueryResult alias)
};
}

public static ScriptResult ToScriptResult(this Script src) => new()
{
Code = src?.Code ?? string.Empty,
Context = src?.Context ?? new ()
};

#endregion Methods
}

public class Script
{
#region Properties

public string Code { get; init; }
public string Code { get; init; } = string.Empty;

public ScriptContext Context { get; init; }

public ScriptResult EmptyResult => new ScriptResult
{
Code = Code,
Context = ScriptContext.Empty
};
public ScriptContext Context { get; init; } = ScriptContext.Empty;

#endregion Properties
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lanceur.Core/LuaScripting/ScriptContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class ScriptContext
#region Properties

public static ScriptContext Empty => new();
public string FileName { get; set; }
public string Parameters { get; set; }
public string FileName { get; init; } = string.Empty;
public string Parameters { get; init; } = string.Empty;

#endregion Properties
}
Expand Down
9 changes: 7 additions & 2 deletions src/Lanceur.Core/LuaScripting/ScriptResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ public class ScriptResult : Script
{
#region Properties

public string Error { get; init; }
public Exception Exception { get; init; }

#endregion Properties

#region Methods

public override string ToString()
{
return $"File Name : {Context.FileName}" +
$"\nParameters : {Context.Parameters}";
}

#endregion Properties
#endregion Methods
}
}
9 changes: 8 additions & 1 deletion src/Lanceur.Core/MacroAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ public class MacroAttribute : Attribute

#region Constructors

public MacroAttribute(string name)
public MacroAttribute(string name, bool isVisible = true)
{
IsVisible = isVisible;
_name = name.Trim().Replace("@", "").ToUpper();
}

#endregion Constructors

#region Properties

/// <summary>
/// Indicates whether this macro should appear in the list of macros
/// This is meant to create some macro for "privileged" people. That's
/// some debugging tools for the developer.
/// </summary>
public bool IsVisible { get; }
public string Name => $"@{_name}@";

#endregion Properties
Expand Down
4 changes: 1 addition & 3 deletions src/Lanceur.Core/Managers/IFavIconManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Lanceur.Core.Models;

namespace Lanceur.Core.Managers
namespace Lanceur.Core.Managers
{
public interface IFavIconManager
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur.Core/Managers/IThumbnailManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IThumbnailManager
/// when thread has done its work
/// </summary>
/// <param name="results">The <see cref="QueryResult"/> to refresh</param>
Task RefreshThumbnails(IEnumerable<QueryResult> results);
void RefreshThumbnailsAsync(IEnumerable<QueryResult> results);

#endregion Methods
}
Expand Down
14 changes: 6 additions & 8 deletions src/Lanceur.Core/Models/AliasQueryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,15 @@ public override bool IsElevated

public bool IsHidden { get; set; }

public string Notes { get; set; }

public RunAs RunAs { get; set; } = RunAs.CurrentUser;

/// <summary>
/// Gets or sets a Lua script that will be executed
/// when user launch an alias
/// </summary>
public string LuaScript { get; set; }

public string Notes { get; set; }

public RunAs RunAs { get; set; } = RunAs.CurrentUser;
public StartMode StartMode { get; set; } = StartMode.Default;

/// <summary>
Expand All @@ -80,8 +79,7 @@ public string Synonyms
get => _synonyms;
set
{
var trimmed = value.Trim(',', ' ');
Set(ref _synonyms, trimmed);
Set(ref _synonyms, value);
OnPropertyChanged(nameof(SynonymsToAdd));
}
}
Expand All @@ -90,8 +88,8 @@ public string Synonyms
/// New synonyms added when updated
/// </summary>
public string SynonymsToAdd => (from n in Synonyms.SplitCsv()
where !SynonymsWhenLoaded.SplitCsv().Contains(n)
select n).ToArray().JoinCsv();
where !SynonymsWhenLoaded.SplitCsv().Contains(n)
select n).ToArray().JoinCsv();

/// <summary>
/// Synonyms present when the entity was loaded
Expand Down
16 changes: 8 additions & 8 deletions src/Lanceur.Core/Models/AliasQueryResultMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ public static class AliasQueryResultMixin
{
#region Methods

/// <summary>
/// Indicates whether this alias is a packaged application (i.e: UWP)
/// </summary>
/// <param name="alias">The alias ti check</param>
/// <returns><c>True</c> if this is a packaged application; otherwise <c>False</c></returns>
public static bool IsPackagedApplication(this AliasQueryResult alias)
=> alias.FileName.ToLower().StartsWith("package:");

/// <summary>
/// Set first names defined in the synonyms as the name of the alias
/// </summary>
Expand All @@ -17,13 +25,5 @@ public static void SetName(this AliasQueryResult alias)
.FirstOrDefault();
}

/// <summary>
/// Indicates whether this alias is a packaged application (i.e: UWP)
/// </summary>
/// <param name="alias">The alias ti check</param>
/// <returns><c>True</c> if this is a packaged application; otherwise <c>False</c></returns>
public static bool IsPackagedApplication(this AliasQueryResult alias)
=> alias.FileName.ToLower().StartsWith("package:");

#endregion Methods
}
11 changes: 7 additions & 4 deletions src/Lanceur.Core/Models/DisplayQueryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class DisplayQueryResult : QueryResult
#region Fields

private readonly string _description;
private string _icon;

#endregion Fields

Expand All @@ -14,17 +15,22 @@ public DisplayQueryResult(string name, string description = null, string iconKin
{
Name = name;
_description = description;
Icon = iconKind;
_icon = iconKind;
}

#endregion Constructors

#region Properties

public static IEnumerable<QueryResult> NoResultFound
=> SingleFromResult("No result found", iconKind: "AlertCircleOutline");

public override string Description => _description;

public override bool IsResult => false;

public override string Icon { get=> _icon; set => _icon = value; }

#endregion Properties

#region Methods
Expand All @@ -37,9 +43,6 @@ public static IEnumerable<QueryResult> SingleFromResult(string text, string subt
};
}

public static IEnumerable<QueryResult> NoResultFound
=> SingleFromResult("No result found", iconKind: "AlertCircleOutline");

#endregion Methods
}
}
10 changes: 5 additions & 5 deletions src/Lanceur.Core/Models/PluginExecutableQueryResult.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using Lanceur.Core.Plugins;
using Lanceur.Core.Plugins.Models;
using Lanceur.Core.Services;
using Lanceur.SharedKernel.Mixins;
using Microsoft.Extensions.Logging;

namespace Lanceur.Core.Models
{
public sealed class PluginExecutableQueryResult : SelfExecutableQueryResult
{
#region Fields

private readonly IAppLogger _log;
private readonly ILogger<PluginExecutableQueryResult> _logger;
private readonly IPlugin _plugin;

#endregion Fields

#region Constructors

public PluginExecutableQueryResult(IPlugin plugin, IAppLoggerFactory logFactory)
public PluginExecutableQueryResult(IPlugin plugin, ILoggerFactory loggerFactory)
{
_log = logFactory.GetLogger<PluginExecutableQueryResult>();
_logger = loggerFactory.CreateLogger<PluginExecutableQueryResult>();
_plugin = plugin;
Name = plugin.Name;
Icon = plugin.Icon;
Expand Down Expand Up @@ -49,7 +49,7 @@ public override async Task<IEnumerable<QueryResult>> ExecuteAsync(Cmdline cmdlin
{
if (cmdline == null || cmdline.Name.IsNullOrWhiteSpace())
{
_log.Info($"Cannot execute plugin '{Name}': the cmdline is empty.");
_logger.LogInformation("Cannot execute plugin {Name}: the cmdline is empty", Name);
return NoResult;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lanceur.Core/Models/QueryResultMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class QueryResultMixin
public static string GetMacroName(this AliasQueryResult @this)
{
if (@this is null) return string.Empty;

var regex = new Regex("@(.*)@");
var result = regex.IsMatch(@this.FileName ?? string.Empty)
? regex.Match(@this.FileName ?? string.Empty).Groups[1].Value
Expand Down
10 changes: 5 additions & 5 deletions src/Lanceur.Core/Models/SessionExecutableQueryResult.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Lanceur.Core.Repositories;
using Lanceur.Core.Services;
using Microsoft.Extensions.Logging;

namespace Lanceur.Core.Models
{
public class SessionExecutableQueryResult : SelfExecutableQueryResult
{
#region Fields

private readonly IAppLogger _log;
private readonly ILogger<SessionExecutableQueryResult> _logger;
private readonly IDbRepository _service;

#endregion Fields
Expand All @@ -17,10 +17,10 @@ public class SessionExecutableQueryResult : SelfExecutableQueryResult
public SessionExecutableQueryResult(
string name,
string description,
IAppLoggerFactory logFactory,
ILogger<SessionExecutableQueryResult> logger,
IDbRepository service) : base(name, description)
{
_log = logFactory.GetLogger<SessionExecutableQueryResult>();
_logger = logger;
_service = service;
}

Expand All @@ -30,7 +30,7 @@ public SessionExecutableQueryResult(

public override Task<IEnumerable<QueryResult>> ExecuteAsync(Cmdline cmdline = null)
{
_log.Trace($"Change to session '{Name}' with id {Id}");
_logger.LogInformation("Change to session {Name} with id {Id}", Name, Id);
_service.SetDefaultSession(Id);
return NoResultAsync;
}
Expand Down
Loading

0 comments on commit a145e10

Please sign in to comment.