Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Feb 10, 2023
2 parents edf3607 + fdcf084 commit ce5d6d9
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 151 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

58 changes: 29 additions & 29 deletions .github/workflows/codequality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install .NET 3.1.x LTS
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"

- name: Install .NET 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"
- name: Install .NET 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"

- name: Restore Tools
run: dotnet tool restore

- name: Restore Packages
run: dotnet restore

- name: InspectCode
run: dotnet jb inspectcode ${{github.workspace}}/DragonFruit.Data.sln --output=${{github.workspace}}/inspectcodereport.xml --cachesDir=${{github.workspace}}/inspectcode --verbosity=WARN --no-build

- name: NVika
run: dotnet nvika parsereport "${{github.workspace}}/inspectcodereport.xml"
- name: Checkout
uses: actions/checkout@v2

- name: Install .NET 3.1.x LTS
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"

- name: Install .NET 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x"

- name: Install .NET 6.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"

- name: Restore Tools
run: dotnet tool restore

- name: Restore Packages
run: dotnet restore

- name: InspectCode
run: dotnet jb inspectcode ${{github.workspace}}/DragonFruit.Data.sln --output=${{github.workspace}}/inspectcodereport.xml --cachesDir=${{github.workspace}}/inspectcode --verbosity=WARN --no-build

- name: NVika
run: dotnet nvika parsereport "${{github.workspace}}/inspectcodereport.xml"
32 changes: 29 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Publish

on:
Expand All @@ -7,5 +6,32 @@ on:

jobs:
deploy:
secrets: inherit
uses: dragonfruitnetwork/workflows/.github/workflows/nuget-publish.yml@master
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'

- name: Restore
run: |
dotnet workload install android
dotnet restore
- name: Build
run: dotnet build -c Release -v normal -p:EnableAndroid=true -p:Version=${{ github.ref_name }}

- name: Pack (Beta)
run: dotnet pack -c Release --include-symbols --no-build -v normal -o . -p:EnableAndroid=true -p:PackageVersion=${{ github.ref_name }}-beta
if: "github.event.release.prerelease"

- name: Pack (Stable)
run: dotnet pack -c Release --include-symbols --no-build -v normal -o . -p:EnableAndroid=true -p:PackageVersion=${{ github.ref_name }}
if: "!github.event.release.prerelease"

- name: Publish
run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_KEY }} --skip-duplicate -s https://api.nuget.org/v3/index.json
6 changes: 3 additions & 3 deletions res/DragonFruit.Data.Nuget.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<RepositoryType>git</RepositoryType>
<Authors>DragonFruit Network</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright 2021 (C) DragonFruit Network</Copyright>
<Copyright>Copyright 2023 (C) DragonFruit Network</Copyright>
<PackageTags>file, api, web, io, framework, dragonfruit, common</PackageTags>
<RepositoryUrl>https://github.com/dragonfruitnetwork/dragonfruit.common</RepositoryUrl>
<PackageProjectUrl>https://github.com/dragonfruitnetwork/dragonfruit.common</PackageProjectUrl>
<RepositoryUrl>https://github.com/dragonfruitnetwork/dragonfruit-common</RepositoryUrl>
<PackageProjectUrl>https://github.com/dragonfruitnetwork/dragonfruit-common</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion res/DragonFruit.Data.Serializers.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<LangVersion>8</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion res/DragonFruit.Data.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<LangVersion>8</LangVersion>
</PropertyGroup>

Expand Down
80 changes: 0 additions & 80 deletions src/ApiClient_Sync.cs

This file was deleted.

6 changes: 4 additions & 2 deletions src/DragonFruit.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project>

<Import Project="$(SolutionDir)res\DragonFruit.Data.props" />

<PropertyGroup>
<TargetFrameworks Condition="'$(EnableAndroid)' == 'true'">$(TargetFrameworks);net6.0-android</TargetFrameworks>

<PackageId>DragonFruit.Data</PackageId>
<Description>A web requests framework for .NET that powers the DragonFruit APIs</Description>
</PropertyGroup>
Expand All @@ -11,6 +15,4 @@
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

<Import Project="$(SolutionDir)res\DragonFruit.Data.props" />

</Project>
30 changes: 22 additions & 8 deletions src/Utils/ParameterUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@ public static class ParameterUtils
{
private const string DefaultConcatenationCharacter = ",";

/// <summary>
/// Default <see cref="BindingFlags"/> to search for matching properties
/// </summary>
private const BindingFlags DefaultFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;

/// <summary>
/// Gets an <see cref="IEnumerable{T}"/> of <see cref="KeyValuePair{TKey,TValue}"/>s from properties with a specified <see cref="IProperty"/>-inheriting attribute.
/// </summary>
internal static IEnumerable<KeyValuePair<string, string>> GetParameter<T>(object host, CultureInfo culture) where T : IProperty
{
foreach (var property in host.GetType().GetProperties(DefaultFlags))
foreach (var property in host.GetType().GetTargetProperties())
{
if (!property.CanRead || !(Attribute.GetCustomAttribute(property, typeof(T)) is T attribute))
{
Expand Down Expand Up @@ -77,7 +72,7 @@ internal static IEnumerable<KeyValuePair<string, string>> GetParameter<T>(object
yield return propertyValue.ToString().ToUpper(culture).Replace(" ", string.Empty).ToKeyValuePair(keyName, culture);
break;

case null:
default:
yield return propertyValue.ToKeyValuePair(keyName, culture);
break;
}
Expand All @@ -96,7 +91,7 @@ internal static object GetSingleParameterObject<T>(object host) where T : Attrib
{
var targetType = typeof(T);
var attributedProperty = host.GetType()
.GetProperties(DefaultFlags)
.GetTargetProperties()
.SingleOrDefault(x => Attribute.GetCustomAttribute(x, targetType) is T);

if (attributedProperty == default)
Expand Down Expand Up @@ -126,6 +121,25 @@ private static IEnumerable<KeyValuePair<string, string>> ApplyOrderedConversion(
(enumerator as IDisposable)?.Dispose();
}

private static IEnumerable<PropertyInfo> GetTargetProperties(this Type target)
{
#if NET6_0 && ANDROID
// android has an issue where nonpublic properties aren't returned from base classes (see https://github.com/dotnet/runtime/pull/77169)
var props = target.GetRuntimeProperties();
var baseType = target.BaseType;

while (baseType != null && baseType != typeof(ApiRequest))
{
props = props.Concat(baseType.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static));
baseType = baseType.BaseType;
}

return props;
#else
return target.GetRuntimeProperties();
#endif
}

private static IEnumerable<KeyValuePair<string, string>> ApplyConcatenation(IEnumerable values, string keyName, CultureInfo culture, string concatCharacter)
{
yield return new KeyValuePair<string, string>(keyName, string.Join(concatCharacter, values.Cast<object>().Select(x => x.AsString(culture))));
Expand Down
2 changes: 1 addition & 1 deletion tests/DragonFruit.Data.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<LangVersion>9</LangVersion>
<IsPackable>false</IsPackable>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions tests/Header/HeaderLevelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. Please refer to the LICENSE file at the root of this project for details

using System;
using System.Threading.Tasks;
using DragonFruit.Data.Extensions;
using DragonFruit.Data.Tests.Requests;
using Newtonsoft.Json.Linq;
Expand All @@ -19,7 +20,7 @@ public class HeaderLevelTests : ApiTest
/// Test whether request-headers and default headers are sent together successfully
/// </summary>
[TestCase]
public void LevelSpecificHeaderTest()
public async Task LevelSpecificHeaderTest()
{
var request = new EchoRequest();

Expand All @@ -29,7 +30,7 @@ public void LevelSpecificHeaderTest()
Client.Headers[GlobalHeaderName] = globalHeaderValue;
request.WithHeader(HeaderName, requestHeaderValue);

var response = Client.Perform<JObject>(request);
var response = await Client.PerformAsync<JObject>(request);
Assert.AreEqual(requestHeaderValue, (string)response["headers"]![HeaderName]);
Assert.AreEqual(globalHeaderValue, (string)response["headers"][GlobalHeaderName]);
}
Expand All @@ -39,7 +40,7 @@ public void LevelSpecificHeaderTest()
/// with the request header taking priority
/// </summary>
[TestCase]
public void LevelOverrideHeaderTest()
public async Task LevelOverrideHeaderTest()
{
var request = new EchoRequest();

Expand All @@ -49,7 +50,7 @@ public void LevelOverrideHeaderTest()
Client.Headers[GlobalHeaderName] = globalHeaderValue;
request.WithHeader(GlobalHeaderName, requestHeaderValue);

var response = Client.Perform<JObject>(request);
var response = await Client.PerformAsync<JObject>(request);
Assert.AreEqual(requestHeaderValue, (string)response["headers"]![GlobalHeaderName]);
}
}
Expand Down
Loading

0 comments on commit ce5d6d9

Please sign in to comment.