Skip to content

Commit 56bcb6c

Browse files
authored
Merge pull request #32 from YassinLokhat/30-core-improvments
30 core improvments
2 parents 379aa78 + a78449d commit 56bcb6c

66 files changed

Lines changed: 2845 additions & 1057 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: C# Build with Dot Net - Linux
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: 10.0.x
19+
20+
- name: Restore dependencies
21+
run: dotnet restore Upsilon.Apps.Passkey.Linux.slnx
22+
23+
- name: Build Debug
24+
run: dotnet build Upsilon.Apps.Passkey.Linux.slnx --no-restore --configuration Debug
25+
26+
- name: Build Relesae
27+
run: dotnet build Upsilon.Apps.Passkey.Linux.slnx --no-restore --configuration Release
28+
29+
- name: Test
30+
run: dotnet test --no-build --verbosity normal Upsilon.Apps.Passkey.Linux.slnx
31+
32+
33+
permissions:
34+
contents: read
35+
issues: write
36+
pull-requests: write

.github/workflows/csharp-dotnet.yml renamed to .github/workflows/csharp-dotnet-windows.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: C# Build with CMake
1+
name: C# Build with Dot Net - Windows
22

33
on:
44
push:
@@ -15,19 +15,19 @@ jobs:
1515
- name: Setup .NET
1616
uses: actions/setup-dotnet@v4
1717
with:
18-
dotnet-version: 8.0.x
18+
dotnet-version: 10.0.x
1919

2020
- name: Restore dependencies
21-
run: dotnet restore Upsilon.Apps.Passkey.sln
21+
run: dotnet restore Upsilon.Apps.Passkey.Windows.slnx
2222

2323
- name: Build Debug
24-
run: dotnet build Upsilon.Apps.Passkey.sln --no-restore --configuration Debug
24+
run: dotnet build Upsilon.Apps.Passkey.Windows.slnx --no-restore --configuration Debug
2525

2626
- name: Build Relesae
27-
run: dotnet build Upsilon.Apps.Passkey.sln --no-restore --configuration Release
27+
run: dotnet build Upsilon.Apps.Passkey.Windows.slnx --no-restore --configuration Release
2828

2929
- name: Test
30-
run: dotnet test --no-build --verbosity normal Upsilon.Apps.Passkey.sln
30+
run: dotnet test --no-build --verbosity normal Upsilon.Apps.Passkey.Windows.slnx
3131

3232

3333
permissions:

Core/Internal/Models/AutoSave.cs

Lines changed: 0 additions & 95 deletions
This file was deleted.

Core/Internal/Utils/StaticMethods.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using System.ComponentModel;
2-
using Upsilon.Apps.PassKey.Core.Internal.Utils;
3-
using Upsilon.Apps.PassKey.Core.Public.Enums;
4-
using Upsilon.Apps.PassKey.Core.Public.Interfaces;
2+
using Upsilon.Apps.Passkey.Core.Utils;
3+
using Upsilon.Apps.Passkey.Interfaces;
4+
using Upsilon.Apps.Passkey.Interfaces.Enums;
55

6-
namespace Upsilon.Apps.PassKey.Core.Internal.Models
6+
namespace Upsilon.Apps.Passkey.Core.Models
77
{
88
internal sealed class Account : IAccount
99
{
1010
#region IAccount interface explicit Internal
1111

1212
string IItem.ItemId => Database.Get(ItemId);
13+
14+
IDatabase IItem.Database => Database;
15+
1316
IService IAccount.Service => Database.Get(Service);
1417

1518
string IAccount.Label
@@ -19,18 +22,20 @@ string IAccount.Label
1922
itemName: ToString(),
2023
fieldName: nameof(Label),
2124
needsReview: false,
22-
value: value,
25+
oldValue: Label,
26+
newValue: value,
2327
readableValue: value);
2428
}
2529

26-
string[] IAccount.Identifiants
30+
string[] IAccount.Identifiers
2731
{
28-
get => Database.Get(Identifiants);
29-
set => Identifiants = Database.AutoSave.UpdateValue(ItemId,
32+
get => Database.Get(Identifiers);
33+
set => Identifiers = Database.AutoSave.UpdateValue(ItemId,
3034
itemName: ToString(),
31-
fieldName: nameof(Identifiants),
35+
fieldName: nameof(Identifiers),
3236
needsReview: true,
33-
value: value,
37+
oldValue: Identifiers,
38+
newValue: value,
3439
readableValue: $"({string.Join(", ", value)})");
3540
}
3641

@@ -39,17 +44,34 @@ string IAccount.Password
3944
get => Database.Get(Password);
4045
set
4146
{
42-
if (!string.IsNullOrEmpty(value))
47+
if (!string.IsNullOrEmpty(value)
48+
&& Password != value)
4349
{
50+
Dictionary<DateTime, string> oldPasswords = Passwords.CloneWith(Database.SerializationCenter);
4451
Passwords[DateTime.Now] = Password = value;
4552

4653
if (_service != null)
4754
{
55+
if (Service.User.NumberOfOldPasswordToKeep != 0)
56+
{
57+
DateTime[] datesToRemove = [.. Passwords.Keys
58+
.OrderBy(x => x)
59+
.Take(Passwords.Count > Service.User.NumberOfOldPasswordToKeep
60+
? Passwords.Count - Service.User.NumberOfOldPasswordToKeep
61+
: 0)];
62+
63+
foreach (DateTime dateToRemove in datesToRemove)
64+
{
65+
_ = Passwords.Remove(dateToRemove);
66+
}
67+
}
68+
4869
_ = Database.AutoSave.UpdateValue(ItemId,
4970
itemName: ToString(),
5071
fieldName: nameof(Password),
5172
needsReview: true,
52-
value: Passwords,
73+
oldValue: oldPasswords,
74+
newValue: Passwords,
5375
readableValue: string.Empty);
5476
}
5577
}
@@ -65,7 +87,8 @@ string IAccount.Notes
6587
itemName: ToString(),
6688
fieldName: nameof(Notes),
6789
needsReview: false,
68-
value: value,
90+
oldValue: Notes,
91+
newValue: value,
6992
readableValue: value);
7093
}
7194

@@ -76,7 +99,8 @@ int IAccount.PasswordUpdateReminderDelay
7699
itemName: ToString(),
77100
fieldName: nameof(PasswordUpdateReminderDelay),
78101
needsReview: false,
79-
value: value,
102+
oldValue: PasswordUpdateReminderDelay,
103+
newValue: value,
80104
readableValue: value.ToString());
81105
}
82106

@@ -87,7 +111,8 @@ AccountOption IAccount.Options
87111
itemName: ToString(),
88112
fieldName: nameof(Options),
89113
needsReview: false,
90-
value: value,
114+
oldValue: Options,
115+
newValue: value,
91116
readableValue: value.ToString());
92117
}
93118

@@ -105,7 +130,7 @@ internal Service Service
105130
}
106131

107132
public string Label { get; set; } = string.Empty;
108-
public string[] Identifiants { get; set; } = [];
133+
public string[] Identifiers { get; set; } = [];
109134
public string Password { get; set; } = string.Empty;
110135
public Dictionary<DateTime, string> Passwords { get; set; } = [];
111136
public string Notes { get; set; } = string.Empty;
@@ -136,23 +161,23 @@ public void Apply(Change change)
136161
switch (change.FieldName)
137162
{
138163
case nameof(Label):
139-
Label = Database.SerializationCenter.Deserialize<string>(change.Value);
164+
Label = change.NewValue.DeserializeTo<string>(Database.SerializationCenter);
140165
break;
141-
case nameof(Identifiants):
142-
Identifiants = Database.SerializationCenter.Deserialize<string[]>(change.Value);
166+
case nameof(Identifiers):
167+
Identifiers = change.NewValue.DeserializeTo<string[]>(Database.SerializationCenter);
143168
break;
144169
case nameof(Notes):
145-
Notes = Database.SerializationCenter.Deserialize<string>(change.Value);
170+
Notes = change.NewValue.DeserializeTo<string>(Database.SerializationCenter);
146171
break;
147172
case nameof(Password):
148-
Passwords = Database.SerializationCenter.Deserialize<Dictionary<DateTime, string>>(change.Value);
173+
Passwords = change.NewValue.DeserializeTo<Dictionary<DateTime, string>>(Database.SerializationCenter);
149174
Password = Passwords.Count != 0 ? Passwords[Passwords.Keys.Max()] : string.Empty;
150175
break;
151176
case nameof(PasswordUpdateReminderDelay):
152-
PasswordUpdateReminderDelay = Database.SerializationCenter.Deserialize<int>(change.Value);
177+
PasswordUpdateReminderDelay = change.NewValue.DeserializeTo<int>(Database.SerializationCenter);
153178
break;
154179
case nameof(Options):
155-
Options = Database.SerializationCenter.Deserialize<AccountOption>(change.Value);
180+
Options = change.NewValue.DeserializeTo<AccountOption>(Database.SerializationCenter);
156181
break;
157182
default:
158183
throw new InvalidDataException("FieldName not valid");
@@ -172,7 +197,7 @@ public override string ToString()
172197
account += $"{Label} ";
173198
}
174199

175-
return account + $"({string.Join(", ", Identifiants)})";
200+
return account + $"({string.Join(", ", Identifiers)})";
176201
}
177202
}
178203
}

0 commit comments

Comments
 (0)