Skip to content

Commit 31e3a58

Browse files
petre-cPetre Chitashvili
andauthored
Fix: Resolve CS8618 nullable warnings in SOAP response classes (#13)
* fix: Resolve CS8618 nullable warnings in SOAP response classes - Changed properties from 'set' to 'init' for immutability - Added 'required' modifier for properties that are always present in responses - Made optional properties nullable with '?' modifier - Fixed warnings in ChangePasswordResponseIo and GetPostboxMessagesResponseIo *Collaboration by Claude* * fix: Add nullable and required modifiers to AccountMovement properties - Made core movement properties required (movementId, debitCredit, description, amount) - Made optional properties nullable (partner info, taxpayer info, additional details) - Ensures proper handling of SOAP responses with missing optional fields *Collaboration by Claude* --------- Co-authored-by: Petre Chitashvili <petre.chitashvili@appifysheets.com>
1 parent 2ef9cef commit 31e3a58

10 files changed

Lines changed: 60 additions & 71 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TBC/@EntryIndexedValue">TBC</s:String></wpf:ResourceDictionary>
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TBC/@EntryIndexedValue">TBC</s:String>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=appify/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetAccountMovements/GetAccountMovementsResponseIo.cs‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Pager
1616
[XmlRoot(ElementName = "result")]
1717
public class ResultXml
1818
{
19-
[XmlElement(ElementName = "pager")] public Pager Pager { get; init; }
19+
[XmlElement(ElementName = "pager")] public required Pager Pager { get; init; }
2020

2121
[XmlElement(ElementName = "totalCount")]
2222
public int TotalCount { get; init; }
@@ -26,91 +26,91 @@ public class ResultXml
2626
public class AmountT
2727
{
2828
[XmlElement(ElementName = "amount")] public decimal Amount { get; init; }
29-
[XmlElement(ElementName = "currency")] public string Currency { get; init; }
29+
[XmlElement(ElementName = "currency")] public required string Currency { get; init; }
3030
}
3131

3232
[XmlRoot(ElementName = "accountMovement")]
3333
public class AccountMovement
3434
{
3535
[XmlElement(ElementName = "movementId")]
36-
public string MovementId { get; init; }
36+
public required string MovementId { get; init; }
3737

3838
[XmlElement(ElementName = "externalPaymentId")]
39-
public string ExternalPaymentId { get; init; }
39+
public string? ExternalPaymentId { get; init; }
4040

4141
[XmlElement(ElementName = "debitCredit")]
42-
public string DebitCredit { get; init; }
42+
public required string DebitCredit { get; init; }
4343

4444
[XmlElement(ElementName = "valueDate")]
4545
public DateTime ValueDate { get; init; }
4646

4747
[XmlElement(ElementName = "description")]
48-
public string Description { get; init; }
48+
public required string Description { get; init; }
4949

50-
[XmlElement(ElementName = "amount")] public AmountT Amount { get; init; }
50+
[XmlElement(ElementName = "amount")] public required AmountT Amount { get; init; }
5151

5252
[XmlElement(ElementName = "accountNumber")]
53-
public string AccountNumber { get; init; }
53+
public string? AccountNumber { get; init; }
5454

5555
[XmlElement(ElementName = "accountName")]
56-
public string AccountName { get; init; }
56+
public string? AccountName { get; init; }
5757

5858
[XmlElement(ElementName = "additionalInformation")]
59-
public string AdditionalInformation { get; init; }
59+
public string? AdditionalInformation { get; init; }
6060

6161
[XmlElement(ElementName = "documentDate")]
62-
public string DocumentDate { get; init; }
62+
public string? DocumentDate { get; init; }
6363

6464
[XmlElement(ElementName = "documentNumber")]
65-
public string DocumentNumber { get; init; }
65+
public string? DocumentNumber { get; init; }
6666

6767
[XmlElement(ElementName = "partnerAccountNumber")]
68-
public string PartnerAccountNumber { get; init; }
68+
public string? PartnerAccountNumber { get; init; }
6969

7070
[XmlElement(ElementName = "partnerName")]
71-
public string PartnerName { get; init; }
71+
public string? PartnerName { get; init; }
7272

7373
[XmlElement(ElementName = "partnerTaxCode")]
74-
public string PartnerTaxCode { get; init; }
74+
public string? PartnerTaxCode { get; init; }
7575

7676
[XmlElement(ElementName = "partnerBankCode")]
77-
public string PartnerBankCode { get; init; }
77+
public string? PartnerBankCode { get; init; }
7878

7979
[XmlElement(ElementName = "partnerBank")]
80-
public string PartnerBank { get; init; }
80+
public string? PartnerBank { get; init; }
8181

8282
[XmlElement(ElementName = "taxpayerCode")]
83-
public string TaxpayerCode { get; init; }
83+
public string? TaxpayerCode { get; init; }
8484

8585
[XmlElement(ElementName = "taxpayerName")]
86-
public string TaxpayerName { get; init; }
86+
public string? TaxpayerName { get; init; }
8787

8888
[XmlElement(ElementName = "operationCode")]
89-
public string OperationCode { get; init; }
89+
public string? OperationCode { get; init; }
9090

9191
[XmlElement(ElementName = "partnerDocumentType")]
92-
public string PartnerDocumentType { get; init; }
92+
public string? PartnerDocumentType { get; init; }
9393

9494
[XmlElement(ElementName = "statusCode")]
95-
public string StatusCode { get; init; }
95+
public string? StatusCode { get; init; }
9696

9797
[XmlElement(ElementName = "transactionType")]
98-
public string TransactionType { get; init; }
98+
public string? TransactionType { get; init; }
9999

100100
[XmlElement(ElementName = "additionalDescription")]
101-
public string AdditionalDescription { get; init; }
101+
public string? AdditionalDescription { get; init; }
102102

103103
[XmlElement(ElementName = "partnerPersonalNumber")]
104-
public string PartnerPersonalNumber { get; init; }
104+
public string? PartnerPersonalNumber { get; init; }
105105

106106
[XmlElement(ElementName = "partnerDocumentNumber")]
107-
public string PartnerDocumentNumber { get; init; }
107+
public string? PartnerDocumentNumber { get; init; }
108108

109109
[XmlElement(ElementName = "paymentId")]
110-
public string PaymentId { get; init; }
110+
public string? PaymentId { get; init; }
111111

112112
[XmlElement(ElementName = "parentExternalPaymentId")]
113-
public string ParentExternalPaymentId { get; init; }
113+
public string? ParentExternalPaymentId { get; init; }
114114
}
115115

116116
[XmlRoot(ElementName = "GetAccountMovementsResponseIo")]
@@ -119,8 +119,8 @@ public class GetAccountMovementsResponseIo : ISoapResponse
119119
[XmlElement(ElementName = "result")] public ResultXml? ResultXml { get; init; }
120120

121121
[XmlElement(ElementName = "accountMovement")]
122-
public List<AccountMovement>? AccountMovement { get; init; }
122+
public List<AccountMovement> AccountMovement { get; init; } = [];
123123

124124
[XmlAttribute(AttributeName = "ns2", Namespace = "http://www.w3.org/2000/xmlns/")]
125-
public string Ns2 { get; init; }
125+
public string? Ns2 { get; init; }
126126
}

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusRequestIo.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace AppifySheets.TBC.IntegrationService.Client.SoapInfrastructure.GetPaymentOrderStatus;
44

55
[UsedImplicitly]
6-
public record GetPaymentOrderStatusRequestIo(int SinglePaymentId)
7-
: RequestSoap<GetPaymentOrderStatusResponseIo>
6+
public record GetPaymentOrderStatusRequestIo(int SinglePaymentId) : RequestSoap<GetPaymentOrderStatusResponseIo>
87
{
98
public override string SoapXml()
109
=> $"""

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusResponseIo.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class GetPaymentOrderStatusResponseIo : ISoapResponse
88
{
99

1010
[XmlElement(ElementName="status")]
11-
public string Status { get; init; }
11+
public string? Status { get; init; }
1212

1313
public PaymentStatusEnum PaymentStatus => Status switch
1414
{

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/ImportSinglePaymentOrdersRequestIo.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public override string SoapXml()
5555

5656
public static class UseExtensions
5757
{
58-
public static TY Use<T, TY>(this T t, Func<T, TY> tTy) => tTy(t);
59-
6058
public static string FormatXml(this string xml)
6159
{
6260
try

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeInterfaces.cs‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ public abstract record TransferTypeRecord
2626
public string? AdditionalDescription => TransferTypeRecordSpecific.AdditionalDescription;
2727
}
2828

29-
// public interface IDescription
30-
// {
31-
// public string? Description { get; }
32-
// }
33-
34-
// public interface IAdditionalDescription
35-
// {
36-
// public string? AdditionalDescription { get; }
37-
// }
38-
3929
public interface IBeneficiaryName
4030
{
4131
public string BeneficiaryName { get; }

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeRecords.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ public record TransferToOtherBankNationalCurrencyPaymentOrderIo(BankAccountWithC
2222
public record TreasuryTransferPaymentOrderIo(long TreasuryCode) : TransferTypeRecord, ITreasury;
2323

2424
[UsedImplicitly]
25-
public record TransferToOwnAccountPaymentOrderIo(BankAccountWithCurrencyV RecipientAccountWithCurrency, string Description) : TransferTypeRecord, IRecipient, IBeneficiaryName, IDescription;
25+
public record TransferToOwnAccountPaymentOrderIo(BankAccountWithCurrencyV RecipientAccountWithCurrency) : TransferTypeRecord, IRecipient, IBeneficiaryName, IDescription;

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,44 @@
66
// }
77

88
using System.Xml.Serialization;
9-
using AppifySheets.TBC.IntegrationService.Client.SoapInfrastructure;
9+
10+
namespace AppifySheets.TBC.IntegrationService.Client.SoapInfrastructure.PasswordChangeRelated;
1011

1112
[XmlRoot(ElementName="ChangePasswordResponseIo")]
1213
public class ChangePasswordResponseIo : ISoapResponse {
1314

1415
[XmlElement(ElementName="message")]
15-
public string Message { get; set; }
16+
public string? Message { get; init; }
1617

1718
[XmlAttribute(AttributeName="i")]
18-
public string I { get; set; }
19+
public string? I { get; init; }
1920

2021
[XmlText]
21-
public string Text { get; set; }
22+
public string? Text { get; init; }
2223
}
2324

2425
[XmlRoot(ElementName="Body")]
2526
public class Body {
2627

2728
[XmlElement(ElementName="ChangePasswordResponseIo")]
28-
public ChangePasswordResponseIo ChangePasswordResponseIo { get; set; }
29+
public ChangePasswordResponseIo? ChangePasswordResponseIo { get; init; }
2930
}
3031

3132
[XmlRoot(ElementName="Envelope")]
3233
public class Envelope {
3334

3435
[XmlElement(ElementName="Header")]
35-
public object Header { get; set; }
36+
public object? Header { get; init; }
3637

3738
[XmlElement(ElementName="Body")]
38-
public Body Body { get; set; }
39+
public required Body Body { get; init; }
3940

4041
[XmlAttribute(AttributeName="SOAP-ENV")]
41-
public string SOAPENV { get; set; }
42+
public string? SOAPENV { get; init; }
4243

4344
[XmlAttribute(AttributeName="ns2")]
44-
public string Ns2 { get; set; }
45+
public string? Ns2 { get; init; }
4546

4647
[XmlText]
47-
public string Text { get; set; }
48+
public string? Text { get; init; }
4849
}

‎AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PostboxMessages/GetPostboxMessagesResponseIo.cs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,45 @@
1414
public class AdditionalAttributes {
1515

1616
[XmlElement(ElementName="name")]
17-
public string Name { get; set; }
17+
public required string Name { get; init; }
1818

1919
[XmlElement(ElementName="value")]
20-
public DateTime Value { get; set; }
20+
public DateTime Value { get; init; }
2121
}
2222

2323
[XmlRoot(ElementName="messages")]
2424
public class Messages {
2525

2626
[XmlElement(ElementName="messageId")]
27-
public int MessageId { get; set; }
27+
public int MessageId { get; init; }
2828

2929
[XmlElement(ElementName="messageText")]
30-
public string MessageText { get; set; }
30+
public required string MessageText { get; init; }
3131

3232
[XmlElement(ElementName="messageType")]
33-
public string MessageType { get; set; }
33+
public required string MessageType { get; init; }
3434

3535
[XmlElement(ElementName="messageStatus")]
36-
public string MessageStatus { get; set; }
36+
public required string MessageStatus { get; init; }
3737

3838
[XmlElement(ElementName="additionalAttributes")]
39-
public List<AdditionalAttributes> AdditionalAttributes { get; set; }
39+
public List<AdditionalAttributes>? AdditionalAttributes { get; init; }
4040
}
4141

4242
[XmlRoot(ElementName="GetPostboxMessagesResponseIo")]
4343
public class GetPostboxMessagesResponseIo : ISoapResponse {
4444

4545
[XmlElement(ElementName="messages")]
46-
public List<Messages> Messages { get; set; }
46+
public List<Messages>? Messages { get; init; }
4747

4848
[XmlAttribute(AttributeName="xsi")]
49-
public string Xsi { get; set; }
49+
public string? Xsi { get; init; }
5050

5151
[XmlAttribute(AttributeName="xsd")]
52-
public string Xsd { get; set; }
52+
public string? Xsd { get; init; }
5353

5454
[XmlText]
55-
public string Text { get; set; }
55+
public string? Text { get; init; }
5656
}
5757

5858
[XmlRoot(ElementName="Root")]
@@ -62,8 +62,8 @@ public class Root {
6262
public GetPostboxMessagesResponseIo? GetPostboxMessagesResponseIo { get; set; }
6363

6464
[XmlAttribute(AttributeName="ns2")]
65-
public string Ns2 { get; set; }
65+
public string? Ns2 { get; init; }
6666

6767
[XmlText]
68-
public string Text { get; set; }
68+
public string? Text { get; init; }
6969
}

‎AppifySheets.TBC.IntegrationService.Client/TBC_Services/Extensions.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static object XmlDeserializeFromString(this string objectData, Type type)
2222
var serializer = new XmlSerializer(type);
2323

2424
using TextReader reader = new StringReader(objectData);
25-
var result = serializer.Deserialize(reader);
25+
var result = serializer.Deserialize(reader)!;
2626

2727
return result;
2828
}

0 commit comments

Comments
 (0)