Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup/nullable-ize IField-derived classes #888

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Examples/Executor/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
Price price = new Price(DEFAULT_MARKET_PRICE);
ClOrdID clOrdID = n.ClOrdID;

switch (ordType.getValue())

Check warning on line 51 in Examples/Executor/Executor.cs

View workflow job for this annotation

GitHub Actions / build

'FieldBase<char>.getValue()' is obsolete: 'Use Value getter property'
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand All @@ -67,10 +67,10 @@
symbol,
side,
orderQty,
new LastShares(orderQty.getValue()),

Check warning on line 70 in Examples/Executor/Executor.cs

View workflow job for this annotation

GitHub Actions / build

'FieldBase<decimal>.getValue()' is obsolete: 'Use Value getter property'
new LastPx(price.getValue()),

Check warning on line 71 in Examples/Executor/Executor.cs

View workflow job for this annotation

GitHub Actions / build

'FieldBase<decimal>.getValue()' is obsolete: 'Use Value getter property'
new CumQty(orderQty.getValue()),

Check warning on line 72 in Examples/Executor/Executor.cs

View workflow job for this annotation

GitHub Actions / build

'FieldBase<decimal>.getValue()' is obsolete: 'Use Value getter property'
new AvgPx(price.getValue()));

Check warning on line 73 in Examples/Executor/Executor.cs

View workflow job for this annotation

GitHub Actions / build

'FieldBase<decimal>.getValue()' is obsolete: 'Use Value getter property'

exReport.Set(clOrdID);

Expand Down Expand Up @@ -101,11 +101,11 @@
Price price = new Price(DEFAULT_MARKET_PRICE);
ClOrdID clOrdID = n.ClOrdID;

switch (ordType.getValue())

Check warning on line 104 in Examples/Executor/Executor.cs

View workflow job for this annotation

GitHub Actions / build

'FieldBase<char>.getValue()' is obsolete: 'Use Value getter property'
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -160,7 +160,7 @@
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -215,7 +215,7 @@
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -270,7 +270,7 @@
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -325,7 +325,7 @@
{
case OrdType.LIMIT:
price = n.Price;
if (price.Obj == 0)
if (price.Value == 0)
throw new IncorrectTagValue(price.Tag);
break;
case OrdType.MARKET: break;
Expand Down Expand Up @@ -375,7 +375,7 @@

public void OnMessage(QuickFix.FIX40.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX40.OrderCancelReject ocj = new QuickFix.FIX40.OrderCancelReject(new OrderID(orderid), msg.ClOrdID);
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
ocj.Text = new Text("Executor does not support order cancels");
Expand All @@ -392,7 +392,7 @@

public void OnMessage(QuickFix.FIX41.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX41.OrderCancelReject ocj = new QuickFix.FIX41.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -410,7 +410,7 @@

public void OnMessage(QuickFix.FIX42.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX42.OrderCancelReject ocj = new QuickFix.FIX42.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -428,7 +428,7 @@

public void OnMessage(QuickFix.FIX43.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX43.OrderCancelReject ocj = new QuickFix.FIX43.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -446,7 +446,7 @@

public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand All @@ -464,7 +464,7 @@

public void OnMessage(QuickFix.FIX50.OrderCancelRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX50.OrderCancelReject ocj = new QuickFix.FIX50.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand All @@ -484,7 +484,7 @@

public void OnMessage(QuickFix.FIX40.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX40.OrderCancelReject ocj = new QuickFix.FIX40.OrderCancelReject(new OrderID(orderid), msg.ClOrdID);
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
ocj.Text = new Text("Executor does not support order cancel/replaces");
Expand All @@ -501,7 +501,7 @@

public void OnMessage(QuickFix.FIX41.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX41.OrderCancelReject ocj = new QuickFix.FIX41.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -519,7 +519,7 @@

public void OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX42.OrderCancelReject ocj = new QuickFix.FIX42.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -537,7 +537,7 @@

public void OnMessage(QuickFix.FIX43.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX43.OrderCancelReject ocj = new QuickFix.FIX43.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER);
Expand All @@ -555,7 +555,7 @@

public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand All @@ -573,7 +573,7 @@

public void OnMessage(QuickFix.FIX50.OrderCancelReplaceRequest msg, SessionID s)
{
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID";
QuickFix.FIX50.OrderCancelReject ocj = new QuickFix.FIX50.OrderCancelReject(
new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
Expand Down
3 changes: 1 addition & 2 deletions QuickFIXn/AbstractInitiator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
using System.Threading;
using System.Threading;
using System.Collections.Generic;
using System;
using QuickFix.Logger;
Expand Down
1 change: 0 additions & 1 deletion QuickFIXn/AcceptorSocketDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#nullable enable
using System.Collections.Generic;
using System.Net;
using QuickFix.Logger;
Expand Down
3 changes: 1 addition & 2 deletions QuickFIXn/ClientHandlerThread.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
using System.Net.Sockets;
using System.Net.Sockets;
using System.Threading;
using System;
using QuickFix.Logger;
Expand Down
7 changes: 3 additions & 4 deletions QuickFIXn/DefaultMessageFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -68,7 +67,7 @@ public Message Create(string beginString, QuickFix.Fields.ApplVerID applVerId, s
if (beginString == QuickFix.Values.BeginString_FIXT11 && !Message.IsAdminMsgType(msgType))
{
_factories.TryGetValue(
QuickFix.FixValues.ApplVerID.ToBeginString(applVerId.Obj),
QuickFix.FixValues.ApplVerID.ToBeginString(applVerId.Value),
out messageFactory);
}

Expand All @@ -85,7 +84,7 @@ public Group Create(string beginString, string msgType, int groupCounterTag)
{
string key = beginString;
if(beginString.Equals(FixValues.BeginString.FIXT11))
key = QuickFix.FixValues.ApplVerID.ToBeginString(_defaultApplVerId.getValue());
key = QuickFix.FixValues.ApplVerID.ToBeginString(_defaultApplVerId.Value);

if (_factories.TryGetValue(key, out IMessageFactory? factory))
return factory.Create(beginString, msgType, groupCounterTag);
Expand Down
46 changes: 14 additions & 32 deletions QuickFIXn/Fields/BooleanField.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QuickFix.Fields;

namespace QuickFix.Fields
{
/// <summary>
/// FIX BooleanField class
/// </summary>
public class BooleanField : FieldBase<Boolean>
{
public BooleanField(int tag)
: base(tag, false) { }

public BooleanField(int tag, Boolean b)
: base(tag, b) { }

/// <summary>
/// quickfix-cpp compat - returns base type
/// </summary>
/// <returns>Boolean object</returns>
public Boolean getValue()
{ return Obj; }
/// <summary>
/// FIX Boolean field
/// </summary>
public class BooleanField : FieldBase<bool> {
public BooleanField(int tag)
: base(tag, false) {
}

/// <summary>
/// quickfix-cpp compat - set object
/// </summary>
public void setValue(Boolean b)
{ Obj = b; }
public BooleanField(int tag, bool b)
: base(tag, b) {
}

protected override string makeString()
{
return Converters.BoolConverter.Convert(Obj);
}
protected override string MakeString() {
return Converters.BoolConverter.Convert(Value);
}
}

38 changes: 13 additions & 25 deletions QuickFIXn/Fields/CharField.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace QuickFix.Fields;

namespace QuickFix.Fields
{
/// <summary>
/// A character message field
/// </summary>
public class CharField : FieldBase<Char>
{
public CharField(int tag)
:base(tag, '\0') {}

public CharField(int tag, char c)
: base(tag, c) { }

// quickfix compat
public char getValue()
{ return Obj; }
/// <summary>
/// FIX character field
/// </summary>
public class CharField : FieldBase<char> {
public CharField(int tag)
: base(tag, '\0') {
}

public void setValue(char c)
{ Obj = c; }
public CharField(int tag, char c)
: base(tag, c) {
}

protected override string makeString()
{
return Converters.CharConverter.Convert(Obj);
}
protected override string MakeString() {
return Converters.CharConverter.Convert(Value);
}
}
3 changes: 1 addition & 2 deletions QuickFIXn/Fields/Converters/DateTimeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
using System;
using System;
using System.Collections.Generic;
using System.Globalization;

Expand Down
20 changes: 6 additions & 14 deletions QuickFIXn/Fields/DateTimeField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@ public DateTimeField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecisio
timePrecision = timeFormatPrecision;
}


// quickfix compat
public DateTime getValue()
{ return Obj; }

public void setValue(DateTime dt)
{ Obj = dt; }

protected override string makeString()
protected override string MakeString()
{
return Converters.DateTimeConverter.ToFIX(Obj, timePrecision);
return Converters.DateTimeConverter.ToFIX(Value, timePrecision);
}
}

Expand All @@ -49,9 +41,9 @@ public DateOnlyField(int tag, DateTime dt, bool showMilliseconds)
public DateOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision)
: base(tag, dt, timeFormatPrecision) { }

protected override string makeString()
protected override string MakeString()
{
return Converters.DateTimeConverter.ToFIXDateOnly(Obj);
return Converters.DateTimeConverter.ToFIXDateOnly(Value);
}
}

Expand All @@ -69,9 +61,9 @@ public TimeOnlyField(int tag, DateTime dt, bool showMilliseconds)
public TimeOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision)
: base(tag, dt, timeFormatPrecision) { }

protected override string makeString()
protected override string MakeString()
{
return Converters.DateTimeConverter.ToFIXTimeOnly(Obj, base.timePrecision);
return Converters.DateTimeConverter.ToFIXTimeOnly(Value, base.timePrecision);
}
}
}
11 changes: 2 additions & 9 deletions QuickFIXn/Fields/DecimalField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ public DecimalField(int tag)
public DecimalField(int tag, Decimal val)
: base(tag, val) { }

// quickfix compat
public Decimal getValue()
{ return Obj; }

public void setValue(Decimal d)
{ Obj = d; }

protected override string makeString()
protected override string MakeString()
{
return Converters.DecimalConverter.Convert(Obj);
return Converters.DecimalConverter.Convert(Value);
}
}
}
Loading
Loading