Skip to content

Commit

Permalink
updated third party nugets
Browse files Browse the repository at this point in the history
udapted to .net 9
updated version to 0.9.0-beta.1
  • Loading branch information
Jani Giannoudis committed Feb 12, 2025
1 parent 0ab174f commit 47ec32a
Show file tree
Hide file tree
Showing 40 changed files with 144 additions and 140 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Build
run: dotnet build -c Release
- name: Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Client.Scripting/Cache/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected List<DateTime> GetConsolidatedPeriodStarts(PayrunFunction function, Co
// test for valid cycle setup
if (function.CycleStart != CycleStartDate)
{
throw new ScriptException($"Mismatching cache cycle dates: {function.CycleStart} vs {CycleStartDate}");
throw new ScriptException($"Mismatching cache cycle dates: {function.CycleStart} vs {CycleStartDate}.");
}

// forecast
Expand Down
2 changes: 1 addition & 1 deletion Client.Scripting/CasePayrollValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public PeriodCasePayrollValueDictionary GetCaseValue(string caseFieldName)
var periodValue = periodValues.Value[caseFieldName];
if (periodValue == null)
{
throw new ScriptException($"Unknown case field {caseFieldName}");
throw new ScriptException($"Unknown case field {caseFieldName}.");
}
values.Add(periodValues.Key, periodValue);
}
Expand Down
1 change: 1 addition & 0 deletions Client.Scripting/CaseValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public bool Equals(CaseValue compare)
Value == compare.Value &&
CancellationDate == compare.CancellationDate &&
(Tags?.SequenceEqual(compare.Tags) ?? compare.Tags != null) &&
// ReSharper disable once UsageOfDefaultStructEquality
(Attributes?.SequenceEqual(compare.Attributes) ?? compare.Attributes != null);
}

Expand Down
2 changes: 1 addition & 1 deletion Client.Scripting/ClientScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public TValue this[TKey key]
{
if (SetValueHandler == null)
{
throw new ScriptException($"Write operation on read-only scripting dictionary: {key}={value} ");
throw new ScriptException($"Write operation on read-only scripting dictionary: {key}={value}.");
}
SetValueHandler(key, value);
}
Expand Down
52 changes: 26 additions & 26 deletions Client.Scripting/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public static bool IsNumericType(this Type type)
public static class NullableExtensions
{
/// <summary>Safe nullable boolean cast</summary>
public static bool Safe(this bool? value, bool defaultValue = default) =>
public static bool Safe(this bool? value, bool defaultValue = false) =>
value ?? defaultValue;

/// <summary>Safe nullable int cast</summary>
public static int Safe(this int? value, int defaultValue = default) =>
public static int Safe(this int? value, int defaultValue = 0) =>
value ?? defaultValue;

/// <summary>Safe nullable decimal cast</summary>
public static decimal Safe(this decimal? value, decimal defaultValue = default) =>
public static decimal Safe(this decimal? value, decimal defaultValue = 0) =>
value ?? defaultValue;

/// <summary>Safe nullable DateTime cast</summary>
Expand Down Expand Up @@ -336,13 +336,13 @@ public static Tuple<string, string> ToRelatedCaseNames(this string caseRelation)
{
if (string.IsNullOrWhiteSpace(caseRelation))
{
return default;
return null;
}

var relatedCases = caseRelation.Split(RelatedCaseSeparator, StringSplitOptions.RemoveEmptyEntries);
if (relatedCases.Length != 2)
{
throw new ArgumentException($"invalid case relation {caseRelation}, please use 'sourceCaseName:targetCaseName')");
throw new ArgumentException($"invalid case relation {caseRelation}, please use 'sourceCaseName:targetCaseName').");
}
return new(relatedCases[0], relatedCases[1]);
}
Expand All @@ -355,11 +355,11 @@ public static string ToCaseRelationKey(this string sourceCaseName, string target
{
if (string.IsNullOrWhiteSpace(sourceCaseName))
{
return default;
return null;
}
if (string.IsNullOrWhiteSpace(targetCaseName))
{
return default;
return null;
}

return $"{sourceCaseName}{RelatedCaseSeparator}{targetCaseName}";
Expand Down Expand Up @@ -467,21 +467,21 @@ public static bool IsWithin(this decimal? value, decimal min, decimal max) =>
/// <param name="stepSize">The step size used to truncate</param>
/// <returns>The result of d rounded toward zero, to the nearest whole number within the step size</returns>
public static decimal Truncate(this decimal value, int stepSize) =>
value == default ? default : value - (value % stepSize);
value == 0 ? 0 : value - (value % stepSize);

/// <summary>Rounds a decimal value up</summary>
/// <param name="value">The decimal value to round</param>
/// <param name="stepSize">The round step size</param>
/// <returns>The up-rounded value</returns>
public static decimal RoundUp(this decimal value, decimal stepSize) =>
value == default || stepSize == 0 ? value : Math.Ceiling(value / stepSize) * stepSize;
value == 0 || stepSize == 0 ? value : Math.Ceiling(value / stepSize) * stepSize;

/// <summary>Rounds a decimal value down</summary>
/// <param name="value">The decimal value to round</param>
/// <param name="stepSize">The round step size</param>
/// <returns>The rounded value</returns>
public static decimal RoundDown(this decimal value, decimal stepSize) =>
value == default || stepSize == 0 ? value : Math.Floor(value / stepSize) * stepSize;
value == 0 || stepSize == 0 ? value : Math.Floor(value / stepSize) * stepSize;

/// <summary>Rounds a decimal value wit predefined rounding type</summary>
/// <param name="value">The decimal value to round</param>
Expand Down Expand Up @@ -542,7 +542,7 @@ public static decimal RoundHundredth(this decimal value) =>
/// <param name="divisor">The divisor factor</param>
/// <returns>The rounded value to one-tenth</returns>
public static decimal RoundPartOfOne(this decimal value, int divisor) =>
value == default ? default : Math.Round(value * divisor, MidpointRounding.AwayFromZero) / divisor;
value == 0 ? 0 : Math.Round(value * divisor, MidpointRounding.AwayFromZero) / divisor;
}

/// <summary><see cref="DateTime">DateTime</see> extension methods</summary>
Expand Down Expand Up @@ -645,7 +645,7 @@ public static DateTime ToUtc(this DateTime moment)
// convert to utc
return moment.ToUniversalTime();
default:
throw new ArgumentOutOfRangeException($"Unknown date time kind {moment.Kind}");
throw new ArgumentOutOfRangeException($"Unknown date time kind {moment.Kind}.");
}
}

Expand All @@ -667,7 +667,7 @@ public static DateTime ToUtcTime(this DateTime moment)
// convert to utc
return moment.ToUniversalTime();
default:
throw new ArgumentOutOfRangeException($"Unknown date time kind {moment.Kind}");
throw new ArgumentOutOfRangeException($"Unknown date time kind {moment.Kind}.");
}
}

Expand Down Expand Up @@ -991,7 +991,7 @@ public static int Age(this DateTime birthDate, DateTime testMoment)
{
if (testMoment <= birthDate)
{
throw new ArgumentOutOfRangeException(nameof(testMoment), "calculate age: birth-date must be older than test-date");
throw new ArgumentOutOfRangeException(nameof(testMoment), "calculate age: birth-date must be older than test-date.");
}
var age = testMoment.Year - birthDate.Year;
// leap years
Expand Down Expand Up @@ -1033,7 +1033,7 @@ public static bool IsLastMomentOfDay(this DateTime moment) =>
public static DateTime RoundUp(this DateTime dateTime, TimeSpan stepSize)
{
var modTicks = dateTime.Ticks % stepSize.Ticks;
var delta = modTicks != default ? stepSize.Ticks - modTicks : 0;
var delta = modTicks != 0 ? stepSize.Ticks - modTicks : 0;
return delta != 0 ? new(dateTime.Ticks + delta, dateTime.Kind) : dateTime;
}

Expand All @@ -1044,7 +1044,7 @@ public static DateTime RoundUp(this DateTime dateTime, TimeSpan stepSize)
public static DateTime RoundDown(this DateTime dateTime, TimeSpan stepSize)
{
var delta = dateTime.Ticks % stepSize.Ticks;
return delta != default ? new(dateTime.Ticks - delta, dateTime.Kind) : dateTime;
return delta != 0 ? new(dateTime.Ticks - delta, dateTime.Kind) : dateTime;
}

/// <summary>Rounds a date time to the nearest value</summary>
Expand All @@ -1054,7 +1054,7 @@ public static DateTime RoundDown(this DateTime dateTime, TimeSpan stepSize)
public static DateTime Round(this DateTime dateTime, TimeSpan stepSize)
{
var delta = dateTime.Ticks % stepSize.Ticks;
if (delta == default)
if (delta == 0)
{
return dateTime;
}
Expand Down Expand Up @@ -1193,7 +1193,7 @@ public static class DictionaryExtensions
/// <param name="key">The value key</param>
/// <param name="defaultValue">The default value</param>
/// <returns>The dictionary value</returns>
public static object GetValue(this Dictionary<string, object> dictionary, string key, object defaultValue = default)
public static object GetValue(this Dictionary<string, object> dictionary, string key, object defaultValue = null)
{
if (!dictionary.TryGetValue(key, out var value))
{
Expand Down Expand Up @@ -1238,7 +1238,7 @@ public static class TimeSpanExtensions
public static TimeSpan RoundUp(this TimeSpan timeSpan, TimeSpan stepSize)
{
var modTicks = timeSpan.Ticks % stepSize.Ticks;
var delta = modTicks != default ? stepSize.Ticks - modTicks : 0;
var delta = modTicks != 0 ? stepSize.Ticks - modTicks : 0;
return delta != 0 ? new(timeSpan.Ticks + delta) : timeSpan;
}

Expand All @@ -1249,7 +1249,7 @@ public static TimeSpan RoundUp(this TimeSpan timeSpan, TimeSpan stepSize)
public static TimeSpan RoundDown(this TimeSpan timeSpan, TimeSpan stepSize)
{
var delta = timeSpan.Ticks % stepSize.Ticks;
return delta != default ? new(timeSpan.Ticks - delta) : timeSpan;
return delta != 0 ? new(timeSpan.Ticks - delta) : timeSpan;
}

/// <summary>Rounds a time interval to the nearest value</summary>
Expand All @@ -1259,7 +1259,7 @@ public static TimeSpan RoundDown(this TimeSpan timeSpan, TimeSpan stepSize)
public static TimeSpan Round(this TimeSpan timeSpan, TimeSpan stepSize)
{
var delta = timeSpan.Ticks % stepSize.Ticks;
if (delta == default)
if (delta == 0)
{
return timeSpan;
}
Expand Down Expand Up @@ -2137,7 +2137,7 @@ public static Type GetDataType(this ValueType valueType)
{
return typeof(DBNull);
}
throw new ScriptException($"Unknown value type {valueType}");
throw new ScriptException($"Unknown value type {valueType}.");
}

/// <summary>Get the value type</summary>
Expand Down Expand Up @@ -2181,15 +2181,15 @@ public static object JsonToValue(this ValueType valueType, string json)

if (valueType.IsInteger())
{
return string.IsNullOrWhiteSpace(json) ? default : JsonSerializer.Deserialize<int>(json);
return string.IsNullOrWhiteSpace(json) ? 0 : JsonSerializer.Deserialize<int>(json);
}
if (valueType.IsDecimal())
{
return string.IsNullOrWhiteSpace(json) ? default : JsonSerializer.Deserialize<decimal>(json);
return string.IsNullOrWhiteSpace(json) ? 0 : JsonSerializer.Deserialize<decimal>(json);
}
if (valueType.IsString())
{
return string.IsNullOrWhiteSpace(json) ? default :
return string.IsNullOrWhiteSpace(json) ? null :
json.StartsWith('"') ? JsonSerializer.Deserialize<string>(json) : json;
}
if (valueType.IsDateTime())
Expand All @@ -2207,7 +2207,7 @@ public static object JsonToValue(this ValueType valueType, string json)
{
return null;
}
throw new ScriptException($"unknown value type {valueType}");
throw new ScriptException($"unknown value type {valueType}.");
}
}

Expand Down
22 changes: 11 additions & 11 deletions Client.Scripting/Function/CaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ protected void RegisterFunction(string name, ActionValueType valueType, Func<TVa
{
if (valueFunctions.ContainsKey(name))
{
throw new ScriptException($"Duplicated action value function: {name}");
throw new ScriptException($"Duplicated action value function: {name}.");
}
valueFunctions.Add(name, new(valueType, evaluate));
}
Expand All @@ -428,7 +428,7 @@ private Tuple<ActionValueType, Func<TValue, object>> GetValueFunction()
{
if (!valueFunctions.TryGetValue(Name, out var function))
{
throw new ScriptException($"Missing action function {Name}");
throw new ScriptException($"Missing action function {Name}.");
}
return function;
}
Expand Down Expand Up @@ -516,7 +516,7 @@ protected bool TryGetParameter<T>(int index, out T result)
case ActionValueSource.ValueAttribute:
case ActionValueSource.Lookup:
case ActionValueSource.RangeLookup:
throw new ScriptException("No parameter support for case value attributes");
throw new ScriptException("No parameter support for case value attributes.");
}

if (value == null)
Expand Down Expand Up @@ -2264,18 +2264,18 @@ public ActionValueType GetValueType()
case ActionValueSource.ValueAttribute:
if (!AttributeType.HasValue)
{
throw new ScriptException("Missing case field or value attribute");
throw new ScriptException("Missing case field or value attribute.");
}
return AttributeType.Value;
case ActionValueSource.Lookup:
case ActionValueSource.RangeLookup:
if (!LookupType.HasValue)
{
throw new ScriptException("Missing lookup value attribute");
throw new ScriptException("Missing lookup value attribute.");
}
return LookupType.Value;
default:
throw new ScriptException($"Unsupported value type {ValueSource}");
throw new ScriptException($"Unsupported value type {ValueSource}.");
}
}

Expand Down Expand Up @@ -2304,7 +2304,7 @@ private TValue GetResolvedValue()
{
case ActionValueReferenceType.CaseChange:
case ActionValueReferenceType.CaseValue:
value = CaseValue?.Value != null ? CaseValue.Value.Value : default;
value = CaseValue?.Value != null ? CaseValue.Value.Value : null;
break;
default:
value = SourceValue;
Expand All @@ -2319,7 +2319,7 @@ private TValue GetResolvedValue()
value = CaseValue?.Start;
break;
default:
throw new ScriptException("Start mode not allowed");
throw new ScriptException("Start mode not allowed.");
}
break;
case ActionValueSource.End:
Expand All @@ -2330,7 +2330,7 @@ private TValue GetResolvedValue()
value = CaseValue?.End;
break;
default:
throw new ScriptException("End mode not allowed");
throw new ScriptException("End mode not allowed.");
}
break;
case ActionValueSource.Period:
Expand All @@ -2344,7 +2344,7 @@ private TValue GetResolvedValue()
}
break;
default:
throw new ScriptException("End mode not allowed");
throw new ScriptException("End mode not allowed.");
}
break;
case ActionValueSource.FieldAttribute:
Expand Down Expand Up @@ -2742,7 +2742,7 @@ protected CaseActionsBase()
var attribute = GetType().GetCustomAttribute<ActionProviderAttribute>();
if (attribute == null)
{
throw new ScriptException($"Missing action provider attribute on type {GetType()}");
throw new ScriptException($"Missing action provider attribute on type {GetType()}.");
}
Namespace = attribute.Namespace;
}
Expand Down
8 changes: 4 additions & 4 deletions Client.Scripting/Function/CaseAvailableFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected static CaseAvailableActionValue<TValue> GetSourceActionValue<TValue>(C
{
if (string.IsNullOrWhiteSpace(source))
{
throw new ArgumentException("Invalid case available source", nameof(source));
throw new ArgumentException("Invalid case available source.", nameof(source));
}

try
Expand All @@ -63,7 +63,7 @@ protected static CaseAvailableActionValue<TValue> GetSourceActionValue<TValue>(C
catch (Exception exception)
{
context.Function.LogError($"Invalid case field name {source}: {exception.GetBaseException().Message}");
return default;
return null;
}
}

Expand All @@ -83,7 +83,7 @@ protected static CaseAvailableActionValue<TValue> GetActionValue<TValue>(CaseAva
catch (Exception exception)
{
context.Function.LogError($"Invalid case action value {value}: {exception.GetBaseException().Message}");
return default;
return null;
}
}

Expand Down Expand Up @@ -147,7 +147,7 @@ public string[] GetAvailableActions() =>
// ReSharper restore EmptyRegion

// compiler will optimize this out if the code provides a return
return default;
return null;
}

private bool InvokeAvailableActions()
Expand Down
Loading

0 comments on commit 47ec32a

Please sign in to comment.