Constants following PascalCase convention#71
Constants following PascalCase convention#71kid-cavaquinho wants to merge 21 commits intobunq:developfrom kid-cavaquinho:feature/bunq/sdk_csharp#58-pascalcase-constants
Conversation
|
@AnTao 😁 Nice on getting the commits right! And thanks for this pull request! |
OGKevin
left a comment
There was a problem hiding this comment.
A few questions and a note regarding environment constants.
| private const string ContextFilenameTest = "context-save-restore-test.conf"; | ||
|
|
||
| private static ApiContext apiContext; | ||
| private static ApiContext _apiContext; |
There was a problem hiding this comment.
I believe it was resharper doing some work 'automatically'. Shall I revert the underscore on all the private variables?
There was a problem hiding this comment.
Yes please revert the _, unless there is a style guide entry that is supporting this _ 👍
| { | ||
| {ApiClient.HEADER_ATTACHMENT_DESCRIPTION, ATTACHMENT_DECSRIPTION}, | ||
| {ApiClient.HEADER_CONTENT_TYPE, CONTEN_TYPE}, | ||
| {ApiClient.HeaderAttachmentDescription, ATTACHMENT_DECSRIPTION}, |
There was a problem hiding this comment.
ATTACHMENT_DECSRIPTION is still in caps.
There was a problem hiding this comment.
I might have missed this ones, changing it.
| {ApiClient.HEADER_ATTACHMENT_DESCRIPTION, ATTACHMENT_DECSRIPTION}, | ||
| {ApiClient.HEADER_CONTENT_TYPE, CONTEN_TYPE}, | ||
| {ApiClient.HeaderAttachmentDescription, ATTACHMENT_DECSRIPTION}, | ||
| {ApiClient.HeaderContentType, CONTEN_TYPE}, |
There was a problem hiding this comment.
CONTEN_TYPE is still in caps.
There seems to be a few constants in this file that have not been refactored, please refactor them.
BunqSdk/Http/ApiClient.cs
Outdated
| public const char DelimiterUriParams = '&'; | ||
|
|
||
| private readonly HttpClient client; | ||
| private readonly HttpClient _client; |
BunqSdk/Http/ApiClient.cs
Outdated
| private readonly HttpClient _client; | ||
|
|
||
| private readonly ApiContext apiContext; | ||
| private readonly ApiContext _apiContext; |
BunqSdk/Json/BunqJsonConvert.cs
Outdated
| private const string FormatDate = "yyyy-MM-dd HH:mm:ss.ffffff"; | ||
|
|
||
| private static bool isInitialized; | ||
| private static bool _isInitialized; |
BunqSdk/Model/Core/Installation.cs
Outdated
| public SessionToken SessionToken { get; private set; } | ||
| private readonly Id id; | ||
| private readonly PublicKeyServer publicKeyServer; | ||
| private readonly Id _id; |
BunqSdk/Model/Core/Installation.cs
Outdated
| private readonly Id id; | ||
| private readonly PublicKeyServer publicKeyServer; | ||
| private readonly Id _id; | ||
| private readonly PublicKeyServer _publicKeyServer; |
OGKevin
left a comment
There was a problem hiding this comment.
It seems that I have been sloppy with the initial constants names!
- Please rename the constants as I’ve pointed out.
| private const string PAYMENT_AMOUNT_EUR = "0.01"; | ||
| private const string PAYMENT_CURRENCY = "EUR"; | ||
| private const string PAYMENT_DESCRIPTION = "C# test Payment"; | ||
| private const string Amount = "0.01"; |
There was a problem hiding this comment.
Please rename this back to PaymentAmountEur as Amount can also refer to the Amount object.
| private const string PAYMENT_CURRENCY = "EUR"; | ||
| private const string PAYMENT_DESCRIPTION = "C# test Payment"; | ||
| private const string Amount = "0.01"; | ||
| private const string Currency = "EUR"; |
There was a problem hiding this comment.
Please rename this back to PaymentCurrecnyEur
| private const string PAYMENT_DESCRIPTION = "C# test Payment"; | ||
| private const string Amount = "0.01"; | ||
| private const string Currency = "EUR"; | ||
| private const string Description = "C# test Payment"; |
There was a problem hiding this comment.
Please rename this back to PaymentDescription. This is our standard on how to name constants. There should be a group identifier and in this case it is Payment.
| {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)}, | ||
| {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, | ||
| {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF} | ||
| {Payment.FIELD_AMOUNT, new Amount(Amount, Currency)}, |
There was a problem hiding this comment.
Don't forget to refactor the renames on these lines as well.
| private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment"; | ||
| private const string FIELD_STATUS = "ACCEPTED"; | ||
| private const int INDEX_FIRST = 0; | ||
| private const string Amount = "0.01"; |
There was a problem hiding this comment.
Same as above, here I was kinda sloppy with the constants name 🙈, Please rename them as described in my comment above.
| private const string TAB_ITEM_FIELD_DESCRIPTION = "Super expensive java tea"; | ||
| private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT"; | ||
| private const string TabDescription = "Pay the tab for Java test please."; | ||
| private const string StatusOpen = "OPEN"; |
There was a problem hiding this comment.
@OGKevin it should be TabUsageSingleStatusOpen following the style you describe above regarding the group, right? naming is hard
There was a problem hiding this comment.
@AnTao Naming is indeed hard! 😁 but you will get used to it!
Yes TabUsageSingleStatusOpen sounds good 👍
| private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT"; | ||
| private const string TabDescription = "Pay the tab for Java test please."; | ||
| private const string StatusOpen = "OPEN"; | ||
| private const string Amount = "42.00"; |
| private const string TabDescription = "Pay the tab for Java test please."; | ||
| private const string StatusOpen = "OPEN"; | ||
| private const string Amount = "42.00"; | ||
| private const string Currency = "EUR"; |
| private const string Amount = "42.00"; | ||
| private const string Currency = "EUR"; | ||
| private const string TabItemDescription = "Super expensive java tea"; | ||
| private const string StatusWaiting = "WAITING_FOR_PAYMENT"; |
| {TabUsageSingle.FIELD_STATUS, FIELD_STATUS_OPEN}, | ||
| {TabUsageSingle.FIELD_AMOUNT_TOTAL, new Amount(AMOUNT_EUR, FIELD_CURRENCY)} | ||
| {TabUsageSingle.FIELD_DESCRIPTION, TabDescription}, | ||
| {TabUsageSingle.FIELD_STATUS, StatusOpen}, |
There was a problem hiding this comment.
Don't forget to refactor these lines after the constants renames.
| private const string MonetaryAccountBankSubStatus = "REDEMPTION_VOLUNTARY"; | ||
| private const string MonetaryAccountBankReason = "OTHER"; | ||
| private const string MonetaryAccountBankReasonDescription = "Because this is a test"; | ||
| private const string MonetaryAccountBankCurrency = "EUR"; |
There was a problem hiding this comment.
Lets make this name future proof, MonetaryAccountBankCurrencyEur. If we start supporting other currencies then there will be less names to change 👍
| private const string Description = "Payment From C# Test"; | ||
| private const string Text = "test msg send from C# test"; | ||
| private const string PaymentChatAmountEur = "0.01"; | ||
| private const string PaymentChatCurrency = "EUR"; |
There was a problem hiding this comment.
Please suffix the currency Eur
| private const string TabUsageSingleDescription = "Pay the tab for Java test please."; | ||
| private const string TabUsageSingleStatusOpen = "OPEN"; | ||
| private const string TabAmountEur = "42.00"; | ||
| private const string TabCurrency = "EUR"; |
There was a problem hiding this comment.
Please suffix Eur and consistency
| private const string StatusWaiting = "WAITING_FOR_PAYMENT"; | ||
| private const string TabUsageSingleDescription = "Pay the tab for Java test please."; | ||
| private const string TabUsageSingleStatusOpen = "OPEN"; | ||
| private const string TabAmountEur = "42.00"; |
There was a problem hiding this comment.
Please be consistent 😝 TabAmountEur -> TabUsageSingleAmountEur
There was a problem hiding this comment.
The constant is also used along with the TabItemShop entity. Changing it for consistency!
OGKevin
left a comment
There was a problem hiding this comment.
One small test amount comment.
After that LGTM
| private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT"; | ||
| private const string TabUsageSingleDescription = "Pay the tab for Java test please."; | ||
| private const string TabUsageSingleStatusOpen = "OPEN"; | ||
| private const string TabUsageSingleAmountEur = "42.00"; |
There was a problem hiding this comment.
😮 42.00 is way to much :P it will drain the test account pretty fast haha! Please lower this amount.
|
@sandervdo you're up, please 👀 |
|
All tests are passing. 👏. Because this PR doenst need any extra tests, I'm marking the |
sandervdo
left a comment
There was a problem hiding this comment.
Thanks for all your work in this PR! I mostly have very small comments, some names are plural whereas our convention is to not use plural names at all (we use PaymentIds -> allPaymentId for instance). Some comments will require a second look of @OGKevin as he's the SDK hero. 😄
BunqSdk.Samples/PaymentListSample.cs
Outdated
| private const string MESSAGE_LATEST_PAGE_IDS = "Latest page IDs: "; | ||
| private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: "; | ||
| private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!"; | ||
| private const string MessageLatestPageIds = "Latest page IDs: "; |
There was a problem hiding this comment.
Plural -> MessageLatestPageAllPaymentId
BunqSdk.Samples/PaymentListSample.cs
Outdated
| private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: "; | ||
| private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!"; | ||
| private const string MessageLatestPageIds = "Latest page IDs: "; | ||
| private const string MessageSecondLatestPageIds = "Second latest page IDs: "; |
There was a problem hiding this comment.
Plural -> MessageSecondLatestPageAllPaymentId
BunqSdk.Samples/PaymentListSample.cs
Outdated
| private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!"; | ||
| private const string MessageLatestPageIds = "Latest page IDs: "; | ||
| private const string MessageSecondLatestPageIds = "Second latest page IDs: "; | ||
| private const string MessageNoPriorPaymentsFound = "No prior payments found!"; |
There was a problem hiding this comment.
Plural -> MessageNoPriorPaymentFound
BunqSdk.Samples/PaymentListSample.cs
Outdated
| }; | ||
| Console.WriteLine(MESSAGE_LATEST_PAGE_IDS); | ||
| var paymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, | ||
| Console.WriteLine(MessageLatestPageIds); |
There was a problem hiding this comment.
MessageLatestPageAllPaymentId
BunqSdk.Samples/PaymentListSample.cs
Outdated
| { | ||
| Console.WriteLine(MESSAGE_SECOND_LATEST_PAGE_IDS); | ||
| var previousPaymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, | ||
| Console.WriteLine(MessageSecondLatestPageIds); |
There was a problem hiding this comment.
Rename (check for other occurrences too of renamed constants)
| To run tests via Rider, you can right click on the `BunqSdk.Tests` solution and should be able to run | ||
| the tests cases form the IDE. | ||
| the tests cases from the IDE. | ||
| To run the tests via Visual Studio, you can use the Test Explorer window. Use default shortcut Ctrl+R, A |
There was a problem hiding this comment.
Is there a shortcut for the Mac edition of Visual Studio too?
There was a problem hiding this comment.
For VS Code there is an [extension] (https://github.com/formulahendry/vscode-dotnet-test-explorer) for testing. Although I use VS Code more and more frequently, I still do 95% of .NET development with Visual Studio, so I don't have much feedback on this extension, yet. I am also not sure if this shortcut will work with VS Code.
Are you guys using Rider? What is your feedback? (Sorry for the off topic of the PR)
There was a problem hiding this comment.
Yea I use Rider, please list this extension in the README as well then to ensure that others know that they must install the extension 👍
There was a problem hiding this comment.
@AnTao myself I don't code in C# at all, but we use the Jetbrains editors mostly yes (PhpStorm, PyCharm, etc.). But in my case, no Rider.
There was a problem hiding this comment.
@OGKevin can you check for the shortcut on MacOS then?
BunqSdk/Context/ApiContext.cs
Outdated
| /// Minimum time to session expiry not requiring session reset. | ||
| /// </summary> | ||
| private const int TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS = 30; | ||
| private const int TimeToSessionExpiryMinimumSeconds = 30; |
There was a problem hiding this comment.
TimeToSessionExpiryMinimumSecond (hmm, looks weird, @OGKevin 👀 )
There was a problem hiding this comment.
🤷♂️ your suggestion is fine, 🙅♂️ plurals.
There was a problem hiding this comment.
@OGKevin @sandervdo TimeToSessionExpiryAllMinimumSecond 🙈 This renaming changes will bring a lot of breaking changes!
There was a problem hiding this comment.
@AnTao How do you mean ? I only see one usage for it which is here:
sdk_csharp/BunqSdk/Context/ApiContext.cs
Line 196 in c71114b
There was a problem hiding this comment.
Ow wait shit your right! I understand. Therefore this pull request needs to actually wait for 0.13.0 👍 Because this is indeed a breaking change! Holy crap how did I miss this 😅
There was a problem hiding this comment.
@OGKevin actually the ones I changed in ApiContext.cs are all with the private modifier, so that will be alright.
There was a problem hiding this comment.
@AnTao Correct, but the field constants for the generated code for instance all will be used publicly, means current implementations will break!
There was a problem hiding this comment.
Lets continue the breaking change discussion in the issue please 👍
| /// Glue to concatenate the error messages. | ||
| /// </summary> | ||
| private const string GLUE_ERROR_MESSAGES = "\n"; | ||
| private const string GlueErrorMessages = "\n"; |
There was a problem hiding this comment.
GlueAllErrorMessage Group by Glue
There was a problem hiding this comment.
I don't like the Glue too much. Why don't we use Separator or sth?
There was a problem hiding this comment.
Hmm well Separator can also be used just fine 👍
BunqSdk/Http/ApiClient.cs
Outdated
| private const string DeviceServerUrl = "device-server"; | ||
| private const string InstallationUrl = "installation"; | ||
| private const string SessionServerUrl = "session-server"; | ||
| private static readonly string[] UrisNotRequiringActiveSession = new string[] |
There was a problem hiding this comment.
AllUriNotRequiringActiveSession
BunqSdk/Security/SecurityUtils.cs
Outdated
| private const string HEADER_NAME_PREFIX_X_BUNQ = "X-Bunq-"; | ||
| private const string DELIMITER_HEADER_VALUE = ","; | ||
| private const string FORMAT_HEADER_STRING = "{0}: {1}"; | ||
| private const string Newline = "\n"; |
There was a problem hiding this comment.
@OGKevin do you want these constants grouped as well? Could use Format prefix.
There was a problem hiding this comment.
Ah yeas Format prefix would indeed be great 👌.
|
@AnTao FYI I've pushed some minor changed, be sure to pull before you push new changes 👍 |
|
Thanks for the push @OGKevin |
|
@AnTao I dont understand ? Why did you close this pull request ? There is nothing wrong with it! |
|
@OGKevin I did not even noticed I've closed it. My bad! Thanks for re-opening it. |
This PR closes/fixes the following issues: