build: Upgrade TargetFramework to net7.0
We've been using several net7.0 preview features for a while now. Now that a stable net7.0 release is available, it is time upgrade officially. This also aids the effort to build csharp on Linux, where these preview features didn't work out of the box. Lastly, trying to make these preview features work would be a waste of time, as namespaces/interfaces in the official release have changed in a way that isn't backwards compatible w/ the preview features.
This commit is contained in:
1 parent
ac6c9e5c46
commit
88302c9470
22 files changed
+113
-99
No files matched your search
@@ -13,6 +13,7 @@
|
||||
<ShowMissingItemTypes>false</ShowMissingItemTypes>
|
||||
<Configuration Condition="'$(configuration)'==''">Debug</Configuration>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<LangVersion>11</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Label="Output">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
@@ -34,7 +34,6 @@
|
||||
<PackageReference Include="System.Reactive.Interfaces" Version="5.0.0" />
|
||||
<PackageReference Include="System.Reactive.Linq" Version="5.0.0" />
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="5.0.0" />
|
||||
<PackageReference Include="System.Runtime.Experimental" Version="6.0.2" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<ProjectReference Include="../spark_api/spark_api.csproj" />
|
||||
<ProjectReference Include="../spark_core/spark_core.csproj" />
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
|
||||
static class TickUpDownHelper {
|
||||
public const string
|
||||
@@ -13,7 +14,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
public static string? format<T>(
|
||||
T? new_value, string curr_text, TickDisplaySettingsImmutable? settings = null)
|
||||
where T : struct, IFloatingPoint<T> {
|
||||
where T : struct, IFloatingPointIeee754<T> {
|
||||
if (T.TryParse(curr_text, null, out var from_text)) {
|
||||
if (!from_text.Equals(new_value)) {
|
||||
return format(new_value, settings);
|
||||
@@ -25,7 +26,7 @@ namespace mbts.ui.controls {
|
||||
}
|
||||
|
||||
public static string format<T>(T? value, TickDisplaySettingsImmutable? settings = null)
|
||||
where T : struct, IFloatingPoint<T> {
|
||||
where T : struct, IFloatingPointIeee754<T> {
|
||||
if (!value.HasValue) {
|
||||
return string.Empty;
|
||||
}
|
||||
@@ -39,7 +40,7 @@ namespace mbts.ui.controls {
|
||||
string? text,
|
||||
[NotNullWhen(true)] out T? result,
|
||||
TickDisplaySettingsImmutable? settings = null
|
||||
) where T : IFloatingPoint<T> {
|
||||
) where T : IFloatingPointIeee754<T> {
|
||||
if (text is null) {
|
||||
result = default;
|
||||
return false;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
using Spark.Core.Disposables;
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Spark.Core.Disposables;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace mbts.ui {
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace mbts {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
|
||||
public static class TickExtensions {
|
||||
static string _nan_text => TickDisplaySettings.Default.nan_text;
|
||||
@@ -109,20 +110,20 @@ namespace mbts {
|
||||
public static string format_without_decimal_part(this TickFactors tick, double value) =>
|
||||
format(tick, value, double.NaN, false, _nan_text, true);
|
||||
|
||||
public static string format<T>(this TickFactors tick, T value) where T : IFloatingPoint<T> =>
|
||||
public static string format<T>(this TickFactors tick, T value) where T : IFloatingPointIeee754<T> =>
|
||||
format(tick, value, T.NaN, false, _nan_text);
|
||||
|
||||
public static string format<T>(this TickFactors tick, T value, bool show_commas)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
format(tick, value, T.NaN, show_commas, _nan_text);
|
||||
|
||||
public static string format<T>(this TickDisplaySettings settings, T value)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
format(settings.tick_factors, value, settings);
|
||||
|
||||
public static string format<T>(
|
||||
this bts.api.domain.TickDisplaySettingsImmutable settings, T value)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
settings.to_tick_display_settings().format(value);
|
||||
|
||||
public static string format<T>(this TickFactors tick, T value, TickDisplaySettings settings)
|
||||
@@ -149,7 +150,7 @@ namespace mbts {
|
||||
bool show_commas,
|
||||
string nan_text,
|
||||
bool show_decimal_part = true)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tick.format(
|
||||
value,
|
||||
TickDisplaySettings.Default.with(
|
||||
@@ -196,7 +197,7 @@ namespace mbts {
|
||||
parse(display_settings.tick_factors, text, display_settings);
|
||||
|
||||
public static T parse<T>(this TickDisplaySettings display_settings, string text)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
parse<T>(display_settings.tick_factors, text, display_settings);
|
||||
#nullable disable
|
||||
|
||||
@@ -204,7 +205,7 @@ namespace mbts {
|
||||
parse<double>(tick, text, display_settings);
|
||||
|
||||
public static T parse<T>(this TickFactors tick, string text, TickDisplaySettings display_settings)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : IFloatingPointIeee754<T> {
|
||||
if (display_settings is null) {
|
||||
return parse(tick, text, T.NaN, _nan_text);
|
||||
}
|
||||
@@ -213,7 +214,9 @@ namespace mbts {
|
||||
return parse(tick, text, display_multiplier, nan_text);
|
||||
}
|
||||
|
||||
public static T parse<T>(this TickFactors tick, string text, T display_multiplier, string nan_text) where T : IFloatingPoint<T> =>
|
||||
public static T parse<T>(
|
||||
this TickFactors tick, string text, T display_multiplier, string nan_text)
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tick?.is_valid() ?? false ?
|
||||
_parse(tick, text, display_multiplier, nan_text) :
|
||||
_parse_no_tick(text, display_multiplier, nan_text);
|
||||
@@ -223,37 +226,37 @@ namespace mbts {
|
||||
string text,
|
||||
T display_multiplier,
|
||||
string nan_text
|
||||
) where T : IFloatingPoint<T> =>
|
||||
) where T : IFloatingPointIeee754<T> =>
|
||||
regional_tick.is_valid() ?
|
||||
_parse(regional_tick, text, display_multiplier, nan_text) :
|
||||
_parse_no_tick(text, display_multiplier, nan_text);
|
||||
|
||||
public static T tick<T>(this TickFactors tick, T value, int count)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
count < 0 ? tick.tickdown(value, (uint)-count) : tick.tickup(value, (uint)count);
|
||||
|
||||
public static T tick<T>(this bts.api.domain.TickFactorsImmutable tick, T value, int count)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tick.to_tick_factors().tick(value, count);
|
||||
|
||||
public static T tick<T>(
|
||||
this bts.api.domain.TickDisplaySettingsImmutable settings, T value, int count)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
settings.HasTickFactors ?
|
||||
settings.TickFactors.tick(value, count) :
|
||||
throw new ArgumentException(
|
||||
"Can't tick because 'settings.HasTickFactors' is false", nameof(settings));
|
||||
|
||||
public static T tickup<T>(this TickFactors tick, T input, uint count = 1)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tickup(tick, input, count, TickUtils.precision_const<T>());
|
||||
|
||||
public static T tickup<T>(this TickFactors tick, T input, uint count, T precision)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tickup<T, NumericCastOutConverter<T>>(tick, input, count, precision);
|
||||
|
||||
public static T tickup<T, TFromUInt32>(this TickFactors tick, T input, uint count, T precision)
|
||||
where T : IFloatingPoint<T>
|
||||
where T : IFloatingPointIeee754<T>
|
||||
where TFromUInt32 : IConverter<uint, T> {
|
||||
if (!precision.is_real_positive()) {
|
||||
throw new ArgumentException("Must be a real positive number.", nameof(precision));
|
||||
@@ -262,7 +265,7 @@ namespace mbts {
|
||||
return input;
|
||||
}
|
||||
var tuf = tick.tick_unit_frac<T>();
|
||||
var ieeer = T.IEEERemainder(input, tuf);
|
||||
var ieeer = T.Ieee754Remainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer < -precision) {
|
||||
count--;
|
||||
@@ -271,15 +274,18 @@ namespace mbts {
|
||||
return _round_tick(tuf, result);
|
||||
}
|
||||
|
||||
public static T tickup<T>(this RegionalTickFactors regional_tick, T input) where T : IFloatingPoint<T> =>
|
||||
public static T tickup<T>(
|
||||
this RegionalTickFactors regional_tick, T input) where T : IFloatingPointIeee754<T> =>
|
||||
regional_tick.tickup(input, 1);
|
||||
|
||||
public static T tickup<T>(this RegionalTickFactors regional_tick, T input, uint count) where T : IFloatingPoint<T> =>
|
||||
public static T tickup<T>(
|
||||
this RegionalTickFactors regional_tick, T input, uint count)
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
regional_tick.tickup(input, count, TickUtils.precision_const<T>());
|
||||
|
||||
public static T tickup<T>(
|
||||
this RegionalTickFactors regional_tick, T input, uint count, T precision)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : IFloatingPointIeee754<T> {
|
||||
if (!precision.is_real_positive()) {
|
||||
throw new ArgumentException("Must be a real positive number.", nameof(precision));
|
||||
}
|
||||
@@ -292,7 +298,7 @@ namespace mbts {
|
||||
T ltie = regional_tick.low_tick_inclusive_end.as_type<double, T>();
|
||||
if (input < ltie) {
|
||||
tuf = regional_tick.low_tick.tick_unit_frac<T>();
|
||||
var ieeer = T.IEEERemainder(input, tuf);
|
||||
var ieeer = T.Ieee754Remainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer < -precision) count--;
|
||||
val = input + tuf * count.as_type<uint, T>();
|
||||
@@ -303,7 +309,7 @@ namespace mbts {
|
||||
}
|
||||
} else {
|
||||
tuf = regional_tick.high_tick.tick_unit_frac<T>();
|
||||
var ieeer = T.IEEERemainder(input, tuf);
|
||||
var ieeer = T.Ieee754Remainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer < -precision) count--;
|
||||
val = input + tuf * count.as_type<uint, T>();
|
||||
@@ -312,21 +318,21 @@ namespace mbts {
|
||||
}
|
||||
|
||||
public static T tickdown<T>(this TickFactors tick, T input, uint count = 1)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tickdown(tick, input, count, TickUtils.precision_const<T>());
|
||||
|
||||
public static T tickdown<T>(this TickFactors tick, T input, uint count, T precision)
|
||||
where T : IFloatingPoint<T> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tickdown<T, NumericCastOutConverter<T>>(tick, input, count, precision);
|
||||
|
||||
public static T tickdown<T, TFromUInt32>(this TickFactors tick, T input, uint count, T precision)
|
||||
where T : IFloatingPoint<T>
|
||||
where T : IFloatingPointIeee754<T>
|
||||
where TFromUInt32 : IConverter<uint, T> {
|
||||
if (!input.is_real()) {
|
||||
return input;
|
||||
}
|
||||
var tuf = tick.tick_unit_frac<T>();
|
||||
var ieeer = T.IEEERemainder(input, tuf);
|
||||
var ieeer = T.Ieee754Remainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer > precision) {
|
||||
count--;
|
||||
@@ -336,21 +342,22 @@ namespace mbts {
|
||||
}
|
||||
|
||||
public static T tickdown<T>(this RegionalTickFactors regional_tick, T input)
|
||||
where T : IFloatingPoint<T>, IComparisonOperators<T, double> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
regional_tick.tickdown(input, 1);
|
||||
|
||||
public static T tickdown<T>(this RegionalTickFactors regional_tick, T input, uint count)
|
||||
where T : IFloatingPoint<T>, IComparisonOperators<T, double> =>
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tickdown(regional_tick, input, count, TickUtils.precision_const<T>());
|
||||
|
||||
public static T tickdown<T>(
|
||||
this RegionalTickFactors regional_tick, T input, uint count, T precision) where T : IFloatingPoint<T> =>
|
||||
this RegionalTickFactors regional_tick, T input, uint count, T precision)
|
||||
where T : IFloatingPointIeee754<T> =>
|
||||
tickdown<T, NumericCastOutConverter<T>, NumericCastOutConverter<T>, NumericCastInConverter<T>>(
|
||||
regional_tick, input, count, precision);
|
||||
|
||||
public static T tickdown<T, TFromUInt32, TFromDouble, TToUInt16>(
|
||||
this RegionalTickFactors regional_tick, T input, uint count, T precision)
|
||||
where T : IFloatingPoint<T>
|
||||
where T : IFloatingPointIeee754<T>
|
||||
where TFromDouble : IConverter<double, T>
|
||||
where TFromUInt32 : IConverter<uint, T>
|
||||
where TToUInt16 : IConverter<T, uint> {
|
||||
@@ -365,7 +372,7 @@ namespace mbts {
|
||||
T low_tick_inclusive_end = TFromDouble.convert(regional_tick.low_tick_inclusive_end);
|
||||
if (input > low_tick_inclusive_end) {
|
||||
tuf = regional_tick.high_tick.tick_unit_frac<T>();
|
||||
var ieeer = T.IEEERemainder(input, tuf);
|
||||
var ieeer = T.Ieee754Remainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer > precision) count--;
|
||||
val = input - tuf * TFromDouble.convert(count);
|
||||
@@ -377,7 +384,7 @@ namespace mbts {
|
||||
}
|
||||
} else {
|
||||
tuf = regional_tick.low_tick.tick_unit_frac<T>();
|
||||
var ieeer = T.IEEERemainder(input, tuf);
|
||||
var ieeer = T.Ieee754Remainder(input, tuf);
|
||||
input -= ieeer;
|
||||
if (ieeer > precision) count--;
|
||||
val = input - tuf * TFromDouble.convert(count);
|
||||
@@ -483,7 +490,7 @@ namespace mbts {
|
||||
return display_digits(tick.tick_base);
|
||||
}
|
||||
|
||||
public static int display_digits<T>(T tick_base) where T : IFloatingPoint<T> {
|
||||
public static int display_digits<T>(T tick_base) where T : IFloatingPoint<T>, ILogarithmicFunctions<T> {
|
||||
var log_tick_base = T.Log10(tick_base);
|
||||
var floor = T.Floor(log_tick_base);
|
||||
var dec = log_tick_base - floor;
|
||||
@@ -500,14 +507,14 @@ namespace mbts {
|
||||
}
|
||||
|
||||
static string _format_no_tick<T>(T value, T display_multiplier, bool show_commas)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : INumberBase<T> {
|
||||
if (!display_multiplier.is_nan()) {
|
||||
value *= display_multiplier;
|
||||
}
|
||||
return value.ToString(show_commas ? "#,0" : "0", null);
|
||||
}
|
||||
|
||||
static T _parse_no_tick<T>(string text, T display_multiplier, string nan_text) where T : IFloatingPoint<T> {
|
||||
static T _parse_no_tick<T>(string text, T display_multiplier, string nan_text) where T : IFloatingPointIeee754<T> {
|
||||
if (text == nan_text) {
|
||||
return T.NaN;
|
||||
}
|
||||
@@ -515,7 +522,7 @@ namespace mbts {
|
||||
result.safe_divide(display_multiplier) : T.NaN;
|
||||
}
|
||||
|
||||
static T _get_integer_part<T>(string integer_text) where T : IFloatingPoint<T> {
|
||||
static T _get_integer_part<T>(string integer_text) where T : IFloatingPointIeee754<T> {
|
||||
if (integer_text.is_null_or_white_space()) {
|
||||
return T.Zero;
|
||||
}
|
||||
@@ -524,7 +531,7 @@ namespace mbts {
|
||||
result : T.NaN;
|
||||
}
|
||||
|
||||
static T _get_numerator_part<T>(string numerator_text, T tick_base) where T : IFloatingPoint<T> {
|
||||
static T _get_numerator_part<T>(string numerator_text, T tick_base) where T : IFloatingPointIeee754<T> {
|
||||
if (string.IsNullOrEmpty(numerator_text)) {
|
||||
return T.Zero;
|
||||
}
|
||||
@@ -554,7 +561,7 @@ namespace mbts {
|
||||
|
||||
static T _parse<T>(
|
||||
RegionalTickFactors regional_tick, string text, T display_multiplier, string nan_text)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : IFloatingPointIeee754<T> {
|
||||
T result = _parse(regional_tick.low_tick, text, display_multiplier, nan_text);
|
||||
|
||||
T ltie = regional_tick.low_tick_inclusive_end.as_type<double, T>()
|
||||
@@ -566,7 +573,7 @@ namespace mbts {
|
||||
}
|
||||
|
||||
static T _parse<T>(TickFactors tick, string text, T display_multiplier, string nan_text)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : IFloatingPointIeee754<T> {
|
||||
if (text.is_null_or_white_space() || text == nan_text) {
|
||||
return T.NaN;
|
||||
}
|
||||
@@ -584,7 +591,7 @@ namespace mbts {
|
||||
}
|
||||
|
||||
static T _parse<T>(TickFactors tick, T integer_part, string numerator_part_text)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : IFloatingPointIeee754<T> {
|
||||
T tick_base = tick.tick_base.as_type<double, T>();
|
||||
T numerator_part = _get_numerator_part(numerator_part_text, tick_base);
|
||||
return integer_part + numerator_part / tick_base;
|
||||
@@ -657,7 +664,7 @@ namespace mbts {
|
||||
}
|
||||
}
|
||||
|
||||
static T _round_tick<T>(T tick_unit_frac, T input) where T : IFloatingPoint<T> =>
|
||||
input - T.IEEERemainder(input, tick_unit_frac);
|
||||
static T _round_tick<T>(T tick_unit_frac, T input) where T : IFloatingPointIeee754<T> =>
|
||||
input - T.Ieee754Remainder(input, tick_unit_frac);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using Spark.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace mbts.spark {
|
||||
static class TickUtils {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
<Description />
|
||||
@@ -20,7 +20,6 @@
|
||||
<PackageReference Include="Google.Protobuf" Version="3.21.4" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||
<PackageReference Include="System.Runtime.Experimental" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
|
||||
@@ -61,9 +61,6 @@ namespace System.Collections.Generic {
|
||||
public static IDictionary<TKey, TValue> as_idictionary<TKey, TValue>(this Dictionary<TKey, TValue> dictionary) =>
|
||||
dictionary;
|
||||
|
||||
public static IReadOnlyDictionary<TKey, TValue> AsReadOnly<TKey, TValue>(this IDictionary<TKey, TValue> dictionary) =>
|
||||
new ReadOnlyDictionary<TKey, TValue>(dictionary);
|
||||
|
||||
public static void Difference<TKey, TValue>(this IDictionary<TKey, TValue> left,
|
||||
IDictionary<TKey, TValue> right,
|
||||
out IEnumerable<KeyValuePair<TKey, TValue>> exclusive_left,
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace System.Collections.Generic {
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
@@ -15,7 +15,6 @@
|
||||
<PackageReference Include="Google.Protobuf" Version="3.21.4" />
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||
<PackageReference Include="protobuf-net" Version="3.1.17" />
|
||||
<PackageReference Include="System.Runtime.Experimental" Version="6.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace mbts.utils {
|
||||
static class ExceptionAssert {
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace bts.utils {
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
public static class MathUtils {
|
||||
public const double EPSILON = 1E-12;
|
||||
@@ -14,7 +15,7 @@ namespace bts.utils {
|
||||
public static readonly IComparer<double> epsilon_comparer = new ErrorMarginComparer<double>(EPSILON);
|
||||
|
||||
public static T abs_diff<T>(T x, T y)
|
||||
where T : ISubtractionOperators<T, T, T>, IComparisonOperators<T, T> =>
|
||||
where T : ISubtractionOperators<T, T, T>, IComparisonOperators<T, T, bool> =>
|
||||
x > y ? (x - y) : (y - x);
|
||||
|
||||
public static IComparer<double> error_margin_comparer(double error_margin) =>
|
||||
@@ -36,14 +37,14 @@ namespace bts.utils {
|
||||
epsilon_equals(x, y, NormalNumericOps<T>.epsilon);
|
||||
|
||||
public static bool epsilon_equals<T>(T x, T y, T epsilon)
|
||||
where T : ISubtractionOperators<T, T, T>, IComparisonOperators<T, T> =>
|
||||
where T : ISubtractionOperators<T, T, T>, IComparisonOperators<T, T, bool> =>
|
||||
abs_diff(x, y) < epsilon;
|
||||
|
||||
public static bool marginal_equals(double x, double y) =>
|
||||
marginal_equals(x, y, EPSILON);
|
||||
|
||||
public static bool marginal_equals<T>(T x, T y, T margin)
|
||||
where T : ISubtractionOperators<T, T, T>, IComparisonOperators<T, T> =>
|
||||
where T : ISubtractionOperators<T, T, T>, IComparisonOperators<T, T, bool> =>
|
||||
(x > y ? (x - y) : (y - x)) < margin;
|
||||
|
||||
public static bool is_nan<T>(T value) where T : INumber<T> =>
|
||||
@@ -132,7 +133,7 @@ namespace bts.utils {
|
||||
public static T nan_diff<T>(T a, T b) where T : IFloatingPoint<T> =>
|
||||
T.IsNaN(a) ? -b : T.IsNaN(b) ? a : a - b;
|
||||
|
||||
public static bool is_within_range<T>(T value, T min, T max) where T : IComparisonOperators<T, T> =>
|
||||
public static bool is_within_range<T>(T value, T min, T max) where T : IComparisonOperators<T, T, bool> =>
|
||||
value >= min && value <= max;
|
||||
|
||||
public static T weighted_average<T>(T x, T x_weight, T y, T y_weight) where T : IFloatingPoint<T> {
|
||||
@@ -145,7 +146,7 @@ namespace bts.utils {
|
||||
return x + (y - x) * (x_weight / (x_weight + y_weight));
|
||||
}
|
||||
|
||||
public static T within_range<T>(T value, T min, T max) where T : IComparisonOperators<T, T> {
|
||||
public static T within_range<T>(T value, T min, T max) where T : IComparisonOperators<T, T, bool> {
|
||||
if (value < min) {
|
||||
return min;
|
||||
}
|
||||
@@ -156,7 +157,7 @@ namespace bts.utils {
|
||||
}
|
||||
|
||||
public static T within_range<T>(
|
||||
T value, T? min = null, T? max = null) where T : struct, IComparisonOperators<T, T> {
|
||||
T value, T? min = null, T? max = null) where T : struct, IComparisonOperators<T, T, bool> {
|
||||
if (min.HasValue && value < min.Value) {
|
||||
return min.Value;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ namespace Spark.Core {
|
||||
using bts;
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
public class NumericCastConverter :
|
||||
IConverter<int, int>,
|
||||
@@ -213,7 +214,7 @@ namespace Spark.Core {
|
||||
IConverter<T, double>,
|
||||
IConverter<T, float>,
|
||||
IConverter<T, decimal>
|
||||
where T : INumber<T> {
|
||||
where T : INumberBase<T> {
|
||||
|
||||
static readonly Func<T, short> _to_int16;
|
||||
static readonly Func<T, ushort> _to_uint16;
|
||||
@@ -342,7 +343,9 @@ namespace Spark.Core {
|
||||
static decimal IConverter<T, decimal>.convert(T value) => _to_decimal(value);
|
||||
}
|
||||
|
||||
public class NumericCastConverter<TIn, TOut> : IConverter<TIn, TOut> where TIn : INumber<TIn> where TOut : INumber<TOut> {
|
||||
public class NumericCastConverter<TIn, TOut> : IConverter<TIn, TOut>
|
||||
where TIn : INumberBase<TIn>
|
||||
where TOut : INumberBase<TOut> {
|
||||
static readonly Func<TIn, TOut> _convert;
|
||||
|
||||
static NumericCastConverter() {
|
||||
|
||||
@@ -3,44 +3,45 @@ namespace bts.utils {
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
public static class NumericExtensions {
|
||||
public static TOut as_type<TOut>(this short value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this short value) where TOut : INumberBase<TOut> =>
|
||||
as_type<short, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this ushort value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this ushort value) where TOut : INumberBase<TOut> =>
|
||||
as_type<ushort, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this int value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this int value) where TOut : INumberBase<TOut> =>
|
||||
as_type<int, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this uint value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this uint value) where TOut : INumberBase<TOut> =>
|
||||
as_type<uint, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this long value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this long value) where TOut : INumberBase<TOut> =>
|
||||
as_type<long, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this ulong value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this ulong value) where TOut : INumberBase<TOut> =>
|
||||
as_type<ulong, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this float value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this float value) where TOut : INumberBase<TOut> =>
|
||||
as_type<float, TOut>(value);
|
||||
|
||||
public static TOut as_type<TOut>(this double value) where TOut : INumber<TOut> =>
|
||||
public static TOut as_type<TOut>(this double value) where TOut : INumberBase<TOut> =>
|
||||
as_type<double, TOut>(value);
|
||||
|
||||
public static TOut as_type<TIn, TOut>(this TIn value)
|
||||
where TIn : INumber<TIn>
|
||||
where TOut : INumber<TOut> =>
|
||||
where TIn : INumberBase<TIn>
|
||||
where TOut : INumberBase<TOut> =>
|
||||
NumericCastConverter<TIn, TOut>.convert(value);
|
||||
|
||||
public static T abs<T>(this T value) where T : INumber<T> =>
|
||||
public static T abs<T>(this T value) where T : INumberBase<T> =>
|
||||
T.Abs(value);
|
||||
|
||||
public static bool is_nan<T>(this T value) where T : IFloatingPoint<T> =>
|
||||
public static bool is_nan<T>(this T value) where T : INumberBase<T> =>
|
||||
T.IsNaN(value);
|
||||
|
||||
public static T if_nan<T>(this T d, T if_nan) where T : IFloatingPoint<T> =>
|
||||
public static T if_nan<T>(this T d, T if_nan) where T : INumberBase<T> =>
|
||||
d.is_nan() ? if_nan : d;
|
||||
|
||||
public static bool is_int<T>(this T value) where T : IFloatingPoint<T> =>
|
||||
@@ -71,15 +72,15 @@ namespace bts.utils {
|
||||
MathUtils.marginal_equals(x, y, margin);
|
||||
|
||||
public static bool is_within_range<T>(
|
||||
this T value, T min, T max) where T : IComparisonOperators<T, T> =>
|
||||
this T value, T min, T max) where T : IComparisonOperators<T, T, bool> =>
|
||||
MathUtils.is_within_range(value, min, max);
|
||||
|
||||
public static T within_range<T>(
|
||||
this T value, T min, T max) where T : IComparisonOperators<T, T> =>
|
||||
this T value, T min, T max) where T : IComparisonOperators<T, T, bool> =>
|
||||
MathUtils.within_range(value, min, max);
|
||||
|
||||
public static T within_range<T>(
|
||||
this T value, T? min = null, T? max = null) where T : struct, IComparisonOperators<T, T> =>
|
||||
this T value, T? min = null, T? max = null) where T : struct, IComparisonOperators<T, T, bool> =>
|
||||
MathUtils.within_range(value, min, max);
|
||||
|
||||
public static bool is_real<T>(this T value) where T : IFloatingPoint<T> =>
|
||||
@@ -118,7 +119,7 @@ namespace bts.utils {
|
||||
/// If only <paramref name="b"/> is real, returns <paramref name="b"/>.
|
||||
/// If neither term is real, returns NaN.
|
||||
/// </remarks>
|
||||
public static T add_real<T>(this T a, T b) where T : IFloatingPoint<T> =>
|
||||
public static T add_real<T>(this T a, T b) where T : IFloatingPointIeee754<T> =>
|
||||
new[] { a, b }.sum_real(true);
|
||||
|
||||
/// <summary>
|
||||
@@ -129,7 +130,7 @@ namespace bts.utils {
|
||||
/// If only <paramref name="b"/> is real, returns -<paramref name="b"/>
|
||||
/// If neither term is real, returns NaN.
|
||||
/// </remarks>
|
||||
public static T subtract_real<T>(this T a, T b) where T : IFloatingPoint<T> =>
|
||||
public static T subtract_real<T>(this T a, T b) where T : IFloatingPointIeee754<T> =>
|
||||
new[] { a, -b }.sum_real(true);
|
||||
|
||||
/// <summary>
|
||||
@@ -187,7 +188,7 @@ namespace bts.utils {
|
||||
/// contains no real numbers
|
||||
/// </param>
|
||||
public static T sum_real<T>(this IEnumerable<T> values, bool nan_if_none = false)
|
||||
where T : IFloatingPoint<T> {
|
||||
where T : IFloatingPointIeee754<T> {
|
||||
return nan_if_none ? nan_if_none_impl() : normal_impl();
|
||||
|
||||
T normal_impl() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<GeneratePackageOnBuild Condition="$(Configuration) == 'Release' or $(Configuration) == 'Release'">true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>$(OutputPath)\net6.0</PackageOutputPath>
|
||||
<PackageOutputPath>$(OutputPath)\net7.0</PackageOutputPath>
|
||||
<IncludeSource>true</IncludeSource>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
|
||||
@@ -40,19 +40,19 @@
|
||||
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences" Condition=" '$(SparkRoot)' != '' ">
|
||||
<ItemGroup>
|
||||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
||||
<BuildOutputInPackage Include="$(OutputPath)..\net6.0\libspark.dll" />
|
||||
<BuildOutputInPackage Include="$(OutputPath)..\net7.0\libspark.dll" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- deployed sdk build net6.0 -->
|
||||
<ItemGroup Condition=" '$(SparkRoot)' == '' and '$(TargetFramework)' == 'net6.0'">
|
||||
<!-- deployed sdk build net7.0 -->
|
||||
<ItemGroup Condition=" '$(SparkRoot)' == '' and '$(TargetFramework)' == 'net7.0'">
|
||||
<Reference Include="spark_api">
|
||||
<HintPath>..\..\lib\net6.0\spark_api.dll</HintPath>
|
||||
<HintPath>..\..\lib\net7.0\spark_api.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="copy_lib_deployed" AfterTargets="PostBuildEvent" Condition=" '$(SparkRoot)' == '' ">
|
||||
<Copy SourceFiles="..\..\lib\net6.0\libspark.dll" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="..\..\lib\net7.0\libspark.dll" DestinationFolder="$(OutputPath)\" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net7.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win10-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
|
||||
<Authors>Blue Trading Systems</Authors>
|
||||
<Company>Blue Trading Systems</Company>
|
||||
|
||||
@@ -2,44 +2,44 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<BuildRoot>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)))</BuildRoot>
|
||||
<Net60OutputPath>$(BuildRoot)\$(Configuration)\bin\net6.0\</Net60OutputPath>
|
||||
<Net60WinOutputPath>$(BuildRoot)\$(Configuration)\bin\net6.0-windows\</Net60WinOutputPath>
|
||||
<Net70OutputPath>$(BuildRoot)\$(Configuration)\bin\net7.0\</Net70OutputPath>
|
||||
<Net70WinOutputPath>$(BuildRoot)\$(Configuration)\bin\net7.0-windows\</Net70WinOutputPath>
|
||||
<ErrorReport>None</ErrorReport>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target
|
||||
Name="CopyToNet60"
|
||||
Name="CopyToNet70"
|
||||
AfterTargets="Link">
|
||||
<Copy
|
||||
SourceFiles="$(OutDir)libspark.dll"
|
||||
Condition="Exists('$(OutDir)libspark.dll')"
|
||||
DestinationFolder="$(Net60OutputPath)"
|
||||
DestinationFolder="$(Net70OutputPath)"
|
||||
Retries="512"
|
||||
RetryDelayMilliseconds="250"
|
||||
SkipUnchangedFiles="true" />
|
||||
<Copy
|
||||
SourceFiles="$(OutDir)libspark.pdb"
|
||||
Condition="Exists('$(OutDir)libspark.pdb')"
|
||||
DestinationFolder="$(Net60OutputPath)"
|
||||
DestinationFolder="$(Net70OutputPath)"
|
||||
Retries="512"
|
||||
RetryDelayMilliseconds="250"
|
||||
SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="CopyToNet60Win"
|
||||
Name="CopyToNet70Win"
|
||||
AfterTargets="Link">
|
||||
<Copy
|
||||
SourceFiles="$(OutDir)libspark.dll"
|
||||
Condition="Exists('$(OutDir)libspark.dll')"
|
||||
DestinationFolder="$(Net60WinOutputPath)"
|
||||
DestinationFolder="$(Net70WinOutputPath)"
|
||||
Retries="512"
|
||||
RetryDelayMilliseconds="250"
|
||||
SkipUnchangedFiles="true" />
|
||||
<Copy
|
||||
SourceFiles="$(OutDir)libspark.pdb"
|
||||
Condition="Exists('$(OutDir)libspark.pdb')"
|
||||
DestinationFolder="$(Net60WinOutputPath)"
|
||||
DestinationFolder="$(Net70WinOutputPath)"
|
||||
Retries="512"
|
||||
RetryDelayMilliseconds="250"
|
||||
SkipUnchangedFiles="true" />
|
||||
|
||||
Reference in new issue
Block a user