cleanup: Fix numerous build warnings in DataStreamSuite

Nearly all warnings were due to nullability issues, since the concept of
nullable reference types did not exist when the DataStream code was
originally written.

* PubSubClientMessage
  - Normalize indentation/whitespace
  - Fix some typos
  - Address nullability issues to fix build warnings
  - Modernize code

* Compression related files
  - ZipEntry
  - ZipFile
  - ZipInputStream
  - TarHeader

* RemoteMessage
  - make 'message' nullable to resolve warnings elsewhere (in calling code)

* PubSubSingleTagStateEvent.cs
* PubSubMessageReactor
* PubSubState
* SystemHeartbeatPublisher
* SystemStatsPublisher
* SingleTagData
* ManagedTCPMessageHub
* PubsubDeserializationController
* PublisherCore
* InflaterHuffmanTree
* AsyncTCPConnection_APM
* ThreadSafeQueue
* ManagedSubscriber
* SubscriberCore
* PubSubServerManagedTCPConnection
* AsyncTCPConnection_APM
* SuperMapStream
* MapStream
* TradeBarsStream
This commit is contained in:
John Colvin committed 2024-10-30 19:30:29 +00:00
1 parent 5426ba0aa7
commit 60a52b3922
34 files changed
+839 -817

No files matched your search

@@ -17,7 +17,7 @@ namespace BCG {
/// with PubSub, as some clients are still using ManagedSubcribers)
/// </summary>
public class ManagedSubscriber : IWorker, IDisposable {
private static ManagedSubscriber _self;
private static ManagedSubscriber? _self;
private SubscriberCore _subcore;
// private IDictionary myTypedDispatchTable = new Hashtable(),
// myRawDispatchTable = new Hashtable();
@@ -37,8 +37,7 @@ namespace BCG {
}
public void subscribe(string tag, OnData on_data) {
List<OnData> tag_cbs = null;
if (!_dispatch_table.TryGetValue(tag, out tag_cbs)) {
if (!_dispatch_table.TryGetValue(tag, out var tag_cbs)) {
tag_cbs = new List<OnData>();
_dispatch_table.Add(tag, tag_cbs);
_subcore.subscribe(tag); ;
@@ -74,8 +73,7 @@ namespace BCG {
// }
public void unsubcribe(string tag, OnData on_data) {
List<OnData> tag_cbs = null;
if (_dispatch_table.TryGetValue(tag, out tag_cbs)) {
if (_dispatch_table.TryGetValue(tag, out var tag_cbs)) {
tag_cbs.Remove(on_data);
if (tag_cbs.Count == 0) {
_dispatch_table.Remove(tag);
@@ -87,10 +85,10 @@ namespace BCG {
private void _fire_events(IEnumerable<bts.PubSubServerMessage> updates) {
// TODO
foreach (var u in updates) {
List<OnData> cbs = null;
if (_dispatch_table.TryGetValue(u.tag, out cbs)) {
ArgumentNullException.ThrowIfNull(u.tag);
if (_dispatch_table.TryGetValue(u.tag, out var cbs)) {
foreach (var cb in cbs) {
cb.Invoke(u.tag, u.data);
cb.Invoke(u.tag, u.data ?? Array.Empty<byte>());
}
}
}
@@ -102,10 +100,8 @@ namespace BCG {
}
}
public static ManagedSubscriber instance {
get { return _self = _self == null ? new ManagedSubscriber() : _self; }
}
public static ManagedSubscriber instance =>
_self ??= new();
#region IDisposable Members