From 3b5b711df6c26f4d406424d67857f94782d6db6d Mon Sep 17 00:00:00 2001 From: Gary Hughes Date: Mon, 30 Dec 2024 15:29:43 +1100 Subject: [PATCH 1/3] .NET 9 --- Directory.Build.props | 4 +- Fix.Common.Tests/Fix.Common.Tests.csproj | 8 +- Fix.Common/IOrderedDictionary.cs | 12 - Fix.Common/OrderedDictionary.cs | 383 ------------------ .../Fix.Dictionary.Tests.csproj | 8 +- Fix.Dictionary/MessageFieldCollection.cs | 4 +- Fix.Dictionary/VersionField.cs | 2 +- Fix.Tests/Fix.Tests.csproj | 8 +- Fix.Tests/OrderBookTests.cs | 2 +- Fix/Fix.csproj | 2 +- FixClient.Tests/FixClient.Tests.csproj | 10 +- FixClient/CheckGroupBox/CheckGroupBox.cs | 1 + FixClient/ConnectForm.cs | 2 + FixClient/Customise/CustomFieldForm.cs | 1 + FixClient/Customise/CustomPropertyGrid.cs | 18 +- FixClient/Customise/CustomisePanel.cs | 2 + .../DataGridViewIndentCell.cs | 6 +- .../DataGridViewIndentColumn.cs | 3 + .../DataGridViewImageColumnHeaderCell.cs | 48 +-- FixClient/DictionaryPanel.cs | 2 + FixClient/EditableMessageFieldDataGridView.cs | 2 + FixClient/Filters/FiltersPanel.cs | 2 + FixClient/FixClient.csproj | 2 +- FixClient/GeneratorPanel.cs | 2 + FixClient/GoaEditor.cs | 3 + FixClient/History/HistoryPanel.cs | 1 + FixClient/InspectorPanel.cs | 2 + FixClient/Log/LogPanel.cs | 2 + FixClient/MainForm.cs | 2 + FixClient/MessageOptionsPanel.cs | 1 + FixClient/MessagesPanel.cs | 2 + FixClient/Orders/OrderDataGridView.cs | 2 + FixClient/Orders/OrdersPanel.cs | 2 + FixClient/PasteMessageForm.cs | 5 + FixClient/SearchTextBox/CueTextBox.cs | 2 + FixClient/Session.cs | 4 +- FixClient/SessionForm.cs | 4 + FixClient/ToolStripCheckBox.cs | 3 + 38 files changed, 106 insertions(+), 463 deletions(-) delete mode 100644 Fix.Common/IOrderedDictionary.cs delete mode 100644 Fix.Common/OrderedDictionary.cs diff --git a/Directory.Build.props b/Directory.Build.props index 2092e45..00cd9a7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - net7.0 + net9.0 enable latest 5.2.0 @@ -9,7 +9,7 @@ https://github.com/GaryHughes/FixClient https://github.com/GaryHughes/FixClient Apache-2.0 - win10-x64 + win-x64 True true diff --git a/Fix.Common.Tests/Fix.Common.Tests.csproj b/Fix.Common.Tests/Fix.Common.Tests.csproj index 3bd38eb..6e0f828 100644 --- a/Fix.Common.Tests/Fix.Common.Tests.csproj +++ b/Fix.Common.Tests/Fix.Common.Tests.csproj @@ -5,10 +5,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Fix.Common/IOrderedDictionary.cs b/Fix.Common/IOrderedDictionary.cs deleted file mode 100644 index d357d90..0000000 --- a/Fix.Common/IOrderedDictionary.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using System.Collections.Specialized; - -namespace Fix.Common; - -public interface IOrderedDictionary : IOrderedDictionary, IDictionary -{ - new int Add(TKey key, TValue value); - void Insert(int index, TKey key, TValue value); - new TValue this[int index] { get; set; } -} - diff --git a/Fix.Common/OrderedDictionary.cs b/Fix.Common/OrderedDictionary.cs deleted file mode 100644 index 15daf23..0000000 --- a/Fix.Common/OrderedDictionary.cs +++ /dev/null @@ -1,383 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics.CodeAnalysis; -using System.Linq; - -namespace Fix.Common; - -public sealed class OrderedDictionary : IOrderedDictionary where TKey : IEquatable -{ - const int DefaultInitialCapacity = 0; - - static readonly string? KeyTypeName = typeof(TKey).FullName; - - Dictionary? _dictionary; - List>? _list; - readonly IEqualityComparer? _comparer; - object? _syncRoot; - readonly int _initialCapacity; - - public OrderedDictionary() - : this(DefaultInitialCapacity, null) - { - } - - public OrderedDictionary(int capacity) - : this(capacity, null) - { - } - - public OrderedDictionary(IEqualityComparer comparer) - : this(DefaultInitialCapacity, comparer) - { - } - - public OrderedDictionary(int capacity, IEqualityComparer? comparer) - { - if (0 > capacity) - { - throw new ArgumentOutOfRangeException(nameof(capacity), $"'{nameof(capacity)}' must be non-negative"); - } - _initialCapacity = capacity; - _comparer = comparer; - } - - static TKey ConvertToKeyType(object key) - { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (key is TKey k) - { - return k; - } - - throw new ArgumentException($"'{nameof(key)}' must be of type " + KeyTypeName, nameof(key)); - } - - Dictionary Dictionary - { - get - { - if (_dictionary == null) - { - _dictionary = new Dictionary(_initialCapacity, _comparer); - } - return _dictionary; - } - } - - List> List - { - get - { - if (_list == null) - { - _list = new List>(_initialCapacity); - } - return _list; - } - } - - IDictionaryEnumerator IOrderedDictionary.GetEnumerator() - { - return Dictionary.GetEnumerator(); - } - - IDictionaryEnumerator IDictionary.GetEnumerator() - { - return Dictionary.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return List.GetEnumerator(); - } - - IEnumerator> IEnumerable>.GetEnumerator() - { - return List.GetEnumerator(); - } - - public void Insert(int index, TKey key, TValue value) - { - if (index > Count || index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - Dictionary.Add(key, value); - List.Insert(index, new KeyValuePair(key, value)); - } - - void IOrderedDictionary.Insert(int index, object key, object? value) - { - throw new NotImplementedException(); - } - - public void RemoveAt(int index) - { - if (index >= Count || index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index), $"'{nameof(index)}' must be non-negative and less than the size of the collection"); - } - - TKey key = List[index].Key; - - List.RemoveAt(index); - Dictionary.Remove(key); - } - - public void ReplaceKey(TKey existing, TKey replacement) - { - if (Dictionary.ContainsKey(replacement)) - { - throw new ArgumentException($"replacement key {replacement} is already in use", nameof(replacement)); - } - - if (!Dictionary.TryGetValue(existing, out var value)) - { - throw new ArgumentException($"existing key {existing} can not be found", nameof(existing)); - } - - Dictionary.Remove(existing); - Dictionary.Add(replacement, value); - } - - public TValue this[int index] - { - get { return List[index].Value; } - set - { - - if (index >= Count || index < 0) - { - throw new ArgumentOutOfRangeException(nameof(index), $"'{nameof(index)}' must be non-negative and less than the size of the collection"); - } - - TKey key = List[index].Key; - - List[index] = new KeyValuePair(key, value); - Dictionary[key] = value; - } - } - - public TValue ItemAtIndex(int index) - { - return List[index].Value; - } - - object? IOrderedDictionary.this[int index] - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - void IDictionary.Add(TKey key, TValue value) - { - Add(key, value); - } - - public int Add(TKey key, TValue value) - { - Dictionary.Add(key, value); - List.Add(new KeyValuePair(key, value)); - return Count - 1; - } - - void IDictionary.Add(object key, object? value) - { - throw new NotImplementedException(); - } - - public void Clear() - { - Dictionary.Clear(); - List.Clear(); - } - - public bool ContainsKey(TKey key) - { - return Dictionary.ContainsKey(key); - } - - bool IDictionary.Contains(object key) - { - return ContainsKey(ConvertToKeyType(key)); - } - - bool IDictionary.IsFixedSize - { - get { return false; } - } - - public bool IsReadOnly - { - get { return false; } - } - - ICollection IDictionary.Keys - { - get { return (ICollection)Keys; } - } - - public int IndexOfKey(TKey key) - { - if (null == key) - { - throw new ArgumentNullException(nameof(key)); - } - - for (int index = 0; index < List.Count; index++) - { - var entry = List[index]; - var next = entry.Key; - if (null != _comparer) - { - if (_comparer.Equals(next, key)) - { - return index; - } - } - else if (key.Equals(next)) - { - return index; - } - } - - return -1; - } - - public bool Remove(TKey key) - { - int index = IndexOfKey(key); - - if (index >= 0) - { - if (Dictionary.Remove(key)) - { - List.RemoveAt(index); - return true; - } - } - - return false; - } - - void IDictionary.Remove(object key) - { - Remove(ConvertToKeyType(key)); - } - - ICollection IDictionary.Values - { - get { return (ICollection)Values; } - } - - public TValue this[TKey key] - { - get { return Dictionary[key]; } - set - { - if (Dictionary.ContainsKey(key)) - { - Dictionary[key] = value; - List[IndexOfKey(key)] = new KeyValuePair(key, value); - } - else - { - Add(key, value); - } - } - } - - object? IDictionary.this[object key] - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - void ICollection.CopyTo(Array array, int index) - { - ((ICollection)List).CopyTo(array, index); - } - - public int Count - { - get { return List.Count; } - } - - bool ICollection.IsSynchronized - { - get { return false; } - } - - object ICollection.SyncRoot - { - get - { - if (_syncRoot == null) - { - System.Threading.Interlocked.CompareExchange(ref _syncRoot, new object(), null); - } - return _syncRoot; - } - } - - public IEnumerable OrderedValues - { - get - { - if (_list is null) - { - throw new Exception("_list is null"); - } - return _list.Select(item => item.Value); - } - } - - public ICollection Keys - { - get { return Dictionary.Keys; } - } - - public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) - { - if (Dictionary.TryGetValue(key, out var innerValue)) - { - value = innerValue; - return true; - } - value = default; - return false; - } - - public ICollection Values - { - get { return Dictionary.Values; } - } - - void ICollection>.Add(KeyValuePair item) - { - Add(item.Key, item.Value); - } - - bool ICollection>.Contains(KeyValuePair item) - { - return ((ICollection>)Dictionary).Contains(item); - } - - void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) - { - ((ICollection>)Dictionary).CopyTo(array, arrayIndex); - } - - bool ICollection>.Remove(KeyValuePair item) - { - return Remove(item.Key); - } -} - diff --git a/Fix.Dictionary.Tests/Fix.Dictionary.Tests.csproj b/Fix.Dictionary.Tests/Fix.Dictionary.Tests.csproj index a3699b3..e409db2 100644 --- a/Fix.Dictionary.Tests/Fix.Dictionary.Tests.csproj +++ b/Fix.Dictionary.Tests/Fix.Dictionary.Tests.csproj @@ -5,10 +5,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Fix.Dictionary/MessageFieldCollection.cs b/Fix.Dictionary/MessageFieldCollection.cs index a299737..9fb2e6c 100644 --- a/Fix.Dictionary/MessageFieldCollection.cs +++ b/Fix.Dictionary/MessageFieldCollection.cs @@ -23,9 +23,9 @@ public bool TryGetValue(int tag, [MaybeNullWhen(false)] out MessageField result) } public int Count => _fields.Count; - public MessageField this[int index] => _fields[index]; + public MessageField this[int index] => _fields.GetAt(index).Value; - public virtual IEnumerator GetEnumerator() => _fields.OrderedValues.GetEnumerator(); + public virtual IEnumerator GetEnumerator() => _fields.Values.GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/Fix.Dictionary/VersionField.cs b/Fix.Dictionary/VersionField.cs index f876ba0..1d93aa0 100644 --- a/Fix.Dictionary/VersionField.cs +++ b/Fix.Dictionary/VersionField.cs @@ -1,4 +1,4 @@ -using Fix.Common; +using System.Collections.Generic; namespace Fix; diff --git a/Fix.Tests/Fix.Tests.csproj b/Fix.Tests/Fix.Tests.csproj index 0a425b1..abc52a1 100644 --- a/Fix.Tests/Fix.Tests.csproj +++ b/Fix.Tests/Fix.Tests.csproj @@ -5,10 +5,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Fix.Tests/OrderBookTests.cs b/Fix.Tests/OrderBookTests.cs index 51a6a48..e37ad16 100644 --- a/Fix.Tests/OrderBookTests.cs +++ b/Fix.Tests/OrderBookTests.cs @@ -386,7 +386,7 @@ public async Task TestQuoteJockeyLog() Assert.AreEqual(25.42m, order.Price); order = book.Orders[1]; Assert.AreEqual(10000, order.OrderQty); - Assert.AreEqual(25.46, order.Price); + Assert.AreEqual(25.46m, order.Price); } break; diff --git a/Fix/Fix.csproj b/Fix/Fix.csproj index 43c6dd0..95cc964 100644 --- a/Fix/Fix.csproj +++ b/Fix/Fix.csproj @@ -6,7 +6,7 @@ - + diff --git a/FixClient.Tests/FixClient.Tests.csproj b/FixClient.Tests/FixClient.Tests.csproj index 71b6246..97b4f90 100644 --- a/FixClient.Tests/FixClient.Tests.csproj +++ b/FixClient.Tests/FixClient.Tests.csproj @@ -1,15 +1,15 @@  - net7.0-windows + net9.0-windows false - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/FixClient/CheckGroupBox/CheckGroupBox.cs b/FixClient/CheckGroupBox/CheckGroupBox.cs index badb2f9..ef9b9fd 100644 --- a/FixClient/CheckGroupBox/CheckGroupBox.cs +++ b/FixClient/CheckGroupBox/CheckGroupBox.cs @@ -61,6 +61,7 @@ public CheckGroupBox() /// /// The text associated with the control. /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public override string Text { get diff --git a/FixClient/ConnectForm.cs b/FixClient/ConnectForm.cs index 05b4847..967860f 100644 --- a/FixClient/ConnectForm.cs +++ b/FixClient/ConnectForm.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.IO; using System.Net; using System.Net.Sockets; @@ -33,6 +34,7 @@ public ConnectForm(IPEndPoint bindEndPoint, IPEndPoint endPoint, Fix.Behaviour b Load += ConnectFormLoad; } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Stream? Stream { get; private set; } void ConnectFormLoad(object? sender, EventArgs e) diff --git a/FixClient/Customise/CustomFieldForm.cs b/FixClient/Customise/CustomFieldForm.cs index 08be621..f52c44f 100644 --- a/FixClient/Customise/CustomFieldForm.cs +++ b/FixClient/Customise/CustomFieldForm.cs @@ -115,6 +115,7 @@ void DeleteEnumButtonClick(object? sender, EventArgs e) { } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public CustomField Field { get diff --git a/FixClient/Customise/CustomPropertyGrid.cs b/FixClient/Customise/CustomPropertyGrid.cs index 4f0bfc4..3a93fb9 100644 --- a/FixClient/Customise/CustomPropertyGrid.cs +++ b/FixClient/Customise/CustomPropertyGrid.cs @@ -10,6 +10,7 @@ // ///////////////////////////////////////////////// using System.Collections; +using System.ComponentModel; namespace FixClient; @@ -25,6 +26,7 @@ public CustomPropertyGrid() Refresh(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool ExpandOnTab { get; set; } /* @@ -62,12 +64,16 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if ((keyData == Keys.Tab) || (keyData == (Keys.Tab | Keys.Shift))) { - GridItem selectedItem = SelectedGridItem; - GridItem root = selectedItem; - while (root.Parent != null) + GridItem? selectedItem = SelectedGridItem; + GridItem? root = selectedItem; + while (root?.Parent != null) { root = root.Parent; } + if (root is null) + { + return base.ProcessCmdKey(ref msg, keyData); + } // Find all expanded items and put them in a list. var items = new ArrayList(); AddExpandedItems(root, items); @@ -90,7 +96,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) SelectedGridItem = item; } - if (ExpandOnTab && (SelectedGridItem.GridItems.Count > 0)) + if (ExpandOnTab && (SelectedGridItem?.GridItems.Count > 0)) { SelectedGridItem.Expanded = false; } @@ -109,7 +115,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) SelectedGridItem = item; } - if (ExpandOnTab && (SelectedGridItem.GridItems.Count > 0)) + if (ExpandOnTab && (SelectedGridItem?.GridItems.Count > 0)) { SelectedGridItem.Expanded = true; } @@ -122,7 +128,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) return base.ProcessCmdKey(ref msg, keyData); } - void AddExpandedItems(GridItem parent, IList items) + static void AddExpandedItems(GridItem parent, IList items) { if (parent.PropertyDescriptor != null) { diff --git a/FixClient/Customise/CustomisePanel.cs b/FixClient/Customise/CustomisePanel.cs index 931671d..6f01251 100644 --- a/FixClient/Customise/CustomisePanel.cs +++ b/FixClient/Customise/CustomisePanel.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Data; using System.Drawing; @@ -431,6 +432,7 @@ void SessionCustomFieldAdded(object? sender, Session.CustomFieldEventArgs ev) } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get diff --git a/FixClient/DataGridViewControls/DataGridViewIndentCell.cs b/FixClient/DataGridViewControls/DataGridViewIndentCell.cs index b24e1f4..2abd34e 100644 --- a/FixClient/DataGridViewControls/DataGridViewIndentCell.cs +++ b/FixClient/DataGridViewControls/DataGridViewIndentCell.cs @@ -18,17 +18,17 @@ public class DataGridViewIndentCell : DataGridViewCell static readonly Brush DefaultBrush = new SolidBrush(LookAndFeel.Color.GridCellBackground); static readonly Brush[] Brushes = - { + [ new SolidBrush(LookAndFeel.Color.GridCellBackground), new SolidBrush(Color.FromArgb(226, 226, 226)), new SolidBrush(Color.FromArgb(204, 204, 204)), new SolidBrush(Color.FromArgb(152, 152, 152)), new SolidBrush(Color.FromArgb(120, 120, 120)), new SolidBrush(Color.Black) - }; + ]; protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, - DataGridViewElementStates cellState, object value, object formattedValue, string errorText, + DataGridViewElementStates cellState, object? value, object? formattedValue, string? errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { diff --git a/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs b/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs index 4bccb14..4cec6b7 100644 --- a/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs +++ b/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs @@ -9,6 +9,8 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; + namespace FixClient; public class DataGridViewIndentColumn : DataGridViewColumn @@ -18,6 +20,7 @@ public DataGridViewIndentColumn() { } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public override DataGridViewCell CellTemplate { get diff --git a/FixClient/DataGridViewImageColumnHeaderCell.cs b/FixClient/DataGridViewImageColumnHeaderCell.cs index 446cf5a..a7f6155 100644 --- a/FixClient/DataGridViewImageColumnHeaderCell.cs +++ b/FixClient/DataGridViewImageColumnHeaderCell.cs @@ -48,10 +48,7 @@ public Icon? Icon set { _icon = value; - if (DataGridView != null) - { - DataGridView.UpdateCellValue(ColumnIndex, -1); - } + DataGridView?.UpdateCellValue(ColumnIndex, -1); } } @@ -96,10 +93,7 @@ public bool ImageBeforeValue if (ImageBeforeValue != value) { _imageBeforeValue = value; - if (DataGridView != null) - { - DataGridView.InvalidateCell(this); - } + DataGridView?.InvalidateCell(this); } } } @@ -145,16 +139,15 @@ public Padding ImagePadding /// /// Custom Clone implementation that copies the cell specific properties. /// - public override object? Clone() + public override object Clone() { - var dataGridViewCell = base.Clone() as DataGridViewImageColumnHeaderCell; - if (dataGridViewCell != null) - { - dataGridViewCell.ImageBeforeValue = ImageBeforeValue; - dataGridViewCell.ImagePadding = ImagePadding; - dataGridViewCell.Image = Image; - dataGridViewCell.Icon = Icon; - } + var dataGridViewCell = base.Clone() as DataGridViewImageColumnHeaderCell ?? throw new NullReferenceException("DataGridViewColumnHeaderCell.Clone() returned a null reference"); + + dataGridViewCell.ImageBeforeValue = ImageBeforeValue; + dataGridViewCell.ImagePadding = ImagePadding; + dataGridViewCell.Image = Image; + dataGridViewCell.Icon = Icon; + return dataGridViewCell; } @@ -194,10 +187,7 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel { if (_image != null || _icon != null) { - if (cellStyle == null) - { - throw new ArgumentNullException(nameof(cellStyle)); - } + ArgumentNullException.ThrowIfNull(cellStyle); cellStyle.Padding = GetAdjustedCellPadding(cellStyle); } @@ -210,10 +200,7 @@ protected override Rectangle GetContentBounds(Graphics graphics, DataGridViewCel /// protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) { - if (rowIndex != -1) - { - throw new ArgumentOutOfRangeException(nameof(rowIndex)); - } + ArgumentOutOfRangeException.ThrowIfNotEqual(rowIndex, -1); if (DataGridView == null) { @@ -264,17 +251,14 @@ protected override void Paint(Graphics graphics, Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, - object value, - object formattedValue, - string errorText, + object? value, + object? formattedValue, + string? errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { - if (cellStyle == null) - { - throw new ArgumentNullException(nameof(cellStyle)); - } + ArgumentNullException.ThrowIfNull(cellStyle); Padding cellStylePadding = cellStyle.Padding; int imageHeight = 0, imageWidth = 0; diff --git a/FixClient/DictionaryPanel.cs b/FixClient/DictionaryPanel.cs index 3ae9ed2..423c3a3 100644 --- a/FixClient/DictionaryPanel.cs +++ b/FixClient/DictionaryPanel.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Drawing; using System.Text; using System.Threading; @@ -61,6 +62,7 @@ public DictionaryPanel() #endregion } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Fix.Message Message { set diff --git a/FixClient/EditableMessageFieldDataGridView.cs b/FixClient/EditableMessageFieldDataGridView.cs index c125bf1..3989545 100644 --- a/FixClient/EditableMessageFieldDataGridView.cs +++ b/FixClient/EditableMessageFieldDataGridView.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Data; using System.Drawing; using static Fix.Dictionary; @@ -34,6 +35,7 @@ public EditableMessageFieldDataGridView() InitializeComponent(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Fix.Message? Message { get; set; } protected override void OnDataError(bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e) diff --git a/FixClient/Filters/FiltersPanel.cs b/FixClient/Filters/FiltersPanel.cs index a201faa..91ed4bf 100644 --- a/FixClient/Filters/FiltersPanel.cs +++ b/FixClient/Filters/FiltersPanel.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Data; using System.Drawing; @@ -441,6 +442,7 @@ void MessageGridSelectionChanged(object? sender, EventArgs e) } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get { return _session; } diff --git a/FixClient/FixClient.csproj b/FixClient/FixClient.csproj index f888be2..daacedf 100644 --- a/FixClient/FixClient.csproj +++ b/FixClient/FixClient.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net9.0-windows true true true diff --git a/FixClient/GeneratorPanel.cs b/FixClient/GeneratorPanel.cs index e463962..e9392bc 100644 --- a/FixClient/GeneratorPanel.cs +++ b/FixClient/GeneratorPanel.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Drawing; namespace FixClient; @@ -130,6 +131,7 @@ public static void UpdateUiState() // UpdateUiState(); //} + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get diff --git a/FixClient/GoaEditor.cs b/FixClient/GoaEditor.cs index ce5c2d7..b8b3d3f 100644 --- a/FixClient/GoaEditor.cs +++ b/FixClient/GoaEditor.cs @@ -9,6 +9,8 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; + namespace FixClient; public partial class GoaEditor : Form @@ -28,6 +30,7 @@ void GoaTextBoxKeyPress(object? sender, KeyPressEventArgs e) } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public string Goa { get diff --git a/FixClient/History/HistoryPanel.cs b/FixClient/History/HistoryPanel.cs index f8e2949..3b4d571 100644 --- a/FixClient/History/HistoryPanel.cs +++ b/FixClient/History/HistoryPanel.cs @@ -627,6 +627,7 @@ void MessageGridSelectionChanged(object? sender, EventArgs e) } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get diff --git a/FixClient/InspectorPanel.cs b/FixClient/InspectorPanel.cs index bfa7b40..f875b19 100644 --- a/FixClient/InspectorPanel.cs +++ b/FixClient/InspectorPanel.cs @@ -203,6 +203,7 @@ public InspectorPanel() Controls.Add(splitterTwo); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Fix.Dictionary.Message? Message { set @@ -213,6 +214,7 @@ public Fix.Dictionary.Message? Message } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Fix.Field? Field { set diff --git a/FixClient/Log/LogPanel.cs b/FixClient/Log/LogPanel.cs index bc050b8..ead5546 100644 --- a/FixClient/Log/LogPanel.cs +++ b/FixClient/Log/LogPanel.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Data; using System.Drawing; @@ -78,6 +79,7 @@ public LogPanel() handle = Handle; } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session Session { set diff --git a/FixClient/MainForm.cs b/FixClient/MainForm.cs index 52af486..ea7e2ae 100644 --- a/FixClient/MainForm.cs +++ b/FixClient/MainForm.cs @@ -10,6 +10,7 @@ // ///////////////////////////////////////////////// using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; using System.IO; using System.Net; @@ -415,6 +416,7 @@ public MainForm() } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public override sealed string Text { get { return base.Text; } diff --git a/FixClient/MessageOptionsPanel.cs b/FixClient/MessageOptionsPanel.cs index be890e5..06c04b5 100644 --- a/FixClient/MessageOptionsPanel.cs +++ b/FixClient/MessageOptionsPanel.cs @@ -149,6 +149,7 @@ void PropertyGridPropertyValueChanged(object? s, PropertyValueChangedEventArgs e _session.Write(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get { return _session; } diff --git a/FixClient/MessagesPanel.cs b/FixClient/MessagesPanel.cs index 42537c8..77f3c2e 100644 --- a/FixClient/MessagesPanel.cs +++ b/FixClient/MessagesPanel.cs @@ -10,6 +10,7 @@ // ///////////////////////////////////////////////// using System.Collections.Generic; +using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; @@ -1219,6 +1220,7 @@ public void UpdateUiState() _fieldSearchTextBox.Enabled = Session != null; } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get diff --git a/FixClient/Orders/OrderDataGridView.cs b/FixClient/Orders/OrderDataGridView.cs index dad0bd2..45a901c 100644 --- a/FixClient/Orders/OrderDataGridView.cs +++ b/FixClient/Orders/OrderDataGridView.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Data; using System.Drawing; using static Fix.Dictionary; @@ -50,6 +51,7 @@ public OrderDataGridView() ReadOnly = true; } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool DisplayExDestination { get; set; } protected override void OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e) diff --git a/FixClient/Orders/OrdersPanel.cs b/FixClient/Orders/OrdersPanel.cs index ea92dcc..e784e0e 100644 --- a/FixClient/Orders/OrdersPanel.cs +++ b/FixClient/Orders/OrdersPanel.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Data; using System.Text; using static Fix.Dictionary; @@ -880,6 +881,7 @@ void UpdateUiState() _reportMenuItem.Enabled = enabled; } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get diff --git a/FixClient/PasteMessageForm.cs b/FixClient/PasteMessageForm.cs index ebf2ae8..309b272 100644 --- a/FixClient/PasteMessageForm.cs +++ b/FixClient/PasteMessageForm.cs @@ -9,6 +9,8 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; + namespace FixClient; public partial class PasteMessageForm : Form @@ -18,18 +20,21 @@ public PasteMessageForm() InitializeComponent(); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool FilterEmptyFields { get { return filterEmptyFieldsCheckBox.Checked; } set { filterEmptyFieldsCheckBox.Checked = value; } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool DefineUnknownAsCustom { get { return defineUnknownAsCustomCheckBox.Checked; } set { defineUnknownAsCustomCheckBox.Checked = value; } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool ResetExistingMessage { get { return resetMessageCheckBox.Checked; } diff --git a/FixClient/SearchTextBox/CueTextBox.cs b/FixClient/SearchTextBox/CueTextBox.cs index 3ea4790..88522f6 100644 --- a/FixClient/SearchTextBox/CueTextBox.cs +++ b/FixClient/SearchTextBox/CueTextBox.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Runtime.InteropServices; namespace FixClient; @@ -26,6 +27,7 @@ static class NativeMethods string? _cue; + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public string? Cue { get diff --git a/FixClient/Session.cs b/FixClient/Session.cs index 32d2d77..d2b8064 100644 --- a/FixClient/Session.cs +++ b/FixClient/Session.cs @@ -757,7 +757,7 @@ public void WriteFilters() { if (_syncContext.InvokeRequired) { - _syncContext.BeginInvoke(new MethodInvoker(() => WriteFilters())); + _syncContext.BeginInvoke(new System.Windows.Forms.MethodInvoker(() => WriteFilters())); return; } @@ -858,7 +858,7 @@ public void WriteTemplates() { if (_syncContext.InvokeRequired) { - _syncContext.BeginInvoke(new MethodInvoker(() => WriteTemplates())); + _syncContext.BeginInvoke(new System.Windows.Forms.MethodInvoker(() => WriteTemplates())); return; } diff --git a/FixClient/SessionForm.cs b/FixClient/SessionForm.cs index f59e4a0..0d51e77 100644 --- a/FixClient/SessionForm.cs +++ b/FixClient/SessionForm.cs @@ -9,6 +9,8 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; + namespace FixClient; partial class SessionForm : Form @@ -34,6 +36,7 @@ public SessionForm() _gridPlaceHolder.Controls.Add(_propertyGrid); } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool Readonly { get { return _propertyGrid.Enabled; } @@ -44,6 +47,7 @@ public bool Readonly } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Session? Session { get { return _session; } diff --git a/FixClient/ToolStripCheckBox.cs b/FixClient/ToolStripCheckBox.cs index b75ae02..d8355f4 100644 --- a/FixClient/ToolStripCheckBox.cs +++ b/FixClient/ToolStripCheckBox.cs @@ -9,6 +9,7 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// +using System.ComponentModel; using System.Drawing; namespace FixClient; @@ -41,12 +42,14 @@ void CheckBoxCheckedChanged(object? sender, EventArgs e) public event EventHandler? CheckChanged; + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool Checked { get { return _checkBox.Checked; } set { _checkBox.Checked = value; } } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public new string Text { get { return _checkBox.Text; } From 0785b0aeae06224f24c91265ce272a64d5df2399 Mon Sep 17 00:00:00 2001 From: Gary Hughes Date: Mon, 30 Dec 2024 16:13:40 +1100 Subject: [PATCH 2/3] Resolve analyser issues. --- Fix.Common.Tests/ReportTests.cs | 5 +-- Fix.Dictionary.Tests/DataTypeTests.cs | 2 +- Fix.Dictionary.Tests/FieldTests.cs | 26 +++++++----- Fix.Dictionary.Tests/MessageTests.cs | 4 +- Fix.Dictionary.Tests/VersionTests.cs | 2 +- Fix.Dictionary/FieldValue.cs | 2 +- Fix.Dictionary/Message.cs | 3 -- Fix.Dictionary/MessageField.cs | 2 +- Fix.Dictionary/MessageFieldCollection.cs | 2 - Fix.Dictionary/Version.cs | 2 +- Fix.Dictionary/VersionCollection.cs | 3 +- Fix.Dictionary/VersionDataTypeCollection.cs | 2 +- Fix.Dictionary/VersionFieldCollection.cs | 9 ++-- Fix.Dictionary/VersionMessageCollection.cs | 2 +- Fix.Tests/OrderBookTests.cs | 7 ++-- Fix.Tests/ParserTests.cs | 11 +++-- Fix.Tests/SessionTestsBase.cs | 2 +- Fix/Parsers/FormattedLogParser.cs | 1 - Fix/Parsers/KlsLogParser.cs | 1 - Fix/Parsers/Parser.cs | 1 - Fix/Session.cs | 9 ++-- .../DataGridViewIndentColumn.cs | 4 +- .../DataGridViewImageColumnHeaderCell.cs | 4 +- FixClient/EditableMessageFieldDataGridView.cs | 7 +++- FixClient/MainForm.cs | 27 ++++++------ FixClient/MessageFieldDataGridView.cs | 2 +- FixClient/MessagesPanel.cs | 42 ++++++------------- FixClient/Parser/ParserPanel.cs | 10 ++--- FixPerformanceTest/Program.cs | 5 +-- .../Program.cs | 9 ++-- 30 files changed, 86 insertions(+), 122 deletions(-) diff --git a/Fix.Common.Tests/ReportTests.cs b/Fix.Common.Tests/ReportTests.cs index 3292d78..c52a7a4 100644 --- a/Fix.Common.Tests/ReportTests.cs +++ b/Fix.Common.Tests/ReportTests.cs @@ -1,7 +1,4 @@ -using System; -using System.ComponentModel; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Fix.Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Fix.Common.Tests; diff --git a/Fix.Dictionary.Tests/DataTypeTests.cs b/Fix.Dictionary.Tests/DataTypeTests.cs index 7313aac..6ce863b 100644 --- a/Fix.Dictionary.Tests/DataTypeTests.cs +++ b/Fix.Dictionary.Tests/DataTypeTests.cs @@ -1,5 +1,5 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; using Fix; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace FixDictionary.Tests; diff --git a/Fix.Dictionary.Tests/FieldTests.cs b/Fix.Dictionary.Tests/FieldTests.cs index 9c2b3ab..507659e 100644 --- a/Fix.Dictionary.Tests/FieldTests.cs +++ b/Fix.Dictionary.Tests/FieldTests.cs @@ -1,7 +1,7 @@ +using Fix; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Fix; namespace FixDictionary.Tests; @@ -19,7 +19,7 @@ public void TestIndexGreaterThanLength() { Assert.IsNull(Dictionary.FIX_4_2.Fields[Dictionary.FIX_4_2.Fields.MaxTag + 1]); } - + [TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))] public void TestIndexerWithTagZero() { @@ -54,7 +54,8 @@ public void TestIndexWithTagOne() public void TestIndexWithTagEqualToMaxTag() { var field = Dictionary.FIX_4_2.Fields.Last(); - if (field is null) { + if (field is null) + { Assert.Fail("field is null"); return; } @@ -65,12 +66,13 @@ public void TestIndexWithTagEqualToMaxTag() public void TestIndexWithTagGreaterThanMaxTag() { var field = Dictionary.FIX_4_2.Fields.Last(); - if (field is null) { + if (field is null) + { Assert.Fail("field is null"); return; } Assert.IsNull(Dictionary.FIX_4_2.Fields[field.Tag + 1]); - } + } [TestMethod] public void TestTryGetValueWithTagZeroFails() @@ -90,7 +92,8 @@ public void TestTryGetValueWithTagOneSucceeds() public void TestTryGetValueWithTagEqualToMaxTag() { var field = Dictionary.FIX_4_2.Fields.Last(); - if (field is null) { + if (field is null) + { Assert.Fail("field is null"); return; } @@ -102,13 +105,14 @@ public void TestTryGetValueWithTagEqualToMaxTag() public void TestTryGetValueWithTagGreaterThanMaxTag() { var field = Dictionary.FIX_4_2.Fields.Last(); - if (field is null) { + if (field is null) + { Assert.Fail("field is null"); return; } Assert.IsFalse(Dictionary.FIX_4_2.Fields.TryGetValue(field.Tag + 1, out var expected)); Assert.IsFalse(Dictionary.IsValid(expected)); - } + } [TestMethod] public void TestFieldSequenceGaps() @@ -132,7 +136,7 @@ public void TestFieldCollections() Assert.AreEqual(956, Fix.Dictionary.FIX_4_4.Fields.MaxTag); Assert.AreEqual(50002, Fix.Dictionary.FIX_5_0SP2.Fields.MaxTag); } - + [TestMethod] public void TestFieldCollectionContains() { @@ -154,4 +158,4 @@ public void TestFieldValueDescription() var day = Dictionary.FIX_5_0SP2.TimeInForce.Day; Assert.AreEqual("A buy or sell order that, if not executed expires at the end of the trading day on which it was entered.", day.Description); } -} +} diff --git a/Fix.Dictionary.Tests/MessageTests.cs b/Fix.Dictionary.Tests/MessageTests.cs index bcee32a..3f77fbb 100644 --- a/Fix.Dictionary.Tests/MessageTests.cs +++ b/Fix.Dictionary.Tests/MessageTests.cs @@ -1,5 +1,5 @@ -using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; namespace FixDictionary.Tests; @@ -42,7 +42,7 @@ public void TestMessageAdded() [TestMethod] public void TestMessageFieldsLength() { - Assert.AreEqual(104, Fix.Dictionary.FIX_4_2.Messages.OrderSingle.Fields.Count); + Assert.AreEqual(104, Fix.Dictionary.FIX_4_2.Messages.OrderSingle.Fields.Count); } [TestMethod] diff --git a/Fix.Dictionary.Tests/VersionTests.cs b/Fix.Dictionary.Tests/VersionTests.cs index 48ede82..a3439ec 100644 --- a/Fix.Dictionary.Tests/VersionTests.cs +++ b/Fix.Dictionary.Tests/VersionTests.cs @@ -1,5 +1,5 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; using Fix; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace FixDictionary.Tests; diff --git a/Fix.Dictionary/FieldValue.cs b/Fix.Dictionary/FieldValue.cs index 17058cb..e1b1df2 100644 --- a/Fix.Dictionary/FieldValue.cs +++ b/Fix.Dictionary/FieldValue.cs @@ -25,7 +25,7 @@ public override string ToString() { if (string.IsNullOrEmpty(Name)) { - if (FIX_5_0SP2.Fields.TryGetValue(Tag, out var fieldDfinition) && + if (FIX_5_0SP2.Fields.TryGetValue(Tag, out var fieldDfinition) && fieldDfinition.Values.TryGetValue(Value, out var valueDefinition)) { Name = valueDefinition.Name; diff --git a/Fix.Dictionary/Message.cs b/Fix.Dictionary/Message.cs index d9ccd68..ac089a5 100644 --- a/Fix.Dictionary/Message.cs +++ b/Fix.Dictionary/Message.cs @@ -1,6 +1,3 @@ -using System.Collections.Generic; -using System.Linq; - namespace Fix; public partial class Dictionary diff --git a/Fix.Dictionary/MessageField.cs b/Fix.Dictionary/MessageField.cs index 60182ca..2188c2f 100644 --- a/Fix.Dictionary/MessageField.cs +++ b/Fix.Dictionary/MessageField.cs @@ -18,6 +18,6 @@ public MessageField(VersionField field, bool required, int depth) public string Description => field.Description; public bool Required { get; } public int Depth { get; } - + } } diff --git a/Fix.Dictionary/MessageFieldCollection.cs b/Fix.Dictionary/MessageFieldCollection.cs index 9fb2e6c..6e2cc6f 100644 --- a/Fix.Dictionary/MessageFieldCollection.cs +++ b/Fix.Dictionary/MessageFieldCollection.cs @@ -1,7 +1,5 @@ -using System.Linq; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Fix.Common; namespace Fix; diff --git a/Fix.Dictionary/Version.cs b/Fix.Dictionary/Version.cs index a8844da..59d0008 100644 --- a/Fix.Dictionary/Version.cs +++ b/Fix.Dictionary/Version.cs @@ -31,6 +31,6 @@ public string ApplVerID } public override string ToString() => BeginString; - + } } diff --git a/Fix.Dictionary/VersionCollection.cs b/Fix.Dictionary/VersionCollection.cs index dcab3e3..2463e23 100644 --- a/Fix.Dictionary/VersionCollection.cs +++ b/Fix.Dictionary/VersionCollection.cs @@ -1,6 +1,5 @@ -using System.Linq; -using System.Collections; using System.Collections.Generic; +using System.Linq; namespace Fix; diff --git a/Fix.Dictionary/VersionDataTypeCollection.cs b/Fix.Dictionary/VersionDataTypeCollection.cs index 89bd3c6..fd17d83 100644 --- a/Fix.Dictionary/VersionDataTypeCollection.cs +++ b/Fix.Dictionary/VersionDataTypeCollection.cs @@ -1,5 +1,5 @@ -using System.Linq; using System.Collections.Generic; +using System.Linq; namespace Fix; diff --git a/Fix.Dictionary/VersionFieldCollection.cs b/Fix.Dictionary/VersionFieldCollection.cs index 95917ba..6ad0bc0 100644 --- a/Fix.Dictionary/VersionFieldCollection.cs +++ b/Fix.Dictionary/VersionFieldCollection.cs @@ -1,8 +1,5 @@ -using System.Linq; using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using System.Diagnostics.CodeAnalysis; +using System.Linq; namespace Fix; @@ -68,8 +65,8 @@ public VersionField this[string name] public bool TryGetValue(string name, out VersionField field) { var value = (from candidate in Fields - where candidate?.Name.ToLower() == name.ToLower() - select candidate).FirstOrDefault(); + where candidate?.Name.ToLower() == name.ToLower() + select candidate).FirstOrDefault(); if (value is null) { diff --git a/Fix.Dictionary/VersionMessageCollection.cs b/Fix.Dictionary/VersionMessageCollection.cs index 9092046..b248d2f 100644 --- a/Fix.Dictionary/VersionMessageCollection.cs +++ b/Fix.Dictionary/VersionMessageCollection.cs @@ -1,5 +1,5 @@ -using System.Linq; using System.Collections.Generic; +using System.Linq; namespace Fix; diff --git a/Fix.Tests/OrderBookTests.cs b/Fix.Tests/OrderBookTests.cs index e37ad16..6ec1b66 100644 --- a/Fix.Tests/OrderBookTests.cs +++ b/Fix.Tests/OrderBookTests.cs @@ -12,7 +12,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using static Fix.Dictionary; @@ -449,7 +448,7 @@ public async Task TestQuoteJockeyLog() [TestMethod] public async Task TestCancel() { - var text = + var text = "{\n" + "BeginString (8) - FIX.4.2\n" + "BodyLength (9) - 216\n" + @@ -1021,7 +1020,7 @@ public async Task TestUpwardAmendFilledToPartial() [DeploymentItem("Logs/t_fill_while_cancel_pending.log")] public async Task TestFillWhileCancelPending() { - Fix.MessageCollection messages = await Fix .MessageCollection.Parse("t_fill_while_cancel_pending.log"); + Fix.MessageCollection messages = await Fix.MessageCollection.Parse("t_fill_while_cancel_pending.log"); Assert.IsNotNull(messages); Assert.AreEqual(6, messages.Count); @@ -1070,7 +1069,7 @@ public async Task TestFillWhileCancelPending() [DeploymentItem("Logs/t_fill_while_amend_pending.log")] public async Task TestFillWhileAmendPending() { - Fix.MessageCollection messages = await Fix .MessageCollection.Parse("t_fill_while_amend_pending.log"); + Fix.MessageCollection messages = await Fix.MessageCollection.Parse("t_fill_while_amend_pending.log"); Assert.IsNotNull(messages); Assert.AreEqual(6, messages.Count); diff --git a/Fix.Tests/ParserTests.cs b/Fix.Tests/ParserTests.cs index c3492ad..363327c 100644 --- a/Fix.Tests/ParserTests.cs +++ b/Fix.Tests/ParserTests.cs @@ -13,14 +13,13 @@ using System; using System.IO; using System.Threading.Tasks; -using static Fix.Dictionary; namespace FixTests; [TestClass] public class ParserTests { - public async Task ParseMessageCollection(string filename) where Parser: Fix.LogParser, new() + public async Task ParseMessageCollection(string filename) where Parser : Fix.LogParser, new() { var result = new Fix.MessageCollection(); var url = new Uri($"file://{Path.GetFullPath(filename)}"); @@ -44,7 +43,7 @@ public async Task TestKlsParser() var messages = await ParseMessageCollection("t_kls.log"); Assert.AreEqual(95, messages.Count); } - + [TestMethod] [DeploymentItem("Logs/t_atlas.log")] public async Task TestAtlasParser() @@ -52,7 +51,7 @@ public async Task TestAtlasParser() var messages = await ParseMessageCollection("t_atlas.log"); Assert.AreEqual(473, messages.Count); } - + [TestMethod] [DeploymentItem("Logs/t_gate_driver.log")] public async Task TestGateDriverParser() @@ -60,7 +59,7 @@ public async Task TestGateDriverParser() var messages = await ParseMessageCollection("t_gate_driver.log"); Assert.AreEqual(43, messages.Count); } - + [TestMethod] [DeploymentItem("Logs/t_gate_ci.log")] public async Task TestGateCiParser() @@ -76,7 +75,7 @@ public async Task TestParseGateRawDriverLog() var messages = await ParseMessageCollection("t_gate_raw_driver.log"); Assert.AreEqual(1466, messages.Count); } - + [TestMethod] [DeploymentItem("Logs/t_gate_raw_ci.log")] public async Task TestParseGateRawCiLog() diff --git a/Fix.Tests/SessionTestsBase.cs b/Fix.Tests/SessionTestsBase.cs index 19a0da1..0a26fc5 100644 --- a/Fix.Tests/SessionTestsBase.cs +++ b/Fix.Tests/SessionTestsBase.cs @@ -259,7 +259,7 @@ static Fix.Message Expect(BlockingCollection? messages, Fix.Diction if (message is null) { - throw new Exception("message is null"); + throw new Exception("message is null"); } Assert.AreEqual(definition.MsgType, message.MsgType, $"Found MsgType={MsgTypeName(message.MsgType)} when we expected MsgType={definition.Name}\n{message}"); diff --git a/Fix/Parsers/FormattedLogParser.cs b/Fix/Parsers/FormattedLogParser.cs index ce86f51..ca0d4f0 100644 --- a/Fix/Parsers/FormattedLogParser.cs +++ b/Fix/Parsers/FormattedLogParser.cs @@ -9,7 +9,6 @@ // Author: Gary Hughes // ///////////////////////////////////////////////// -using System; using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; diff --git a/Fix/Parsers/KlsLogParser.cs b/Fix/Parsers/KlsLogParser.cs index 061b595..753e662 100644 --- a/Fix/Parsers/KlsLogParser.cs +++ b/Fix/Parsers/KlsLogParser.cs @@ -10,7 +10,6 @@ // ///////////////////////////////////////////////// -using System; using System.IO; using System.Threading.Tasks; diff --git a/Fix/Parsers/Parser.cs b/Fix/Parsers/Parser.cs index 8eec23e..271a2f8 100644 --- a/Fix/Parsers/Parser.cs +++ b/Fix/Parsers/Parser.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; diff --git a/Fix/Session.cs b/Fix/Session.cs index 1730db4..b4c6a7b 100644 --- a/Fix/Session.cs +++ b/Fix/Session.cs @@ -10,10 +10,10 @@ // ///////////////////////////////////////////////// global using System; +using Newtonsoft.Json; using System.ComponentModel; using System.Reflection; using System.Timers; -using Newtonsoft.Json; using static Fix.Dictionary; namespace Fix; @@ -220,16 +220,17 @@ public Session(Session session) [Category(CategoryCommon)] [DisplayName("Outgoing Timestamp Format")] [JsonProperty] - public string OutgoingTimestampFormat { + public string OutgoingTimestampFormat + { get => _outgoingTimestampFormat; set { if (!Field.IsTimestampFormatStringValid(value)) { - throw new Exception($"'{value}' is not a valid DateTime format string"); + throw new Exception($"'{value}' is not a valid DateTime format string"); } _outgoingTimestampFormat = value; - } + } } [Category(CategoryCommon)] diff --git a/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs b/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs index 4cec6b7..392d7cf 100644 --- a/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs +++ b/FixClient/DataGridViewControls/DataGridViewIndentColumn.cs @@ -11,7 +11,7 @@ ///////////////////////////////////////////////// using System.ComponentModel; -namespace FixClient; +namespace FixClient.DataGridViewControls; public class DataGridViewIndentColumn : DataGridViewColumn { @@ -21,7 +21,7 @@ public DataGridViewIndentColumn() } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public override DataGridViewCell CellTemplate + public override DataGridViewCell? CellTemplate { get { diff --git a/FixClient/DataGridViewImageColumnHeaderCell.cs b/FixClient/DataGridViewImageColumnHeaderCell.cs index a7f6155..f2fd4e9 100644 --- a/FixClient/DataGridViewImageColumnHeaderCell.cs +++ b/FixClient/DataGridViewImageColumnHeaderCell.cs @@ -142,12 +142,12 @@ public Padding ImagePadding public override object Clone() { var dataGridViewCell = base.Clone() as DataGridViewImageColumnHeaderCell ?? throw new NullReferenceException("DataGridViewColumnHeaderCell.Clone() returned a null reference"); - + dataGridViewCell.ImageBeforeValue = ImageBeforeValue; dataGridViewCell.ImagePadding = ImagePadding; dataGridViewCell.Image = Image; dataGridViewCell.Icon = Icon; - + return dataGridViewCell; } diff --git a/FixClient/EditableMessageFieldDataGridView.cs b/FixClient/EditableMessageFieldDataGridView.cs index 3989545..eeb292a 100644 --- a/FixClient/EditableMessageFieldDataGridView.cs +++ b/FixClient/EditableMessageFieldDataGridView.cs @@ -262,8 +262,11 @@ protected override void OnCellValueChanged(DataGridViewCellEventArgs e) // The user has selected an item in a combo box for an field with an enumerated value so // update the source field as well. // - dataRow[FieldDataTable.ColumnValue] = (string)CurrentCell.Value; - Message.Fields[index].Value = (string)CurrentCell.Value; + if (CurrentCell?.Value is string stringValue) + { + dataRow[FieldDataTable.ColumnValue] = stringValue; + Message.Fields[index].Value = stringValue; + } OnFieldValueChanged(); return; } diff --git a/FixClient/MainForm.cs b/FixClient/MainForm.cs index ea7e2ae..c40e329 100644 --- a/FixClient/MainForm.cs +++ b/FixClient/MainForm.cs @@ -64,7 +64,7 @@ partial class MainForm : Form readonly MenuStrip _mainMenu; - List _mru = new(); + List _mru = []; readonly MessagesPanel _messagesPanel; readonly OrdersPanel _ordersPanel; @@ -829,20 +829,19 @@ bool FileSaveAsClick(object? sender, EventArgs e) filename = current.SenderCompId + "-" + current.TargetCompId + ".session"; } - using (SaveFileDialog dlg = new()) - { - dlg.Filter = "txt files (*.session)|*.session|All files (*.*)|*.*"; - dlg.FilterIndex = 2; - dlg.RestoreDirectory = true; - dlg.FileName = filename; + using SaveFileDialog dlg = new(); + + dlg.Filter = "txt files (*.session)|*.session|All files (*.*)|*.*"; + dlg.FilterIndex = 2; + dlg.RestoreDirectory = true; + dlg.FileName = filename; - if (dlg.ShowDialog() == DialogResult.OK) - { - CurrentSession.FileName = dlg.FileName; - CurrentSession.Write(); - AddToMru(dlg.FileName); - return true; - } + if (dlg.ShowDialog() == DialogResult.OK) + { + CurrentSession.FileName = dlg.FileName; + CurrentSession.Write(); + AddToMru(dlg.FileName); + return true; } return false; diff --git a/FixClient/MessageFieldDataGridView.cs b/FixClient/MessageFieldDataGridView.cs index e5c4dc2..9dffb06 100644 --- a/FixClient/MessageFieldDataGridView.cs +++ b/FixClient/MessageFieldDataGridView.cs @@ -53,7 +53,7 @@ public MessageFieldDataGridView() // DataGridViewColumn column; - column = new DataGridViewIndentColumn + column = new DataGridViewControls.DataGridViewIndentColumn { Name = FieldDataTable.ColumnIndent, DataPropertyName = FieldDataTable.ColumnIndent, diff --git a/FixClient/MessagesPanel.cs b/FixClient/MessagesPanel.cs index 77f3c2e..1c1c24d 100644 --- a/FixClient/MessagesPanel.cs +++ b/FixClient/MessagesPanel.cs @@ -505,7 +505,7 @@ void EditGoaButtonClick(object? sender, EventArgs e) editor.Text = string.Format("{0} - {1}", fieldTag, fieldName); - if (row.Cells[FieldDataTable.ColumnValue].Value.ToString() is string goa) + if (row.Cells[FieldDataTable.ColumnValue].Value?.ToString() is string goa) { editor.Goa = goa; } @@ -546,7 +546,7 @@ void FieldGridCellContextMenuStripNeeded(object? sender, DataGridViewCellContext ContextMenuRowIndex = _fieldTable.Rows.IndexOf(row); - if (Session.CustomFields.Any()) + if (Session.CustomFields.Count != 0) { _insertContextMenuItem.DropDownItems.Clear(); @@ -566,7 +566,7 @@ void FieldGridCellContextMenuStripNeeded(object? sender, DataGridViewCellContext _repeatContextMenuItem.Enabled = _fieldGrid.SelectedRows.Count > 0; _removeContextMenuItem.Enabled = _fieldGrid.SelectedRows.Count > 0; - _insertContextMenuItem.Enabled = Session.CustomFields.Any(); + _insertContextMenuItem.Enabled = Session.CustomFields.Count != 0; _resetContextMenuItem.Enabled = _messageGrid.SelectedRows.Count > 0; e.ContextMenuStrip = _contextMenu; @@ -588,10 +588,10 @@ void InsertCustomFieldClick(object? sender, EventArgs e) return; } - var item = (ToolStripMenuItem)sender; - var field = (CustomField)item.Tag; - - message.Fields.Insert(ContextMenuRowIndex, new Fix.Field(field.Tag.ToString(), string.Empty)); + if (sender is ToolStripMenuItem item && item.Tag is CustomField field) + { + message.Fields.Insert(ContextMenuRowIndex, new Fix.Field(field.Tag.ToString(), string.Empty)); + } MessageGridSelectionChanged(this, EventArgs.Empty); } @@ -674,9 +674,7 @@ void RemoveButtonClick(object? sender, EventArgs e) // If the user selects the rows bottom up thats the order the rows will be in SelectedRows so we need to // reverse the order here. // - int tmp = end; - end = begin; - begin = tmp; + (begin, end) = (end, begin); } // // Update some fields automatically to make life easier for the user. @@ -769,9 +767,7 @@ void RepeatButtonClick(object? sender, EventArgs e) // If the user selects the rows bottom up thats the order the rows will be in SelectedRows so we need to // reverse the order here. // - int tmp = end; - end = begin; - begin = tmp; + (begin, end) = (end, begin); } Fix.Message? message = SelectedMessage; @@ -1715,10 +1711,7 @@ public void AcknowledgeOrder(Fix.Order order) message.Fields.Set(FIX_5_0SP2.Fields.OrderQty, order.OrderQty); message.Fields.Set(FIX_5_0SP2.OrdStatus.New); - if (order.OrderID == null) - { - order.OrderID = Session.NextOrderId.ToString(); - } + order.OrderID ??= Session.NextOrderId.ToString(); message.Fields.Set(FIX_5_0SP2.Fields.OrderID, order.OrderID); message.Fields.Set(FIX_5_0SP2.Fields.ExecID, Session.NextExecId.ToString()); @@ -1764,10 +1757,7 @@ public void RejectOrder(Fix.Order order) message.Fields.Set(FIX_5_0SP2.Fields.OrderQty, order.OrderQty); message.Fields.Set(FIX_5_0SP2.OrdStatus.Rejected); - if (order.OrderID == null) - { - order.OrderID = Session.NextOrderId.ToString(); - } + order.OrderID ??= Session.NextOrderId.ToString(); message.Fields.Set(FIX_5_0SP2.Fields.OrderID, order.OrderID); message.Fields.Set(FIX_5_0SP2.Fields.ExecID, Session.NextExecId.ToString()); @@ -1813,10 +1803,7 @@ public void ReportOrder(Fix.Order order) message.Fields.Set(FIX_5_0SP2.Fields.OrderQty, order.OrderQty); message.Fields.Set(FIX_5_0SP2.OrdStatus.Filled); - if (order.OrderID == null) - { - order.OrderID = Session.NextOrderId.ToString(); - } + order.OrderID ??= Session.NextOrderId.ToString(); message.Fields.Set(FIX_5_0SP2.Fields.OrderID, order.OrderID); message.Fields.Set(FIX_5_0SP2.Fields.ExecID, Session.NextExecId.ToString()); @@ -1907,10 +1894,7 @@ public void UnsolicitedCancelOrder(Fix.Order order) message.Fields.Set(FIX_5_0SP2.Fields.OrderQty, order.OrderQty); message.Fields.Set(FIX_5_0SP2.OrdStatus.Canceled); - if (order.OrderID == null) - { - order.OrderID = Session.NextOrderId.ToString(); - } + order.OrderID ??= Session.NextOrderId.ToString(); message.Fields.Set(FIX_5_0SP2.Fields.OrderID, order.OrderID); message.Fields.Set(FIX_5_0SP2.Fields.ExecID, Session.NextExecId.ToString()); diff --git a/FixClient/Parser/ParserPanel.cs b/FixClient/Parser/ParserPanel.cs index c519a49..dde20a5 100644 --- a/FixClient/Parser/ParserPanel.cs +++ b/FixClient/Parser/ParserPanel.cs @@ -1,12 +1,8 @@ -using System.Drawing; -using System.Drawing.Design; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; using System.Windows.Forms.Integration; -using System.Windows.Media; namespace FixClient; @@ -19,7 +15,7 @@ public partial class ParserPanel : FixClientPanel FontFamily = new System.Windows.Media.FontFamily("Consolas"), Background = System.Windows.Media.Brushes.White, Padding = new System.Windows.Thickness(10) - + }; string? _filename; @@ -84,14 +80,14 @@ async Task LoadClientMessagesButtonClick(object? sender, EventArgs e) } async Task LoadFile(string filename) - { + { Cursor? original = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { _textBlock.Text = string.Empty; - + var orderBook = new Fix.OrderBook(); var url = new Uri($"file://{Path.GetFullPath(filename)}"); diff --git a/FixPerformanceTest/Program.cs b/FixPerformanceTest/Program.cs index ba68922..b066bd5 100644 --- a/FixPerformanceTest/Program.cs +++ b/FixPerformanceTest/Program.cs @@ -10,12 +10,9 @@ // ///////////////////////////////////////////////// using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Diagnostics; using System.IO; +using System.Text; namespace FixPerformanceTest; diff --git a/FixPersistentSessionPerformanceTest/Program.cs b/FixPersistentSessionPerformanceTest/Program.cs index a0fbfae..455e0f1 100644 --- a/FixPersistentSessionPerformanceTest/Program.cs +++ b/FixPersistentSessionPerformanceTest/Program.cs @@ -10,16 +10,13 @@ // ///////////////////////////////////////////////// using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.IO; +using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; -using System.Net.Sockets; -using System.IO; using System.Timers; -using static System.Console; using static Fix.Dictionary; +using static System.Console; namespace FixPersistentSessionPerformanceTest; From 210c55a83ac9c6af7cebfc802a33091b9df563a8 Mon Sep 17 00:00:00 2001 From: Gary Hughes Date: Mon, 30 Dec 2024 16:33:56 +1100 Subject: [PATCH 3/3] Update GitHub actions and readme for .NET 9 --- .github/workflows/dotnet.yml | 11 ++++++----- .github/workflows/release.yml | 8 ++++---- CHANGELOG.md | 1 + FixClient/CHANGELOG.TXT | 1 + README.md | 6 +++--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ed05501..e0aa22f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -11,11 +11,11 @@ jobs: build: runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build @@ -25,8 +25,9 @@ jobs: - name: Publish run: dotnet publish -c Release - name: Upload Artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: FixClient - path: FixClient/bin/Release/net7.0-windows/win10-x64/publish/FixClient.exe + path: FixClient/bin/Release/net9.0-windows/win-x64/publish/FixClient.exe + overwrite: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23b09c7..2f98c98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,11 +9,11 @@ jobs: build_release: runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build @@ -43,7 +43,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: FixClient/bin/Release/net7.0-windows/win10-x64/publish/FixClient.exe + asset_path: FixClient/bin/Release/net9.0-windows/win-x64/publish/FixClient.exe asset_name: FixClient.exe asset_content_type: application/exe - name: Publish Fix.Common diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f9ac1..a935a58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ * Fixed an exception when adding custom fields. * The format of outgoing timestamp fields can now be customised in the session properties dialog. +* Upgrade to .NET 9 diff --git a/FixClient/CHANGELOG.TXT b/FixClient/CHANGELOG.TXT index 38b61b6..d72b878 100644 --- a/FixClient/CHANGELOG.TXT +++ b/FixClient/CHANGELOG.TXT @@ -3,6 +3,7 @@ • Fixed an exception when adding custom fields. • The format of outgoing timestamp fields can now be customised in the session properties dialog. +• Upgrade to .NET 9 -------------------------------------------------------------------------------- 5.2.0 2022/12/11 diff --git a/README.md b/README.md index 617a96d..27d169c 100755 --- a/README.md +++ b/README.md @@ -36,17 +36,17 @@ This branch maintains historic functionality and is built on a FIX Repository ba ## Building ### Command Line -* Install the [.NET 7.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-7.0.100-windows-x64-installer) +* Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-9.0.100-windows-x64-installer) * Clone this repository and change into the repository root directory. * On the command line type `dotnet publish -c Release` -* The resulting executable can be retrieved from `FixClient/bin/Release/net7.0-windows/win10-x64/publish/FixClient.exe` +* The resulting executable can be retrieved from `FixClient/bin/Release/net9.0-windows/win-x64/publish/FixClient.exe` ### Visual Studio * Install [Visual Studio Community Edition 2022](https://visualstudio.microsoft.com/vs/community/) * Open `Fix.sln` in the repository root directory. * Select `Build` -> `Publish FIX Client` from the menu. * Click the `Publish` button. -* The resulting executable can be retrieved from `FixClient/bin/Release/net7.0-windows/win10-x64/publish/FixClient.exe` +* The resulting executable can be retrieved from `FixClient/bin/Release/net9.0-windows/win-x64/publish/FixClient.exe` *** ## Acknowledgements