Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support net 9 #95

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x

- name: Checkout Wiremock fixtures repo
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-version: '9.0.x'

# https://github.com/dawidd6/action-download-artifact
- name: Download artifact
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/sinch/sinch-sdk-dotnet/blob/main/LICENSE)

[![.NET 6.0](https://img.shields.io/badge/.NET-6.0-blue.svg)](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
[![.NET 7.0](https://img.shields.io/badge/.NET-7.0-blue.svg)](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
[![.NET 8.0](https://img.shields.io/badge/.NET-8.0-blue.svg)](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
[![.NET 9.0](https://img.shields.io/badge/.NET-9.0-blue.svg)](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)

Here you'll find documentation related to the Sinch .NET SDK, including how to install it, initialize it, and start developing .NET code using Sinch services.

Expand Down
4 changes: 2 additions & 2 deletions examples/Console/Examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetEnv" Version="2.5.0" />
<PackageReference Include="DotNetEnv" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 10 additions & 3 deletions examples/WebApi/Controllers/HandleFaxEventController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace WebApiExamples.Controllers
[Route("fax")]
public class HandleFaxEventController : ControllerBase
{
private List<string> _incomingFaxIds = new(); // track fax ids which was sent
private readonly List<string> _incomingFaxIds = new(); // track fax ids which was sent

[HttpPost]
[Route("event-json")]
Expand All @@ -19,15 +19,22 @@ public async Task<IActionResult> HandleJsonEvent([FromBody] IFaxEvent faxEvent)
{
case IncomingFaxEvent incomingFaxEvent:
// just track fax ids for future
_incomingFaxIds.Add(incomingFaxEvent.Fax.Id);
if (incomingFaxEvent?.Fax?.Id is not null)
{
_incomingFaxIds.Add(incomingFaxEvent.Fax.Id);
}
break;
case CompletedFaxEvent completedFaxEvent:
// download if fax completed
foreach (var file in completedFaxEvent.Files)
{
if (file.File is null || completedFaxEvent.Fax is null)
{
continue;
}
var bytes = Convert.FromBase64String(file.File);
var contents = new MemoryStream(bytes);
var fileName = completedFaxEvent.Fax.Id + "." + file.FileType.Value.ToLower();
var fileName = completedFaxEvent.Fax.Id + "." + file.FileType?.Value.ToLower();
await SaveFile(fileName, contents);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion examples/WebApi/WebApiExamples.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>f6d17a10-702c-41a9-b9e3-8f42339006f6</UserSecretsId>
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/Auth/OAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private class AuthResponse
{
[JsonPropertyName("access_token")]
#if NET7_0_OR_GREATER
public required string AccessToken { get; set; }
public required string AccessToken { get; set; }
#else
public string AccessToken { get; set; } = null!;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CreateTemplateRequest
/// Gets or Sets Translations
/// </summary>
#if NET7_0_OR_GREATER
public required List<TemplateTranslation> Translations { get; set; }
public required List<TemplateTranslation> Translations { get; set; }
#else
public List<TemplateTranslation> Translations { get; set; } = null!;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/Conversation/TemplatesV2/Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Template
/// be unique for a given project.
/// </summary>
#if NET7_0_OR_GREATER
public required string Id { get; set; }
public required string Id { get; set; }
#else
public string Id { get; set; } = null!;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/Conversation/Webhooks/Webhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public string? Secret
/// Maximum URL length is 742. The conversation-api.*.sinch.com subdomains are forbidden.
/// </summary>
#if NET7_0_OR_GREATER
public required string Target
public required string Target
#else
public string Target
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/Core/StreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static string ConvertToBase64(this Stream stream)
var bytes = new Byte[(int)stream.Length];

stream.Seek(0, SeekOrigin.Begin);
stream.Read(bytes, 0, (int)stream.Length);
stream.ReadExactly(bytes, 0, (int)stream.Length);

return Convert.ToBase64String(bytes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/SMS/Groups/Replace/ReplaceGroupRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public sealed class ReplaceGroupRequest
/// <see href="https://community.sinch.com/t5/Glossary/E-164/ta-p/7537">E.164</see> format MSISDNs.
/// </summary>
#if NET7_0_OR_GREATER
public required List<string> Members { get; init; }
public required List<string> Members { get; init; }
#else
public List<string> Members { get; set; } = null!;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/SMS/Hooks/IncomingTextSms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class IncomingTextSms : IIncomingSms
/// </summary>
[JsonPropertyName("body")]
#if NET7_0_OR_GREATER
public required virtual string Body { get; set; }
public required virtual string Body { get; set; }
#else
public virtual string Body { get; set; } = null!;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Sinch/Sinch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Nullable>enable</Nullable>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<RepositoryUrl>https://github.com/sinch/sinch-sdk-dotnet</RepositoryUrl>
<Version>0.1.0</Version>
<Title>Sinch</Title>
Expand Down
4 changes: 2 additions & 2 deletions tests/Sinch.Tests/Sinch.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetEnv" Version="2.5.0" />
<PackageReference Include="DotNetEnv" Version="3.1.1" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="FluentAssertions.Json" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
Expand Down
Loading