Skip to content

Commit 7574bd7

Browse files
committed
Upgrade to C# 10, closes #270
* Restructure * Enable C# 10 features for library projects * Switch to file-scoped namespaces. * Enable implicit usings. * Add JetBrains.Annotations. * Reformat code. * Update Samples * Upgrade dependencies * Skip GitVersion for PR builds * Skip code coverage for .NET 7 * Include build Id in PR build version number * Disable .NET preview warning
1 parent e6a8469 commit 7574bd7

File tree

251 files changed

+8210
-8626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+8210
-8626
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end_of_line = lf
2222
[*.{cmd, bat}]
2323
end_of_line = crlf
2424

25-
[{**/tests/**,**/Tests/**,**/*.Tests/**}.cs]
25+
[{**/tests/**,**/Tests/**,**/*.Tests/**,**/Samples/**}.cs]
2626
resharper_async_converter_async_await_may_be_elided_highlighting=do_not_show
2727
resharper_class_never_instantiated_global_highlighting = do_not_show
2828
resharper_class_with_virtual_members_never_inherited_global_highlighting = do_not_show

Directory.Build.props

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,30 @@
66
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0;net7.0</TargetFrameworks>
77
<Culture></Culture>
88
<SignAssembly>false</SignAssembly>
9+
910
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
1011
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
1112
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
1213
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14+
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
15+
1316
<DebugSymbols>true</DebugSymbols>
1417
<DebugType>portable</DebugType>
1518

1619
<LangVersion>preview</LangVersion>
1720
<Nullable>enable</Nullable>
21+
<ImplicitUsings>enable</ImplicitUsings>
22+
1823
<IsTestProject>false</IsTestProject>
1924

25+
<DefineConstants>$(DefineConstants);JETBRAINS_ANNOTATIONS</DefineConstants>
2026
<NoWarn>$(NoWarn);0105</NoWarn>
2127
</PropertyGroup>
2228

29+
<ItemGroup>
30+
<Using Include="JetBrains.Annotations" />
31+
</ItemGroup>
32+
2333
<PropertyGroup Label="Custom targets">
2434
<!-- target frameworks for unit-tests and applications -->
2535
<AppTargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0</AppTargetFrameworks>
@@ -34,7 +44,7 @@
3444
</PropertyGroup>
3545

3646
<!-- nullable checks -->
37-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0'">
47+
<PropertyGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
3848
<DefineConstants>$(DefineConstants);NULLABLE_REFERENCE_TYPES</DefineConstants>
3949
</PropertyGroup>
4050

Samples/Samples.sln

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Suteki.TardisBank.Tasks", "
2121
EndProject
2222
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Suteki.TardisBank.Tests", "TardisBank\Src\Suteki.TardisBank.Tests\Suteki.TardisBank.Tests.csproj", "{6AB4ABA4-DBB1-4A05-BE4C-894EF9836A29}"
2323
EndProject
24-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Domain", "..\Src\SharpArch.Domain\SharpArch.Domain.csproj", "{FA611294-98F7-4718-8EBE-F6DACF510040}"
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Domain", "..\Src\Lib\SharpArch.Domain\SharpArch.Domain.csproj", "{FA611294-98F7-4718-8EBE-F6DACF510040}"
2525
EndProject
26-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Infrastructure", "..\Src\SharpArch.Infrastructure\SharpArch.Infrastructure.csproj", "{C0C2A307-73F6-437D-9341-1A014000C023}"
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Infrastructure", "..\Src\Lib\SharpArch.Infrastructure\SharpArch.Infrastructure.csproj", "{C0C2A307-73F6-437D-9341-1A014000C023}"
2727
EndProject
28-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.NHibernate", "..\Src\SharpArch.NHibernate\SharpArch.NHibernate.csproj", "{E94D2E74-4900-44DD-B114-7C37502F88FA}"
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.NHibernate", "..\Src\Lib\SharpArch.NHibernate\SharpArch.NHibernate.csproj", "{E94D2E74-4900-44DD-B114-7C37502F88FA}"
2929
EndProject
30-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.NHibernate.Extensions.DependencyInjection", "..\Src\SharpArch.NHibernate.DependencyInjection\SharpArch.NHibernate.Extensions.DependencyInjection.csproj", "{F7BED6C6-ACD4-41C4-8F2C-7FAEFFF53A8A}"
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.NHibernate.Extensions.DependencyInjection", "..\Src\Lib\SharpArch.NHibernate.DependencyInjection\SharpArch.NHibernate.Extensions.DependencyInjection.csproj", "{F7BED6C6-ACD4-41C4-8F2C-7FAEFFF53A8A}"
3131
EndProject
32-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.RavenDb", "..\Src\SharpArch.RavenDb\SharpArch.RavenDb.csproj", "{CFFD11B3-E73D-4712-9A74-6B4EEE842BD4}"
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.RavenDb", "..\Src\Lib\SharpArch.RavenDb\SharpArch.RavenDb.csproj", "{CFFD11B3-E73D-4712-9A74-6B4EEE842BD4}"
3333
EndProject
34-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing", "..\Src\SharpArch.Testing\SharpArch.Testing.csproj", "{172063A6-E0DD-4F71-8904-FEBEB1B285DC}"
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing", "..\Src\Lib\SharpArch.Testing\SharpArch.Testing.csproj", "{172063A6-E0DD-4F71-8904-FEBEB1B285DC}"
3535
EndProject
36-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing.NUnit", "..\Src\SharpArch.Testing.NUnit\SharpArch.Testing.NUnit.csproj", "{7D11D48A-38DA-4933-9670-0D7214DFA843}"
36+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing.NUnit", "..\Src\Lib\SharpArch.Testing.NUnit\SharpArch.Testing.NUnit.csproj", "{7D11D48A-38DA-4933-9670-0D7214DFA843}"
3737
EndProject
38-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing.Xunit", "..\Src\SharpArch.Testing.Xunit\SharpArch.Testing.Xunit.csproj", "{A615DFB3-F550-4B40-B90F-D10ED619359F}"
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing.Xunit", "..\Src\Lib\SharpArch.Testing.Xunit\SharpArch.Testing.Xunit.csproj", "{A615DFB3-F550-4B40-B90F-D10ED619359F}"
3939
EndProject
40-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing.Xunit.NHibernate", "..\Src\SharpArch.Testing.Xunit.NHibernate\SharpArch.Testing.Xunit.NHibernate.csproj", "{0DDF2078-BC4B-4890-9AFC-0407C1D24A0E}"
40+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Testing.Xunit.NHibernate", "..\Src\Lib\SharpArch.Testing.Xunit.NHibernate\SharpArch.Testing.Xunit.NHibernate.csproj", "{0DDF2078-BC4B-4890-9AFC-0407C1D24A0E}"
4141
EndProject
42-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Web.AspNetCore", "..\Src\SharpArch.Web.AspNetCore\SharpArch.Web.AspNetCore.csproj", "{BC957B66-7B0C-44F6-8C03-518B384EB57D}"
42+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpArch.Web.AspNetCore", "..\Src\Lib\SharpArch.Web.AspNetCore\SharpArch.Web.AspNetCore.csproj", "{BC957B66-7B0C-44F6-8C03-518B384EB57D}"
4343
EndProject
4444
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharpArch", "SharpArch", "{F2D26BF7-7343-4A9D-B73F-95506346EC33}"
4545
EndProject
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
namespace Suteki.TardisBank.Api.Announcements
2-
{
3-
using System;
4-
using System.ComponentModel.DataAnnotations;
5-
using Newtonsoft.Json;
1+
namespace Suteki.TardisBank.Api.Announcements;
62

3+
using System.ComponentModel.DataAnnotations;
4+
using Newtonsoft.Json;
75

8-
/// <summary>
9-
/// Announcement summary model.
10-
/// </summary>
11-
public class AnnouncementSummary
12-
{
13-
[JsonProperty("id")]
14-
public int Id { get; set; }
156

16-
[JsonProperty("date")]
17-
[DataType(DataType.Date)]
18-
public DateTime Date { get; set; }
7+
/// <summary>
8+
/// Announcement summary model.
9+
/// </summary>
10+
public class AnnouncementSummary
11+
{
12+
[JsonProperty("id")]
13+
public int Id { get; set; }
1914

20-
[Required]
21-
[JsonProperty("title")]
22-
public string Title { get; set; } = null!;
23-
}
15+
[JsonProperty("date")]
16+
[DataType(DataType.Date)]
17+
public DateTime Date { get; set; }
2418

19+
[Required]
20+
[JsonProperty("title")]
21+
public string Title { get; set; } = null!;
22+
}
2523

26-
/// <summary>
27-
/// Full announcement details.
28-
/// </summary>
29-
public class AnnouncementModel : AnnouncementSummary
30-
{
31-
[JsonProperty("content")]
32-
[Required]
33-
public string Content { get; set; } = null!;
34-
}
24+
25+
/// <summary>
26+
/// Full announcement details.
27+
/// </summary>
28+
public class AnnouncementModel : AnnouncementSummary
29+
{
30+
[JsonProperty("content")]
31+
[Required]
32+
public string Content { get; set; } = null!;
3533
}
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
namespace Suteki.TardisBank.Api.Announcements
2-
{
3-
using System;
4-
using System.ComponentModel.DataAnnotations;
5-
using Newtonsoft.Json;
1+
namespace Suteki.TardisBank.Api.Announcements;
2+
3+
using System.ComponentModel.DataAnnotations;
4+
using Newtonsoft.Json;
65

76

8-
public class NewAnnouncement
9-
{
10-
[JsonProperty("date")]
11-
[DataType(DataType.Date)]
12-
public DateTime Date { get; set; }
7+
public class NewAnnouncement
8+
{
9+
[JsonProperty("date")]
10+
[DataType(DataType.Date)]
11+
public DateTime Date { get; set; }
1312

14-
[Required]
15-
[JsonProperty("title")]
16-
public string Title { get; set; } = null!;
13+
[Required]
14+
[JsonProperty("title")]
15+
public string Title { get; set; } = null!;
1716

18-
[JsonProperty("content")]
19-
[Required]
20-
public string Content { get; set; } = null!;
21-
}
17+
[JsonProperty("content")]
18+
[Required]
19+
public string Content { get; set; } = null!;
2220
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root=true
2+
3+
[*.cs]
4+
# NHibernate requires all class members to be virtual
5+
resharper_virtual_member_call_in_constructor_highlighting=do_not_show
6+
resharper_class_with_virtual_members_never_inherited_global_highlighting=do_not_show
Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,66 @@
1-
namespace Suteki.TardisBank.Domain
2-
{
3-
using System;
4-
using System.Linq;
5-
using System.Collections.Generic;
1+
// ReSharper disable MissingXmlDoc
2+
namespace Suteki.TardisBank.Domain;
63

7-
using SharpArch.Domain.DomainModel;
4+
using SharpArch.Domain.DomainModel;
85

9-
public class Account : Entity<int>
10-
{
11-
public const int MaxTransactions = 100;
12-
public virtual decimal OldTransactionsBalance { get; protected set; }
136

14-
public Account()
15-
{
16-
this.Transactions = new List<Transaction>();
17-
this.PaymentSchedules = new List<PaymentSchedule>();
18-
this.OldTransactionsBalance = 0M;
19-
}
7+
public class Account : Entity<int>
8+
{
9+
public const int MaxTransactions = 100;
10+
public virtual decimal OldTransactionsBalance { get; protected set; }
2011

21-
public virtual IList<Transaction> Transactions { get; protected set; }
12+
public virtual IList<Transaction> Transactions { get; protected set; }
2213

23-
public virtual decimal Balance
24-
{
25-
get { return this.OldTransactionsBalance + this.Transactions.Sum(x => x.Amount); }
26-
}
14+
public virtual decimal Balance
15+
{
16+
get { return OldTransactionsBalance + Transactions.Sum(x => x.Amount); }
17+
}
2718

28-
public virtual IList<PaymentSchedule> PaymentSchedules { get; protected set; }
19+
public virtual IList<PaymentSchedule> PaymentSchedules { get; protected set; }
2920

30-
public virtual void AddTransaction(string? description, decimal amount)
31-
{
32-
this.Transactions.Add(new Transaction(description, amount, this));
21+
public Account()
22+
{
23+
Transactions = new List<Transaction>();
24+
PaymentSchedules = new List<PaymentSchedule>();
25+
OldTransactionsBalance = 0M;
26+
}
3327

34-
this.RemoveOldTransactions();
35-
}
28+
public virtual void AddTransaction(string? description, decimal amount)
29+
{
30+
Transactions.Add(new Transaction(description, amount, this));
3631

37-
void RemoveOldTransactions()
38-
{
39-
if (this.Transactions.Count <= MaxTransactions) return;
32+
RemoveOldTransactions();
33+
}
4034

41-
var oldestTransaction = this.Transactions.First();
42-
this.Transactions.Remove(oldestTransaction);
43-
this.OldTransactionsBalance += oldestTransaction.Amount;
44-
}
35+
void RemoveOldTransactions()
36+
{
37+
if (Transactions.Count <= MaxTransactions) return;
4538

46-
public virtual void AddPaymentSchedule(DateTime startDate, Interval interval, decimal amount, string description)
47-
{
48-
this.PaymentSchedules.Add(new PaymentSchedule(startDate, interval, amount, description, this));
49-
}
39+
var oldestTransaction = Transactions.First();
40+
Transactions.Remove(oldestTransaction);
41+
OldTransactionsBalance += oldestTransaction.Amount;
42+
}
43+
44+
public virtual void AddPaymentSchedule(DateTime startDate, Interval interval, decimal amount, string description)
45+
{
46+
PaymentSchedules.Add(new PaymentSchedule(startDate, interval, amount, description, this));
47+
}
5048

51-
public virtual void TriggerScheduledPayments(DateTime now)
49+
public virtual void TriggerScheduledPayments(DateTime now)
50+
{
51+
var overdueSchedules = PaymentSchedules.Where(x => x.NextRun <= now);
52+
foreach (var overdueSchedule in overdueSchedules)
5253
{
53-
var overdueSchedules = this.PaymentSchedules.Where(x => x.NextRun <= now);
54-
foreach (var overdueSchedule in overdueSchedules)
55-
{
56-
this.AddTransaction(overdueSchedule.Description, overdueSchedule.Amount);
57-
overdueSchedule.CalculateNextRunDate();
58-
}
54+
AddTransaction(overdueSchedule.Description, overdueSchedule.Amount);
55+
overdueSchedule.CalculateNextRunDate();
5956
}
57+
}
6058

61-
public virtual void RemovePaymentSchedule(int paymentScheduleId)
62-
{
63-
var scheduleToRemove = this.PaymentSchedules.SingleOrDefault(x => x.Id == paymentScheduleId);
64-
if (scheduleToRemove == null) return;
59+
public virtual void RemovePaymentSchedule(int paymentScheduleId)
60+
{
61+
var scheduleToRemove = PaymentSchedules.SingleOrDefault(x => x.Id == paymentScheduleId);
62+
if (scheduleToRemove == null) return;
6563

66-
this.PaymentSchedules.Remove(scheduleToRemove);
67-
}
64+
PaymentSchedules.Remove(scheduleToRemove);
6865
}
6966
}
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
namespace Suteki.TardisBank.Domain
2-
{
3-
using System;
4-
using System.ComponentModel.DataAnnotations;
5-
using System.Diagnostics;
6-
using SharpArch.Domain.DomainModel;
1+
// ReSharper disable MissingXmlDoc
2+
namespace Suteki.TardisBank.Domain;
73

8-
[DebuggerDisplay("{Id}: {Title}")]
9-
public class Announcement: Entity<int>
10-
{
11-
public virtual DateTime Date { get; set; }
4+
using System.ComponentModel.DataAnnotations;
5+
using System.Diagnostics;
6+
using SharpArch.Domain.DomainModel;
127

13-
[MaxLength(120)]
14-
public virtual string Title { get; set; } = null!;
158

16-
[MaxLength(2000)]
17-
public virtual string? Content { get; set; }
9+
[DebuggerDisplay("{Id}: {Title}")]
10+
public class Announcement : Entity<int>
11+
{
12+
public virtual DateTime Date { get; set; }
1813

19-
public virtual DateTime LastModifiedUtc { get; set; }
14+
[MaxLength(120)]
15+
public virtual string Title { get; set; } = null!;
2016

17+
[MaxLength(2000)]
18+
public virtual string? Content { get; set; }
2119

22-
}
20+
public virtual DateTime LastModifiedUtc { get; set; }
2321
}

0 commit comments

Comments
 (0)