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

Multitarget #49

Merged
merged 8 commits into from
Nov 10, 2021
Merged
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
5 changes: 5 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET 5.0 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.x'

- name: Setup .NET 6.0 SDK
uses: actions/setup-dotnet@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ jobs:
with:
useConfigFile: true

- name: Setup .NET 5.0 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.x'

- name: Setup .NET 6.0 SDK
uses: actions/setup-dotnet@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions src/FaluSdk/Core/BaseServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ protected virtual async Task<ResourceResponse<TResource>> RequestCoreAsync<TReso

// get a stream reference for the content
// the stream may still be being incoming and thus we should only read when necessary
#if NET5_0_OR_GREATER
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
#else
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
#endif

// if the response was a success then deserialize the body as TResource otherwise TError
if (response.IsSuccessStatusCode)
Expand Down
2 changes: 1 addition & 1 deletion src/FaluSdk/Events/EventUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static bool IsSignaturePresent(string signature, IEnumerable<string> sig
return signatures.Any(key => string.Equals(key, signature, StringComparison.Ordinal));
}

private static string ComputeSignature(string secret, string timestamp, string payload)
private static string ComputeSignature(string secret, string? timestamp, string payload)
{
var secretBytes = Encoding.UTF8.GetBytes(secret);
var payloadBytes = Encoding.UTF8.GetBytes($"{timestamp}.{payload}");
Expand Down
2 changes: 1 addition & 1 deletion src/FaluSdk/Extensions/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static IHttpClientBuilder AddFalu<TClient, TClientOptions>(this IServiceC
services.AddSingleton<IPostConfigureOptions<TClientOptions>, PostConfigureFaluClientOptions<TClientOptions>>();

// get the version from the assembly
var productVersion = typeof(TClient).Assembly.GetName().Version.ToString(3);
var productVersion = typeof(TClient).Assembly.GetName().Version!.ToString(3);

// setup client
var builder = services.AddHttpClient<TClient>()
Expand Down
2 changes: 1 addition & 1 deletion src/FaluSdk/FaluClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static JsonSerializerOptions CreateSerializerOptions()
{
var serializerOptions = new JsonSerializerOptions
{
IgnoreNullValues = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
PropertyNameCaseInsensitive = true,
AllowTrailingCommas = true,
Expand Down
2 changes: 1 addition & 1 deletion src/FaluSdk/FaluSdk.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<Description>The official client library for Falu. (https://falu.io)</Description>
<RootNamespace>Falu</RootNamespace>
<PackageIcon>falu-logo.png</PackageIcon>
Expand Down
3 changes: 2 additions & 1 deletion src/FaluSdk/Files/FilesServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public virtual Task<ResourceResponse<File>> CreateAsync(FileCreateRequest file,
throw new InvalidOperationException($"{nameof(file.FileName)} cannot be null or whitespace.");
}

var purpose = file.Purpose!.Value;
var content = new MultipartFormDataContent
{
// populate fields of the model as key value pairs
{ new StringContent(file.Purpose?.GetEnumMemberAttrValueOrDefault()), "purpose" },
{ new StringContent(purpose.GetEnumMemberAttrValueOrDefault()), "purpose" },

// populate the file stream
{ new StreamContent(file.Content), "file", file.FileName },
Expand Down
2 changes: 1 addition & 1 deletion src/FaluSdk/ResourceResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static void AddIf(IList<string> collection, string? value, string format
t = Nullable.GetUnderlyingType(t);
}

return (T)Convert.ChangeType(value, t);
return (T?)Convert.ChangeType(value, t!);
}
}
}
2 changes: 1 addition & 1 deletion tests/FaluSdk.Tests/FaluSdk.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
<RootNamespace>Falu.Tests</RootNamespace>
Expand Down