Skip to content

Commit 3a1b83f

Browse files
Migrate Easify.Notifications to .Net 6.0 (icgam#6)
* [DEV-1929] Upgraded to .net 6 * [DEV-1929] Namespace and global using updates * [DEV-1929] Updated ci.yaml * [DEV-1929] Added global system usings file * [DEV-1929] Update to release.yaml file * [DEV-1929] Upgraded all NetStandard projects to Net 6 * [DEV-1929] Small usings file tidy up
1 parent 7b18cb2 commit 3a1b83f

File tree

55 files changed

+774
-881
lines changed

Some content is hidden

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

55 files changed

+774
-881
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
- name: Install GitVersion
2525
uses: gittools/actions/gitversion/[email protected]
2626
with:
27-
versionSpec: "5.6.x"
27+
versionSpec: "5.8.x"
2828
- name: Setup .NET Core
29-
uses: actions/setup-dotnet@v1
29+
uses: actions/setup-dotnet@v2
3030
with:
31-
dotnet-version: "5.0.x"
31+
dotnet-version: "6.0.x"
3232
- name: Install dependencies
3333
run: dotnet restore src
3434
- name: Use GitVersion

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
- name: Install GitVersion
1717
uses: gittools/actions/gitversion/[email protected]
1818
with:
19-
versionSpec: "5.6.x"
19+
versionSpec: "5.8.x"
2020
- name: Setup .NET Core
21-
uses: actions/setup-dotnet@v1
21+
uses: actions/setup-dotnet@v2
2222
with:
23-
dotnet-version: "5.0.x"
23+
dotnet-version: "6.0.x"
2424
- name: Install dependencies
2525
run: dotnet restore src
2626
- name: Use GitVersion

src/Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<ItemGroup>
3+
<Compile Include="../GlobalUsings.System.cs" />
4+
</ItemGroup>
5+
</Project>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
54
<Description>MailKit implementation for Easify Notification Messaging</Description>
65
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
76
<Authors>Mohammad Moattar,David Cassell</Authors>
@@ -10,17 +9,18 @@
109
<RepositoryUrl>https://github.com/icgam/Easify.Notifications</RepositoryUrl>
1110
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
1211
<Version>1.0.0</Version>
13-
<LangVersion>9</LangVersion>
12+
<LangVersion>10</LangVersion>
13+
<TargetFramework>net6.0</TargetFramework>
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="MailKit" Version="2.10.0" />
18-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
17+
<PackageReference Include="MailKit" Version="2.10.0" />
18+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
19+
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<ProjectReference Include="..\Easify.Notifications.Messaging\Easify.Notifications.Messaging.csproj" />
23+
<ProjectReference Include="..\Easify.Notifications.Messaging\Easify.Notifications.Messaging.csproj" />
2424
</ItemGroup>
2525

2626
</Project>
Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,72 @@
1-
using System;
2-
using System.Linq;
3-
using System.Threading.Tasks;
4-
using Easify.Notifications.Messaging;
5-
using Easify.Notifications.Messaging.Configuration;
6-
using Easify.Notifications.Messaging.Exceptions;
7-
using MailKit.Net.Smtp;
8-
using MailKit.Security;
9-
using Microsoft.Extensions.Logging;
10-
using Microsoft.Extensions.Options;
11-
using MimeKit;
12-
131
// This software is part of the Easify framework
142
// Copyright (C) 2019 Intermediate Capital Group
15-
//
3+
//
164
// This program is free software: you can redistribute it and/or modify
175
// it under the terms of the GNU Affero General Public License as published by
186
// the Free Software Foundation, either version 3 of the License, or
197
// (at your option) any later version.
20-
//
8+
//
219
// This program is distributed in the hope that it will be useful,
2210
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2311
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2412
// GNU Affero General Public License for more details.
25-
//
13+
//
2614
// You should have received a copy of the GNU Affero General Public License
2715
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2816

29-
namespace Easify.Notifications.Messaging.MailKit
17+
namespace Easify.Notifications.Messaging.MailKit;
18+
19+
public sealed class MailKitMessagingService : IMessagingService
3020
{
31-
public sealed class MailKitMessagingService : IMessagingService
32-
{
33-
private readonly ILogger<MailKitMessagingService> _logger;
34-
private readonly SmtpOptions _smtpOptions;
21+
private readonly ILogger<MailKitMessagingService> _logger;
22+
private readonly SmtpOptions _smtpOptions;
3523

36-
public MailKitMessagingService(IOptions<SmtpOptions> smtpOptionsAccessor, ILogger<MailKitMessagingService> logger)
37-
{
38-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
39-
_smtpOptions = smtpOptionsAccessor?.Value ?? throw new ArgumentNullException(nameof(smtpOptionsAccessor));
40-
}
24+
public MailKitMessagingService(IOptions<SmtpOptions> smtpOptionsAccessor, ILogger<MailKitMessagingService> logger)
25+
{
26+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
27+
_smtpOptions = smtpOptionsAccessor?.Value ?? throw new ArgumentNullException(nameof(smtpOptionsAccessor));
28+
}
4129

42-
public async Task SendAsync(Message message)
43-
{
44-
if (message == null) throw new ArgumentNullException(nameof(message));
30+
public async Task SendAsync(Message message)
31+
{
32+
if (message == null) throw new ArgumentNullException(nameof(message));
4533

46-
EnsureOptions();
34+
EnsureOptions();
4735

48-
var emailMessage = new MimeMessage();
36+
var emailMessage = new MimeMessage();
4937

50-
emailMessage.From.Add(CreateAddress(message.Sender));
51-
emailMessage.To.AddRange(message.Recipients.Select(CreateAddress).ToList());
52-
emailMessage.Subject = message.Subject;
53-
emailMessage.Body = new TextPart("html") {Text = message.Content};
38+
emailMessage.From.Add(CreateAddress(message.Sender));
39+
emailMessage.To.AddRange(message.Recipients.Select(CreateAddress).ToList());
40+
emailMessage.Subject = message.Subject;
41+
emailMessage.Body = new TextPart("html") { Text = message.Content };
5442

55-
await SendEmailMessageAsync(emailMessage);
56-
}
43+
await SendEmailMessageAsync(emailMessage);
44+
}
5745

58-
private void EnsureOptions()
59-
{
60-
if (string.IsNullOrWhiteSpace(_smtpOptions.LocalDomain))
61-
throw new SmtpOptionsException(nameof(_smtpOptions.LocalDomain));
46+
private void EnsureOptions()
47+
{
48+
if (string.IsNullOrWhiteSpace(_smtpOptions.LocalDomain))
49+
throw new SmtpOptionsException(nameof(_smtpOptions.LocalDomain));
6250

63-
if (string.IsNullOrWhiteSpace(_smtpOptions.Server))
64-
throw new SmtpOptionsException(nameof(_smtpOptions.Server));
65-
}
51+
if (string.IsNullOrWhiteSpace(_smtpOptions.Server))
52+
throw new SmtpOptionsException(nameof(_smtpOptions.Server));
53+
}
6654

67-
private async Task SendEmailMessageAsync(MimeMessage message)
55+
private async Task SendEmailMessageAsync(MimeMessage message)
56+
{
57+
using (var client = new SmtpClient())
6858
{
69-
using (var client = new SmtpClient())
70-
{
71-
client.LocalDomain = _smtpOptions.LocalDomain;
72-
await client.ConnectAsync(_smtpOptions.Server, _smtpOptions.Port, SecureSocketOptions.None);
73-
await client.SendAsync(message);
74-
await client.DisconnectAsync(true);
75-
}
59+
client.LocalDomain = _smtpOptions.LocalDomain;
60+
await client.ConnectAsync(_smtpOptions.Server, _smtpOptions.Port, SecureSocketOptions.None);
61+
await client.SendAsync(message);
62+
await client.DisconnectAsync(true);
7663
}
64+
}
7765

78-
private MailboxAddress CreateAddress(EmailAddress recipient)
79-
{
80-
if (recipient == null) throw new ArgumentNullException(nameof(recipient));
66+
private MailboxAddress CreateAddress(EmailAddress recipient)
67+
{
68+
if (recipient == null) throw new ArgumentNullException(nameof(recipient));
8169

82-
return new MailboxAddress(recipient.Name ?? recipient.Email, recipient.Email);
83-
}
70+
return new MailboxAddress(recipient.Name ?? recipient.Email, recipient.Email);
8471
}
8572
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
global using Easify.Notifications.Messaging.Configuration;
2+
global using Easify.Notifications.Messaging.Exceptions;
3+
4+
global using Microsoft.Extensions.Logging;
5+
global using Microsoft.Extensions.Options;
6+
7+
global using MailKit.Net.Smtp;
8+
global using MailKit.Security;
9+
global using MimeKit;
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
// This software is part of the Easify framework
22
// Copyright (C) 2019 Intermediate Capital Group
3-
//
3+
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
8-
//
8+
//
99
// This program is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU Affero General Public License for more details.
13-
//
13+
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
namespace Easify.Notifications.Messaging.Configuration
17+
namespace Easify.Notifications.Messaging.Configuration;
18+
19+
public sealed class NotificationAudience
1820
{
19-
public sealed class NotificationAudience
20-
{
21-
public string Email { get; set; }
22-
}
21+
public string Email { get; set; }
2322
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
// This software is part of the Easify framework
22
// Copyright (C) 2019 Intermediate Capital Group
3-
//
3+
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
8-
//
8+
//
99
// This program is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU Affero General Public License for more details.
13-
//
13+
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
namespace Easify.Notifications.Messaging.Configuration
17+
namespace Easify.Notifications.Messaging.Configuration;
18+
19+
public sealed class NotificationOptions
1820
{
19-
public sealed class NotificationOptions
20-
{
21-
public string Sender { get; set; }
22-
public NotificationProfile[] Profiles { get; set; } = { };
23-
public NotificationTemplate[] Templates { get; set; } = { };
24-
}
21+
public string Sender { get; set; }
22+
public NotificationProfile[] Profiles { get; set; } = { };
23+
public NotificationTemplate[] Templates { get; set; } = { };
2524
}
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
// This software is part of the Easify framework
22
// Copyright (C) 2019 Intermediate Capital Group
3-
//
3+
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
8-
//
8+
//
99
// This program is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU Affero General Public License for more details.
13-
//
13+
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
namespace Easify.Notifications.Messaging.Configuration
17+
namespace Easify.Notifications.Messaging.Configuration;
18+
19+
public sealed class NotificationProfile
1820
{
19-
public sealed class NotificationProfile
20-
{
21-
public string ProfileName { get; set; }
22-
public NotificationAudience[] Audiences { get; set; }
23-
}
21+
public string ProfileName { get; set; }
22+
public NotificationAudience[] Audiences { get; set; }
2423
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
// This software is part of the Easify framework
22
// Copyright (C) 2019 Intermediate Capital Group
3-
//
3+
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as published by
66
// the Free Software Foundation, either version 3 of the License, or
77
// (at your option) any later version.
8-
//
8+
//
99
// This program is distributed in the hope that it will be useful,
1010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU Affero General Public License for more details.
13-
//
13+
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
namespace Easify.Notifications.Messaging.Configuration
17+
namespace Easify.Notifications.Messaging.Configuration;
18+
19+
public static class NotificationProfileNames
1820
{
19-
public static class NotificationProfileNames
20-
{
21-
public const string DefaultProfile = "DefaultProfile";
22-
}
21+
public const string DefaultProfile = "DefaultProfile";
2322
}

0 commit comments

Comments
 (0)