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

4.x #124

Merged
merged 15 commits into from
Jul 11, 2022
Merged

4.x #124

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
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish dotnet package to nuget

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout csharp-rest-api
uses: actions/checkout@v3

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x

- name: Build release
run: dotnet build --configuration Release MessageBird -f net6.0

- name: Create the package
run: dotnet pack --configuration Release /p:Version=${{github.event.release.tag_name}} MessageBird

- name: Publish the package to GPR
run: dotnet nuget push MessageBird/bin/Release/*.nupkg --api-key ${{secrets.NUGET_AUTH_TOKEN}} --source https://api.nuget.org/v3/index.json
22 changes: 13 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ name: Tests
on:
pull_request:
push:
branches: [master, main]
branches: [ master, main ]

jobs:
build:
runs-on: ubuntu-latest
name: Dotnet Side by Side testing sample
name: Build and test
steps:
- uses: actions/checkout@v3
- name: Setup dotnet
- name: Checkout csharp-rest-api
uses: actions/checkout@v3

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
2.1.x
3.1.x
- run: dotnet build MessageBird -f netstandard2.0
- run: dotnet test Tests/UnitTests/MessageBirdUnitTests -f netcoreapp2.0
dotnet-version: 6.0.x

- name: Build
run: dotnet build MessageBird -f net6.0

- name: Test
run: dotnet test Tests/MessageBird.Tests -f net6.0
7 changes: 3 additions & 4 deletions MessageBird/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ public static Client CreateDefault(string accessKey, IProxyConfigurationInjector

#region Programmable SMS API

public Message SendMessage(string originator, string body, long[] msisdns, MessageOptionalArguments optionalArguments = null)
public Message SendMessage(string originator, string body, long[] recipients, MessageOptionalArguments optionalArguments = null)
{
ParameterValidator.IsNotNullOrWhiteSpace(originator, "originator");
ParameterValidator.IsNotNullOrWhiteSpace(body, "body");
ParameterValidator.ContainsAtLeast(msisdns, 1, "msisdns");
ParameterValidator.ContainsAtLeast(recipients, 1, "recipients");

if (optionalArguments != null)
{
ParameterValidator.IsValidMessageType(optionalArguments.Type);
}

var recipients = new Recipients(msisdns);
var message = new Message(originator, body, recipients, optionalArguments);
var message = new Message(originator, body, new Recipients(recipients), optionalArguments);

var messages = new Messages(message);
var result = restClient.Create(messages);
Expand Down
3 changes: 1 addition & 2 deletions MessageBird/Exceptions/ErrorException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public bool HasReason
get { return !String.IsNullOrEmpty(Reason); }
}

public ErrorException(string reason, Exception innerException = null)
: base(reason, innerException)
public ErrorException(string reason, Exception? innerException = null) : base(reason, innerException)
{
Reason = reason;
}
Expand Down
23 changes: 6 additions & 17 deletions MessageBird/MessageBird.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<Product>MessageBird</Product>
<Title>MessageBird</Title>
<Company>MessageBird</Company>
<Copyright>Copyright © 2019</Copyright>
<FileVersion>3.1.0.0</FileVersion>
<InformationalVersion>3.1.0.0</InformationalVersion>
<Version>3.1.0.0</Version>
<AssemblyVersion>3.1.0.0</AssemblyVersion>
<LangVersion>4</LangVersion>
<Copyright>Copyright © 2022</Copyright>

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<!-- Conditionally obtain references for the .NET Framework 4.0 target -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
</ItemGroup>

<ItemGroup>
<PackageReference Include="JWT" Version="8.2.3" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like the switch to target .net6.0.
Be ware that targetting .net6.0 might leave customers running on .NET Framework behind, as you are no longer targetting .netstandard 6.0.
https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-1-0#net-standard-not-deprecated

Is it possible to remove this dependency to JWT and switch over to System.Text.Json? That would result in a library with only framework dependencies.
JWT package still depends on Newtonsoft.Json, there is an issue on their side to replace it: jwt-dotnet/jwt#364

Copy link
Contributor Author

@marcelcorso marcelcorso Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I think it's time we leave the .NET Framework behind.
Well make a major change release and then people have a chance to stay on old versions.

About your idea of using System's Jason.. it looks like a very good one.
We have limited c# knowledge these days over here so if you can do a PR or point us on the right direction it would be amazing

<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Objects\Common\" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>MessageBirdUnitTests</_Parameter1>
Expand Down
26 changes: 0 additions & 26 deletions MessageBird/MessageBird.csproj.nuspec

This file was deleted.

3 changes: 1 addition & 2 deletions MessageBird/Objects/Recipients.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public Recipients()
SerializeMsisdnsOnly = true;
}

public Recipients(IEnumerable<long> msisdns)
: this()
public Recipients(IEnumerable<long> msisdns) : this()
{
foreach (long msisdn in msisdns)
{
Expand Down
50 changes: 0 additions & 50 deletions MessageBird/Objects/Request.cs

This file was deleted.

86 changes: 0 additions & 86 deletions MessageBird/RequestSigner.cs

This file was deleted.

4 changes: 2 additions & 2 deletions MessageBird/RequestValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public RequestValidator(string secret, bool skipURLValidation = false)
}

/// <summary>
/// Internal constructor visible for unit testing.
/// Constructor that allows you to overwrite the dateTimeProvider for easier testing
/// </summary>
internal RequestValidator(string secret, IDateTimeProvider dateTimeProvider) : this(secret)
public RequestValidator(string secret, IDateTimeProvider dateTimeProvider) : this(secret)
{
_jwtBuilder = _jwtBuilder.WithDateTimeProvider(dateTimeProvider);
}
Expand Down
2 changes: 0 additions & 2 deletions NuGet/.gitignore

This file was deleted.

Binary file removed NuGet/MessageBird.dll
Binary file not shown.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Requirements

- [Sign up](https://www.messagebird.com/en/signup) for a free MessageBird account
- Create a new access_key in the developers sections
- MessageBird API client for C# requires **.NET Framework >= 4** or **.NET Standard >= 2.0**
- It has a dependency on **JSON.NET >= 4.5.6**

Installation
-----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\MessageBird\MessageBird.csproj" />
<ProjectReference Include="..\..\MessageBird\MessageBird.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="WireMock.Net" Version="1.0.21" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="WireMock.Net" Version="1.2.18" />
</ItemGroup>
<ItemGroup>
<Content Include="Responses\**">
Expand All @@ -34,4 +34,4 @@
<ItemGroup>
<None Include="Responses\WebhooksList.json" />
</ItemGroup>
</Project>
</Project>
Loading