Skip to content

Commit

Permalink
Upgrade to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Marfusios committed Feb 16, 2024
1 parent 5ae22c0 commit da80011
Show file tree
Hide file tree
Showing 33 changed files with 304 additions and 323 deletions.
10 changes: 0 additions & 10 deletions .github/notification_pr.workflow

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/dotnet-core-branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: .NET Core (branch)

on:
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
37 changes: 37 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: .NET Core

on:
push:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.x

- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --logger "trx;LogFileName=tests.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: tests
path: '**/*.trx'
reporter: dotnet-trx
- name: Pack library project
run: dotnet pack src/Bitfinex.Client.Websocket/Bitfinex.Client.Websocket.csproj --no-build --configuration Release --include-symbols -p:SymbolPackageFormat=snupkg -o .
- name: Publish library (NuGet)
run: dotnet nuget push *.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
#- name: Publish library (Github)
# run: dotnet nuget push *.nupkg --api-key ${{secrets.PUBLISH_TO_GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/marfusios/index.json" --skip-duplicate
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions Bitfinex.Client.Websocket.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
# Visual Studio Version 17
VisualStudioVersion = 17.8.34601.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{360B18BD-653A-4824-9261-C88167EEBAD2}"
EndProject
Expand All @@ -19,8 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bitfinex.Client.Websocket.S
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6D0FCFA1-4C4C-4BBD-83CC-22C8E464E338}"
ProjectSection(SolutionItems) = preProject
.travis.yml = .travis.yml
bitfinex_logo.png = bitfinex_logo.png
.github\workflows\dotnet-core-branches.yml = .github\workflows\dotnet-core-branches.yml
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
Expand Down
9 changes: 9 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<!-- Project defaults -->

<PropertyGroup>
<Version>4.1.0</Version>
</PropertyGroup>

</Project>
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,3 @@ Due to the large amount of questions about integration of this library into a de
### Available for help
I do consulting, please don't hesitate to contact me if you have a custom solution you would like me to implement ([web](http://mkotas.cz/),
<[email protected]>)

Donations gratefully accepted.
* [![Donate with Bitcoin](https://en.cryptobadges.io/badge/small/1HfxKZhvm68qK3gE8bJAdDBWkcZ2AFs9pw)](https://en.cryptobadges.io/donate/1HfxKZhvm68qK3gE8bJAdDBWkcZ2AFs9pw)
* [![Donate with Litecoin](https://en.cryptobadges.io/badge/small/LftdENE8DTbLpV6RZLKLdzYzVU82E6dz4W)](https://en.cryptobadges.io/donate/LftdENE8DTbLpV6RZLKLdzYzVU82E6dz4W)
* [![Donate with Ethereum](https://en.cryptobadges.io/badge/small/0xb9637c56b307f24372cdcebd208c0679d4e48a47)](https://en.cryptobadges.io/donate/0xb9637c56b307f24372cdcebd208c0679d4e48a47)
63 changes: 32 additions & 31 deletions src/Bitfinex.Client.Websocket/Bitfinex.Client.Websocket.csproj
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5;net6</TargetFrameworks>
<PackageId>Bitfinex.Client.Websocket</PackageId>
<Version>4.0.0</Version>
<Authors>Mariusz Kotas</Authors>
<Description>Client for Bitfinex and Ethfinex websocket API version 2.0</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes></PackageReleaseNotes>
<Copyright>Copyright 2021 Mariusz Kotas. All rights reserved.</Copyright>
<PackageTags>Bitfinex Ethfinex websockets websocket client cryptocurrency exchange bitcoin</PackageTags>
<PackageLicenseUrl>https://github.com/Marfusios/bitfinex-client-websocket/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/Marfusios/bitfinex-client-websocket</PackageProjectUrl>
<PackageIconUrl>http://blog.bitfinex.com/wp-content/uploads/2016/05/bfx-stacked.png</PackageIconUrl>
<RepositoryUrl>https://github.com/Marfusios/bitfinex-client-websocket</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.0.0.0</FileVersion>
<PropertyGroup>
<TargetFrameworks>netstandard2.1;net6;net7;net8</TargetFrameworks>
<PackageId>Bitfinex.Client.Websocket</PackageId>
<Authors>Mariusz Kotas</Authors>
<Description>Client for Bitfinex and Ethfinex websocket API version 2.0</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Enhancements</PackageReleaseNotes>
<Copyright>Copyright 2024 Mariusz Kotas. All rights reserved.</Copyright>
<PackageTags>Bitfinex Ethfinex websockets websocket client cryptocurrency exchange bitcoin</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Marfusios/bitfinex-client-websocket</PackageProjectUrl>
<PackageIconUrl>http://blog.bitfinex.com/wp-content/uploads/2016/05/bfx-stacked.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/Marfusios/bitfinex-client-websocket</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryType>Git</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibLog" Version="5.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Reactive" Version="4.4.1" />
<PackageReference Include="Websocket.Client" Version="4.4.40" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="Websocket.Client" Version="5.1.1" />
</ItemGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Bitfinex.Client.Websocket.Logging;
using Bitfinex.Client.Websocket.Responses.Balance;
using Bitfinex.Client.Websocket.Responses.Configurations;
using Bitfinex.Client.Websocket.Responses.Notifications;
Expand All @@ -9,18 +8,20 @@
using Bitfinex.Client.Websocket.Responses.Trades;
using Bitfinex.Client.Websocket.Responses.TradesPrivate;
using Bitfinex.Client.Websocket.Responses.Wallets;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;

namespace Bitfinex.Client.Websocket.Client
{
internal class BitfinexAuthenticatedHandler
{
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
private readonly ILogger _logger;
private readonly BitfinexClientStreams _streams;

public BitfinexAuthenticatedHandler(BitfinexClientStreams streams, BitfinexChannelList channelIdToHandler)
public BitfinexAuthenticatedHandler(BitfinexClientStreams streams, BitfinexChannelList channelIdToHandler, ILogger logger)
{
_streams = streams;
_logger = logger;

channelIdToHandler[0] = HandleAccountInfo;
}
Expand All @@ -35,17 +36,17 @@ internal void HandleAccountInfo(JToken token, ConfigurationState config)
var itemsCount = token?.Count();
if (token == null || itemsCount < 2)
{
Log.Warn($"Invalid message format, too low items");
_logger.LogWarning(L("Invalid message format, too low items"));
return;
}

var secondItem = token[1];
if (secondItem.Type != JTokenType.String)
if (secondItem?.Type != JTokenType.String)
{
Log.Warn(L("Invalid message format, second param is not string"));
_logger.LogWarning(L("Invalid message format, second param is not string"));
return;
}
var msgType = (string)secondItem;
var msgType = (string?)secondItem;
if (msgType == "hb")
{
// heartbeat, ignore
Expand All @@ -54,7 +55,7 @@ internal void HandleAccountInfo(JToken token, ConfigurationState config)

if (itemsCount < 3)
{
Log.Warn(L("Invalid message format, too low items"));
_logger.LogWarning(L("Invalid message format, too low items"));
return;
}

Expand Down Expand Up @@ -109,9 +110,9 @@ internal void HandleAccountInfo(JToken token, ConfigurationState config)
case "miu":
MarginInfo.Handle(token, _streams.MarginInfoSubject);
break;
//default:
// Log.Warning($"Missing private handler for '{msgType}'. Data: {token}");
// break;
//default:
// Log.Warning($"Missing private handler for '{msgType}'. Data: {token}");
// break;
}
}
}
Expand Down
34 changes: 17 additions & 17 deletions src/Bitfinex.Client.Websocket/Client/BitfinexPublicHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Bitfinex.Client.Websocket.Logging;
using Bitfinex.Client.Websocket.Messages;
using Bitfinex.Client.Websocket.Responses;
using Bitfinex.Client.Websocket.Responses.Books;
Expand All @@ -14,8 +13,6 @@ namespace Bitfinex.Client.Websocket.Client
{
internal class BitfinexPublicHandler
{
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();

private readonly BitfinexClientStreams _streams;
private readonly BitfinexChannelList _channelIdToHandler;

Expand Down Expand Up @@ -52,14 +49,17 @@ public void OnObjectMessage(string msg)
case MessageType.Unsubscribed:
UnsubscribedResponse.Handle(msg, _streams.UnsubscriptionSubject);
break;
//default:
// Log.Warning($"Missing handler for public stream, data: '{msg}'");
// break;
//default:
// Log.Warning($"Missing handler for public stream, data: '{msg}'");
// break;
}
}

private void OnSubscription(SubscribedResponse response)
private void OnSubscription(SubscribedResponse? response)
{
if (response == null)
return;

_streams.SubscriptionSubject.OnNext(response);

var channelId = response.ChanId;
Expand All @@ -71,32 +71,32 @@ private void OnSubscription(SubscribedResponse response)
switch (response.Channel)
{
case "ticker":
_channelIdToHandler[channelId] = (data, config) =>
_channelIdToHandler[channelId] = (data, config) =>
Ticker.Handle(data, response, config, _streams.TickerSubject);
break;
case "trades":
//if pair is null means that is funding
if (response.Pair == null)
{
_channelIdToHandler[channelId] = (data, config) =>
_channelIdToHandler[channelId] = (data, config) =>
Funding.Handle(data, response, config, _streams.FundingsSubject);
}
else
{
_channelIdToHandler[channelId] = (data, config) =>
_channelIdToHandler[channelId] = (data, config) =>
Trade.Handle(data, response, config, _streams.TradesSubject, _streams.TradesSnapshotSubject);
}
break;
case "candles":
_channelIdToHandler[channelId] = (data, config) =>
_channelIdToHandler[channelId] = (data, config) =>
Candles.Handle(data, response, _streams.CandlesSubject);
break;
case "book":
if("R0".Equals(response.Prec, StringComparison.OrdinalIgnoreCase))
_channelIdToHandler[channelId] = (data, config) =>
if ("R0".Equals(response.Prec, StringComparison.OrdinalIgnoreCase))
_channelIdToHandler[channelId] = (data, config) =>
RawBook.Handle(data, response, config, _streams.RawBookSubject, _streams.RawBookSnapshotSubject, _streams.BookChecksumSubject);
else
_channelIdToHandler[channelId] = (data, config) =>
_channelIdToHandler[channelId] = (data, config) =>
Book.Handle(data, response, config, _streams.BookSubject, _streams.BookSnapshotSubject, _streams.BookChecksumSubject);
break;
case "status":
Expand All @@ -113,9 +113,9 @@ private void OnSubscription(SubscribedResponse response)
}

break;
//default:
// Log.Warning($"Missing subscription handler '{response.Channel}'");
// break;
//default:
// Log.Warning($"Missing subscription handler '{response.Channel}'");
// break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Bitfinex.Client.Websocket.Client
{
internal static class BitfinexSerialization
{
public static T Deserialize<T>(string msg)
public static T? Deserialize<T>(string msg) where T : class
{
return JsonConvert.DeserializeObject<T>(msg, BitfinexJsonSerializer.Settings);
}
Expand Down
Loading

0 comments on commit da80011

Please sign in to comment.