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

Upgrade to .NET 8 and prepare for .NET 9 #34

Merged
merged 4 commits into from
Nov 14, 2024
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
10 changes: 4 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
name: "CodeQL"

on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
Expand All @@ -30,7 +28,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand All @@ -43,7 +41,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +52,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +66,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
20 changes: 9 additions & 11 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: .NET

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand All @@ -12,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '8.0.x' ]
dotnet-version: [ '8.0.x', '9.0.x' ]

steps:
- uses: actions/checkout@v4
Expand All @@ -31,12 +29,12 @@ jobs:
run: dotnet build --no-restore
- name: Test
timeout-minutes: 2
run: dotnet test --no-build --verbosity normal --blame-hang-timeout 45s --blame-hang-dump-type full
- name: Archive test results
uses: actions/upload-artifact@v4
if: always()
with:
name: TestResults
path: |
/home/runner/work/Activout.RestClient/Activout.RestClient/Activout.RestClient.Test/TestResults/
run: dotnet test --no-build
# - name: Archive test results
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: TestResults
# path: |
# /home/runner/work/Activout.RestClient/Activout.RestClient/Activout.RestClient.Test/TestResults/

15 changes: 8 additions & 7 deletions Activout.RestClient.Test/Activout.RestClient.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
9 changes: 5 additions & 4 deletions Activout.RestClient/Activout.RestClient.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ImpromptuInterface" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.20" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ImpromptuInterface" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Linq" Version="4.3.0" />
</ItemGroup>
</Project>
52 changes: 0 additions & 52 deletions Activout.RestClient/RestClientException.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
using System;
using System.Net;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace Activout.RestClient
{
internal static class Extensions
{
public static T GetValue<T>(this SerializationInfo self, string name)
{
return (T)self.GetValue(name, typeof(T));
}

public static bool IsSerializable(this object obj)
{
if (obj == null)
return false;

var t = obj.GetType();
return t.IsSerializable;
}
}

[Serializable]
public class RestClientException : Exception
{
public RestClientException(Uri requestUri, HttpStatusCode statusCode, object errorResponse) : base(errorResponse?.ToString())
Expand All @@ -40,17 +20,6 @@ public RestClientException(Uri requestUri, HttpStatusCode statusCode, string err
ErrorResponse = errorResponse;
}

protected RestClientException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
StatusCode = info.GetValue<HttpStatusCode>(nameof(StatusCode));
var typeName = info.GetString(nameof(Type));
if (typeName != null)
{
ErrorResponse = info.GetValue(nameof(ErrorResponse), Type.GetType(typeName));
}
}

public Uri RequestUri { get; }
public HttpStatusCode StatusCode { get; }

Expand All @@ -61,27 +30,6 @@ public T GetErrorResponse<T>()
return (T)ErrorResponse;
}

#if !NET5_0_OR_GREATER
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null) throw new ArgumentNullException(nameof(info));

info.AddValue(nameof(StatusCode), StatusCode);
if (ErrorResponse.IsSerializable())
{
info.AddValue(nameof(Type), ErrorResponse.GetType().AssemblyQualifiedName);
info.AddValue(nameof(ErrorResponse), ErrorResponse);
}
else
{
info.AddValue(nameof(Type), null);
}

base.GetObjectData(info, context);
}

public override string ToString()
{
return $"{base.ToString()}, {nameof(RequestUri)}: {RequestUri}, {nameof(StatusCode)}: {StatusCode}, {nameof(ErrorResponse)}: {ErrorResponse}";
Expand Down