-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
* add .NET 5.0 support #286
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1409,11 +1409,12 @@ public BezahlCode(AuthorityType authority, string name, string account, string b | |||||
} | ||||||
else if (internalMode == 2) | ||||||
{ | ||||||
#pragma warning disable CS0612 | ||||||
if (authority != AuthorityType.periodicsinglepayment && authority != AuthorityType.singledirectdebit && authority != AuthorityType.singlepayment) | ||||||
throw new BezahlCodeException("The constructor with 'account' and 'bnc' may only be used with 'non SEPA' authority types. Either choose another authority type or switch constructor."); | ||||||
if (authority == AuthorityType.periodicsinglepayment && (string.IsNullOrEmpty(periodicTimeunit) || periodicTimeunitRotation == 0)) | ||||||
throw new BezahlCodeException("When using 'periodicsinglepayment' as authority type, the parameters 'periodicTimeunit' and 'periodicTimeunitRotation' must be set."); | ||||||
|
||||||
#pragma warning restore CS0612 | ||||||
} | ||||||
else if (internalMode == 3) | ||||||
{ | ||||||
|
@@ -1437,8 +1438,10 @@ public BezahlCode(AuthorityType authority, string name, string account, string b | |||||
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic)); | ||||||
|
||||||
//Non-SEPA payment types | ||||||
#pragma warning disable CS0612 | ||||||
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment || authority == AuthorityType.contact || (authority == AuthorityType.contact_v2 && oldWayFilled)) | ||||||
{ | ||||||
#pragma warning restore CS0612 | ||||||
if (!Regex.IsMatch(account.Replace(" ", ""), @"^[0-9]{1,9}$")) | ||||||
throw new BezahlCodeException("The account entered isn't valid."); | ||||||
this.account = account.Replace(" ", "").ToUpper(); | ||||||
|
@@ -1500,8 +1503,9 @@ public BezahlCode(AuthorityType authority, string name, string account, string b | |||||
throw new BezahlCodeException("Execution date must be today or in future."); | ||||||
this.executionDate = (DateTime)executionDate; | ||||||
} | ||||||
|
||||||
#pragma warning disable CS0612 | ||||||
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa) | ||||||
#pragma warning restore CS0612 | ||||||
{ | ||||||
if (periodicTimeunit.ToUpper() != "M" && periodicTimeunit.ToUpper() != "W") | ||||||
throw new BezahlCodeException("The periodicTimeunit must be either 'M' (monthly) or 'W' (weekly)."); | ||||||
|
@@ -1530,8 +1534,9 @@ public override string ToString() | |||||
if (authority != AuthorityType.contact && authority != AuthorityType.contact_v2) | ||||||
{ | ||||||
//Handle what is same for all payments | ||||||
|
||||||
#pragma warning disable CS0612 | ||||||
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment) | ||||||
#pragma warning restore CS0612 | ||||||
{ | ||||||
bezahlCodePayload += $"account={account}&"; | ||||||
bezahlCodePayload += $"bnc={bnc}&"; | ||||||
|
@@ -1552,7 +1557,7 @@ public override string ToString() | |||||
bezahlCodePayload += $"creditorid={ Uri.EscapeDataString(creditorId)}&"; | ||||||
if (!string.IsNullOrEmpty(mandateId)) | ||||||
bezahlCodePayload += $"mandateid={ Uri.EscapeDataString(mandateId)}&"; | ||||||
if (dateOfSignature != null) | ||||||
if (dateOfSignature != DateTime.MinValue) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contructor takes nullable DateTimes ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DateTime is a struct. It cannot be null. Also a warning appeared for this after add of .NET 5. I didn't check datatype of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback. The documentation states that for nullable types both, checking for null and checking for "HasValue" works: https://docs.microsoft.com/de-de/dotnet/csharp/language-reference/builtin-types/nullable-value-types So I suggest we change the code to:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we have another issue here. The constructor does already convert the Nullable type to a regulare DateTime. In this case, nothing is assign and it will be the default value, which is probably There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But it does so, only if dateOfSignature != null otherwise the conversion isn't run. |
||||||
bezahlCodePayload += $"dateofsignature={dateOfSignature.ToString("ddMMyyyy")}&"; | ||||||
} | ||||||
} | ||||||
|
@@ -1562,16 +1567,17 @@ public override string ToString() | |||||
bezahlCodePayload += $"reason={ Uri.EscapeDataString(reason)}&"; | ||||||
bezahlCodePayload += $"currency={currency}&"; | ||||||
bezahlCodePayload += $"executiondate={executionDate.ToString("ddMMyyyy")}&"; | ||||||
|
||||||
#pragma warning disable CS0612 | ||||||
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.periodicsinglepaymentsepa) | ||||||
{ | ||||||
bezahlCodePayload += $"periodictimeunit={periodicTimeunit}&"; | ||||||
bezahlCodePayload += $"periodictimeunitrotation={periodicTimeunitRotation}&"; | ||||||
if (periodicFirstExecutionDate != null) | ||||||
if (periodicFirstExecutionDate != DateTime.MinValue) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contructor takes nullable DateTimes ([...] , DateTime? periodicFirstExecutionDate = null, [...] so I guess the dates should be checked against null or does ... != Datetime.MinValue also check for null? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DateTime is a struct. It cannot be null. Also a warning appeared for this after add of .NET 5. I didn't check datatype of |
||||||
bezahlCodePayload += $"periodicfirstexecutiondate={periodicFirstExecutionDate.ToString("ddMMyyyy")}&"; | ||||||
if (periodicLastExecutionDate != null) | ||||||
if (periodicLastExecutionDate != DateTime.MinValue) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contructor takes nullable DateTimes ([...] , DateTime? periodicLastExecutionDate = null, [...] so I guess the dates should be checked against null or does ... != Datetime.MinValue also check for null? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DateTime is a struct. It cannot be null. Also a warning appeared for this after add of .NET 5. I didn't check datatype of |
||||||
bezahlCodePayload += $"periodiclastexecutiondate={periodicLastExecutionDate.ToString("ddMMyyyy")}&"; | ||||||
} | ||||||
#pragma warning restore CS0612 | ||||||
} | ||||||
else | ||||||
{ | ||||||
|
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.