From 08ddfc364c0b89d3eeb699482754b0be8dd6580f Mon Sep 17 00:00:00 2001 From: Grant Birchmeier Date: Wed, 29 May 2024 14:53:57 -0500 Subject: [PATCH] fix warnings/release notes for Weekdays setting addendum to PR #864 on issue #844 --- QuickFIXn/SessionSchedule.cs | 26 +++++++++++++------------- RELEASE_NOTES.md | 2 +- UnitTests/SettingsDictionaryTests.cs | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/QuickFIXn/SessionSchedule.cs b/QuickFIXn/SessionSchedule.cs index 1a0434da7..b869b63b6 100755 --- a/QuickFIXn/SessionSchedule.cs +++ b/QuickFIXn/SessionSchedule.cs @@ -14,7 +14,7 @@ public class SessionSchedule public DayOfWeek? EndDay { get; } private readonly bool _isWeekdaysSession; - private readonly HashSet _weekdays; + private readonly HashSet _weekdays = new(); public bool NonStopSession { get; } @@ -90,7 +90,7 @@ public DateTime NextEndTime(DateTime utc) if (NonStopSession) throw new InvalidOperationException("NonStopSession is set; this statement should be unreachable"); - TimeSpan vEndTime = EndTime ?? throw new QuickFix.ConfigError("EndTime is null"); + TimeSpan vEndTime = EndTime ?? throw new ConfigError("EndTime is null"); if (utc.Kind != DateTimeKind.Utc) throw new ArgumentException("Only UTC time is supported", nameof(utc)); @@ -133,10 +133,10 @@ private bool CheckDay(DateTime dt) if (NonStopSession) throw new InvalidOperationException("NonStopSession is set; this statement should be unreachable"); - DayOfWeek vStartDay = StartDay ?? throw new QuickFix.ConfigError("StartDay is null"); - DayOfWeek vEndDay = EndDay ?? throw new QuickFix.ConfigError("EndDay is null"); - TimeSpan vStartTime = StartTime ?? throw new QuickFix.ConfigError("StartTime is null"); - TimeSpan vEndTime = EndTime ?? throw new QuickFix.ConfigError("EndTime is null"); + DayOfWeek vStartDay = StartDay ?? throw new ConfigError("StartDay is null"); + DayOfWeek vEndDay = EndDay ?? throw new ConfigError("EndDay is null"); + TimeSpan vStartTime = StartTime ?? throw new ConfigError("StartTime is null"); + TimeSpan vEndTime = EndTime ?? throw new ConfigError("EndTime is null"); if (vStartDay < vEndDay) { @@ -177,8 +177,8 @@ private bool CheckTime(TimeSpan time) if (NonStopSession) return true; - TimeSpan vStartTime = StartTime ?? throw new QuickFix.ConfigError("StartTime is null"); - TimeSpan vEndTime = EndTime ?? throw new QuickFix.ConfigError("EndTime is null"); + TimeSpan vStartTime = StartTime ?? throw new ConfigError("StartTime is null"); + TimeSpan vEndTime = EndTime ?? throw new ConfigError("EndTime is null"); if (vStartTime.CompareTo(vEndTime) < 0) { @@ -195,8 +195,8 @@ private bool CheckWeekdays(DateTime dt) if (NonStopSession) throw new InvalidOperationException("NonStopSession is set; this statement should be unreachable"); - TimeSpan vStartTime = StartTime ?? throw new QuickFix.ConfigError("StartTime is null"); - TimeSpan vEndTime = EndTime ?? throw new QuickFix.ConfigError("EndTime is null"); + TimeSpan vStartTime = StartTime ?? throw new ConfigError("StartTime is null"); + TimeSpan vEndTime = EndTime ?? throw new ConfigError("EndTime is null"); TimeSpan tod = dt.TimeOfDay; @@ -216,7 +216,7 @@ private bool CheckWeekdays(DateTime dt) return _weekdays.Contains(targetDay); } - private DayOfWeek PreviousDay(DayOfWeek d) { + private static DayOfWeek PreviousDay(DayOfWeek d) { return d == DayOfWeek.Sunday ? DayOfWeek.Saturday : d - 1; @@ -252,10 +252,10 @@ public SessionSchedule(SettingsDictionary settings) } if (!settings.Has(SessionSettings.START_DAY) && settings.Has(SessionSettings.END_DAY)) - throw new QuickFix.ConfigError("EndDay used without StartDay"); + throw new ConfigError("EndDay used without StartDay"); if (settings.Has(SessionSettings.START_DAY) && !settings.Has(SessionSettings.END_DAY)) - throw new QuickFix.ConfigError("StartDay used without EndDay"); + throw new ConfigError("StartDay used without EndDay"); if (settings.Has(SessionSettings.START_DAY) && settings.Has(SessionSettings.END_DAY)) { diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ba834e8eb..a50aedc02 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -60,7 +60,6 @@ What's New * Also refactor the heck out of DateTimeConverter & tests: many functions renamed/deprecated * #847 - remove setting MillisecondsInTimeStamp (gbirchmeier) * Use TimestampPrecision instead (same as QF/j) -* #844 - implement "Weekdays" setting (MichalUssuri/gbirchmeier) **Non-breaking changes** * #400 - added DDTool, a C#-based codegen, and deleted Ruby-based generator (gbirchmeier) @@ -83,6 +82,7 @@ What's New Programming Model (APM), in order to catch unobserved SocketExceptions (nmandzyk) * Cleanup/nullable-ize SocketInitiatorThread (gbirchmeier) * #839 - change ScreenLog to output FIX messages with "|" instead of non-visible SOH (gbirchmeier) +* #844 - implement "Weekdays" setting (MichalUssuri/gbirchmeier) ### v1.11.2: * same as v1.11.1, but I fixed the readme in the pushed nuget packages diff --git a/UnitTests/SettingsDictionaryTests.cs b/UnitTests/SettingsDictionaryTests.cs index 776e9a57e..00b59c8c9 100755 --- a/UnitTests/SettingsDictionaryTests.cs +++ b/UnitTests/SettingsDictionaryTests.cs @@ -117,7 +117,7 @@ public void TestGetDay() d.SetString("DAY_X", "invalid"); var ex = Assert.Throws(typeof(ArgumentException), delegate { d.GetDay("DAY_X"); }); - StringAssert.Contains("Cannot recognize this day: 'invalid'", ex.Message); + StringAssert.Contains("Cannot recognize this day: 'invalid'", ex!.Message); } [Test] @@ -130,7 +130,7 @@ public void TestSetDay() { Assert.That(d.GetString("DAY4"), Is.EqualTo("Thursday")); var ex = Assert.Throws(typeof(ArgumentException), delegate { d.SetDay("X", (DayOfWeek)9); }); - StringAssert.Contains("Not a valid DayOfWeek value", ex.Message); + StringAssert.Contains("Not a valid DayOfWeek value", ex!.Message); } [Test]