Skip to content

Commit

Permalink
Bump packages, target .NET 9, remove .NET 6 and .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
hbulens committed Nov 13, 2024
1 parent 7594b9e commit e7d2e2c
Show file tree
Hide file tree
Showing 24 changed files with 126 additions and 102 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-quality: "preview"
dotnet-version: |
6.x.x
7.x.x
dotnet-version: |
8.x.x
9.x.x
- name: Install dependencies
run: dotnet restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/Facteur.Attachments.IO/Facteur.Attachments.IO.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<RuntimeIdentifiers>win</RuntimeIdentifiers>
<AssemblyTitle>Facteur.Attachments.IO</AssemblyTitle>
<Company>Dime Software</Company>
Expand All @@ -20,7 +20,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Add attachments using simple IO</Description>
<PackageTags>Facteur;Email;Mail;RazorEngine;Scriban;SendGrid;Graph;SMTP</PackageTags>
<Version>2.1.0</Version>
<Version>3.0.0-alpha.1</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -14,14 +14,14 @@
<Description>Create email bodies using the Scriban template engine.</Description>
<PackageTags>Facteur;Email;Mail;Scriban</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/dimesoftware/facteur/master/assets/facteur.png?raw=true</PackageIconUrl>
<Version>2.1.0</Version>
<Version>3.0.0-alpha.1</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Scriban" Version="5.7.0" />
<PackageReference Include="Scriban" Version="5.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand All @@ -13,14 +13,14 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Facteur;Email;Mail;RazorEngine;Scriban;SendGrid;Graph;SMTP</PackageTags>
<Description>ASP.NET Core extensions for facteur.</Description>
<Version>2.1.0</Version>
<Version>3.0.0-alpha.1</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions src/Facteur.MsGraph.Tests/Facteur.MsGraph.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 2 additions & 1 deletion src/Facteur.MsGraph.Tests/MsGraphTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Tasks;
using Facteur.MsGraph;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -27,7 +28,7 @@ public async Task Graph_SendMail_ShouldSend()
EmailComposer composer = new();
EmailRequest request = await composer
.Subject("Hello world")
.From("info@facteur.com")
.From("info@dimescheduler.com")
.To("[email protected]")
.BuildAsync(new TestMailModel { Email = "[email protected]", Name = "Guy Gadbois" });

Expand Down
9 changes: 5 additions & 4 deletions src/Facteur.MsGraph/AttachmentConverter.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using Microsoft.Graph;
using System.Collections.Generic;
using Microsoft.Graph.Models;

namespace Facteur.MsGraph
{
internal static class AttachmentConverter
{
internal static IMessageAttachmentsCollectionPage AddAttachments(this EmailRequest request)
internal static IEnumerable<Microsoft.Graph.Models.Attachment> AddAttachments(this EmailRequest request)
{
MessageAttachmentsCollectionPage attachments = new();
List<FileAttachment> attachments = [];
foreach (Attachment attachment in request.Attachments)
attachments.Add(new FileAttachment
{
ODataType = "#microsoft.graph.fileAttachment",
OdataType = "#microsoft.graph.fileAttachment",
Name = attachment.Name,
ContentBytes = attachment.ContentBytes
});
Expand Down
8 changes: 4 additions & 4 deletions src/Facteur.MsGraph/Facteur.MsGraph.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -14,15 +14,15 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Facteur;Email;Mail;Graph;Microsoft</PackageTags>
<Description>Send emails using the MS Graph endpoint</Description>
<Version>2.1.0</Version>
<Version>3.0.0-alpha.1</Version>
<Authors>Dime Software</Authors>
<Company>Dime Software</Company>
<Product>Facteur</Product>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Graph" Version="3.35.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.34.0" />
<PackageReference Include="Microsoft.Graph" Version="5.62.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.66.2" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 9 additions & 3 deletions src/Facteur.MsGraph/GraphCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ public readonly struct GraphCredentials
public GraphCredentials(string clientId, string tenantId, string clientSecret, string from)
{
if (string.IsNullOrEmpty(clientId))
throw new ArgumentNullException(nameof(clientSecret));
throw new ArgumentNullException(nameof(clientId));

if (string.IsNullOrEmpty(tenantId))
throw new ArgumentNullException(nameof(clientSecret));
throw new ArgumentNullException(nameof(tenantId));

if (string.IsNullOrEmpty(clientSecret))
throw new ArgumentNullException(nameof(clientSecret));

if (string.IsNullOrEmpty(from))
throw new ArgumentNullException(nameof(clientSecret));
throw new ArgumentNullException(nameof(from));

ClientId = clientId;
TenantId = tenantId;
Expand All @@ -22,8 +25,11 @@ public GraphCredentials(string clientId, string tenantId, string clientSecret, s
}

public string ClientId { get; }

public string TenantId { get; }

public string ClientSecret { get; }

public string From { get; }
}
}
33 changes: 15 additions & 18 deletions src/Facteur.MsGraph/GraphMailer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Graph;
using Microsoft.Graph.Models;
using Microsoft.Graph.Users.Item.SendMail;
using Microsoft.Identity.Client;
using Microsoft.Kiota.Abstractions.Authentication;

using t = System.Threading.Tasks;

Check warning on line 11 in src/Facteur.MsGraph/GraphMailer.cs

View workflow job for this annotation

GitHub Actions / build

The type name 't' only contains lower-cased ascii characters. Such names may become reserved for the language.

Check warning on line 11 in src/Facteur.MsGraph/GraphMailer.cs

View workflow job for this annotation

GitHub Actions / build

The type name 't' only contains lower-cased ascii characters. Such names may become reserved for the language.

Check warning on line 11 in src/Facteur.MsGraph/GraphMailer.cs

View workflow job for this annotation

GitHub Actions / build

The type name 't' only contains lower-cased ascii characters. Such names may become reserved for the language.

Check warning on line 11 in src/Facteur.MsGraph/GraphMailer.cs

View workflow job for this annotation

GitHub Actions / build

The type name 't' only contains lower-cased ascii characters. Such names may become reserved for the language.

Expand Down Expand Up @@ -37,22 +39,20 @@ public GraphMailer(GraphCredentials credentials, IEmailComposer composer = null)
/// <returns></returns>
public async t.Task SendMailAsync(EmailRequest request)
{
GraphServiceClient graphClient = await ConnectClient().ConfigureAwait(false);
GraphServiceClient graphClient = await ConnectClient();
Message message = new()
{
Subject = request.Subject,
Body = new ItemBody { ContentType = BodyType.Html, Content = request.Body },
ToRecipients = request.To.Select(x => new Recipient { EmailAddress = new EmailAddress { Address = x } }),
CcRecipients = request.Cc.Select(x => new Recipient { EmailAddress = new EmailAddress { Address = x } }),
BccRecipients = request.Bcc.Select(x => new Recipient { EmailAddress = new EmailAddress { Address = x } }),
Attachments = request.AddAttachments()
ToRecipients = request.To.Select(x => new Recipient { EmailAddress = new EmailAddress { Address = x } }).ToList(),
CcRecipients = request.Cc.Select(x => new Recipient { EmailAddress = new EmailAddress { Address = x } }).ToList(),
BccRecipients = request.Bcc.Select(x => new Recipient { EmailAddress = new EmailAddress { Address = x } }).ToList(),
Attachments = request.AddAttachments().ToList()
};

await graphClient.Users[Credentials.From]
.SendMail(message, false)
.Request()
.PostAsync()
.ConfigureAwait(false);
SendMailPostRequestBody requestBody = new() { Message = message };

await graphClient.Users[Credentials.From].SendMail.PostAsync(requestBody);
}

public async Task SendMailAsync(Func<IEmailComposer, Task<EmailRequest>> compose)
Expand All @@ -70,13 +70,10 @@ protected async t.Task<GraphServiceClient> ConnectClient()
.WithAuthority(authority)
.Build();

AuthenticationResult authenticationResult = await confidentialClientApplication.AcquireTokenForClient(scopes).ExecuteAsync().ConfigureAwait(false);

return new GraphServiceClient(new DelegateAuthenticationProvider(x =>
{
x.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);
return t.Task.FromResult(0);
}));
AuthenticationResult authenticationResult = await confidentialClientApplication.AcquireTokenForClient(scopes).ExecuteAsync();
TokenProvider provider = new(authenticationResult.AccessToken);
BaseBearerTokenAuthenticationProvider authenticationProvider = new(provider);
return new GraphServiceClient(authenticationProvider);
}
}
}
20 changes: 20 additions & 0 deletions src/Facteur.MsGraph/TokenProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Kiota.Abstractions.Authentication;

namespace Facteur.MsGraph
{
public class TokenProvider : IAccessTokenProvider
{
public string Token { get; set; }

public TokenProvider(string token) => Token = token;

public AllowedHostsValidator AllowedHostsValidator => throw new NotImplementedException();

public Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string, object>? additionalAuthenticationContext = null, CancellationToken cancellationToken = default)

Check warning on line 17 in src/Facteur.MsGraph/TokenProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 17 in src/Facteur.MsGraph/TokenProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 17 in src/Facteur.MsGraph/TokenProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 17 in src/Facteur.MsGraph/TokenProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
=> Task.FromResult(Token);
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit e7d2e2c

Please sign in to comment.