From 515c52fe3821fe0b67be65566bbb882a9ab20e8a Mon Sep 17 00:00:00 2001 From: Petre Chitashvili Date: Mon, 4 Aug 2025 23:17:50 +0400 Subject: [PATCH 1/2] 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* --- .../ChangePasswordResponseIo.cs | 18 ++++++------- .../GetPostboxMessagesResponseIo.cs | 26 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs index 0fb7a55..83851ac 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs @@ -12,37 +12,37 @@ public class ChangePasswordResponseIo : ISoapResponse { [XmlElement(ElementName="message")] - public string Message { get; set; } + public string? Message { get; init; } [XmlAttribute(AttributeName="i")] - public string I { get; set; } + public string? I { get; init; } [XmlText] - public string Text { get; set; } + public string? Text { get; init; } } [XmlRoot(ElementName="Body")] public class Body { [XmlElement(ElementName="ChangePasswordResponseIo")] - public ChangePasswordResponseIo ChangePasswordResponseIo { get; set; } + public ChangePasswordResponseIo? ChangePasswordResponseIo { get; init; } } [XmlRoot(ElementName="Envelope")] public class Envelope { [XmlElement(ElementName="Header")] - public object Header { get; set; } + public object? Header { get; init; } [XmlElement(ElementName="Body")] - public Body Body { get; set; } + public required Body Body { get; init; } [XmlAttribute(AttributeName="SOAP-ENV")] - public string SOAPENV { get; set; } + public string? SOAPENV { get; init; } [XmlAttribute(AttributeName="ns2")] - public string Ns2 { get; set; } + public string? Ns2 { get; init; } [XmlText] - public string Text { get; set; } + public string? Text { get; init; } } \ No newline at end of file diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PostboxMessages/GetPostboxMessagesResponseIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PostboxMessages/GetPostboxMessagesResponseIo.cs index 98989c2..c47736c 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PostboxMessages/GetPostboxMessagesResponseIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PostboxMessages/GetPostboxMessagesResponseIo.cs @@ -14,45 +14,45 @@ public class AdditionalAttributes { [XmlElement(ElementName="name")] - public string Name { get; set; } + public required string Name { get; init; } [XmlElement(ElementName="value")] - public DateTime Value { get; set; } + public DateTime Value { get; init; } } [XmlRoot(ElementName="messages")] public class Messages { [XmlElement(ElementName="messageId")] - public int MessageId { get; set; } + public int MessageId { get; init; } [XmlElement(ElementName="messageText")] - public string MessageText { get; set; } + public required string MessageText { get; init; } [XmlElement(ElementName="messageType")] - public string MessageType { get; set; } + public required string MessageType { get; init; } [XmlElement(ElementName="messageStatus")] - public string MessageStatus { get; set; } + public required string MessageStatus { get; init; } [XmlElement(ElementName="additionalAttributes")] - public List AdditionalAttributes { get; set; } + public List? AdditionalAttributes { get; init; } } [XmlRoot(ElementName="GetPostboxMessagesResponseIo")] public class GetPostboxMessagesResponseIo : ISoapResponse { [XmlElement(ElementName="messages")] - public List Messages { get; set; } + public List? Messages { get; init; } [XmlAttribute(AttributeName="xsi")] - public string Xsi { get; set; } + public string? Xsi { get; init; } [XmlAttribute(AttributeName="xsd")] - public string Xsd { get; set; } + public string? Xsd { get; init; } [XmlText] - public string Text { get; set; } + public string? Text { get; init; } } [XmlRoot(ElementName="Root")] @@ -62,8 +62,8 @@ public class Root { public GetPostboxMessagesResponseIo? GetPostboxMessagesResponseIo { get; set; } [XmlAttribute(AttributeName="ns2")] - public string Ns2 { get; set; } + public string? Ns2 { get; init; } [XmlText] - public string Text { get; set; } + public string? Text { get; init; } } \ No newline at end of file From d1a4ce31671a44df84fad76c9be069300de7b8f0 Mon Sep 17 00:00:00 2001 From: Petre Chitashvili Date: Mon, 4 Aug 2025 23:25:29 +0400 Subject: [PATCH 2/2] 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* --- ...grationService.Client.Core.sln.DotSettings | 3 +- .../GetAccountMovementsResponseIo.cs | 60 +++++++++---------- .../GetPaymentOrderStatusRequestIo.cs | 3 +- .../GetPaymentOrderStatusResponseIo.cs | 2 +- .../ImportSinglePaymentOrdersRequestIo.cs | 2 - .../TransferTypeInterfaces.cs | 10 ---- .../TransferTypeRecords.cs | 2 +- .../ChangePasswordResponseIo.cs | 3 +- .../TBC_Services/Extensions.cs | 2 +- 9 files changed, 38 insertions(+), 49 deletions(-) diff --git a/AppifySheets.TBC.IntegrationService.Client.Core.sln.DotSettings b/AppifySheets.TBC.IntegrationService.Client.Core.sln.DotSettings index 4a28027..6baf83c 100644 --- a/AppifySheets.TBC.IntegrationService.Client.Core.sln.DotSettings +++ b/AppifySheets.TBC.IntegrationService.Client.Core.sln.DotSettings @@ -1,2 +1,3 @@  - TBC \ No newline at end of file + TBC + True \ No newline at end of file diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetAccountMovements/GetAccountMovementsResponseIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetAccountMovements/GetAccountMovementsResponseIo.cs index c3d4404..8bec668 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetAccountMovements/GetAccountMovementsResponseIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetAccountMovements/GetAccountMovementsResponseIo.cs @@ -16,7 +16,7 @@ public class Pager [XmlRoot(ElementName = "result")] public class ResultXml { - [XmlElement(ElementName = "pager")] public Pager Pager { get; init; } + [XmlElement(ElementName = "pager")] public required Pager Pager { get; init; } [XmlElement(ElementName = "totalCount")] public int TotalCount { get; init; } @@ -26,91 +26,91 @@ public class ResultXml public class AmountT { [XmlElement(ElementName = "amount")] public decimal Amount { get; init; } - [XmlElement(ElementName = "currency")] public string Currency { get; init; } + [XmlElement(ElementName = "currency")] public required string Currency { get; init; } } [XmlRoot(ElementName = "accountMovement")] public class AccountMovement { [XmlElement(ElementName = "movementId")] - public string MovementId { get; init; } + public required string MovementId { get; init; } [XmlElement(ElementName = "externalPaymentId")] - public string ExternalPaymentId { get; init; } + public string? ExternalPaymentId { get; init; } [XmlElement(ElementName = "debitCredit")] - public string DebitCredit { get; init; } + public required string DebitCredit { get; init; } [XmlElement(ElementName = "valueDate")] public DateTime ValueDate { get; init; } [XmlElement(ElementName = "description")] - public string Description { get; init; } + public required string Description { get; init; } - [XmlElement(ElementName = "amount")] public AmountT Amount { get; init; } + [XmlElement(ElementName = "amount")] public required AmountT Amount { get; init; } [XmlElement(ElementName = "accountNumber")] - public string AccountNumber { get; init; } + public string? AccountNumber { get; init; } [XmlElement(ElementName = "accountName")] - public string AccountName { get; init; } + public string? AccountName { get; init; } [XmlElement(ElementName = "additionalInformation")] - public string AdditionalInformation { get; init; } + public string? AdditionalInformation { get; init; } [XmlElement(ElementName = "documentDate")] - public string DocumentDate { get; init; } + public string? DocumentDate { get; init; } [XmlElement(ElementName = "documentNumber")] - public string DocumentNumber { get; init; } + public string? DocumentNumber { get; init; } [XmlElement(ElementName = "partnerAccountNumber")] - public string PartnerAccountNumber { get; init; } + public string? PartnerAccountNumber { get; init; } [XmlElement(ElementName = "partnerName")] - public string PartnerName { get; init; } + public string? PartnerName { get; init; } [XmlElement(ElementName = "partnerTaxCode")] - public string PartnerTaxCode { get; init; } + public string? PartnerTaxCode { get; init; } [XmlElement(ElementName = "partnerBankCode")] - public string PartnerBankCode { get; init; } + public string? PartnerBankCode { get; init; } [XmlElement(ElementName = "partnerBank")] - public string PartnerBank { get; init; } + public string? PartnerBank { get; init; } [XmlElement(ElementName = "taxpayerCode")] - public string TaxpayerCode { get; init; } + public string? TaxpayerCode { get; init; } [XmlElement(ElementName = "taxpayerName")] - public string TaxpayerName { get; init; } + public string? TaxpayerName { get; init; } [XmlElement(ElementName = "operationCode")] - public string OperationCode { get; init; } + public string? OperationCode { get; init; } [XmlElement(ElementName = "partnerDocumentType")] - public string PartnerDocumentType { get; init; } + public string? PartnerDocumentType { get; init; } [XmlElement(ElementName = "statusCode")] - public string StatusCode { get; init; } + public string? StatusCode { get; init; } [XmlElement(ElementName = "transactionType")] - public string TransactionType { get; init; } + public string? TransactionType { get; init; } [XmlElement(ElementName = "additionalDescription")] - public string AdditionalDescription { get; init; } + public string? AdditionalDescription { get; init; } [XmlElement(ElementName = "partnerPersonalNumber")] - public string PartnerPersonalNumber { get; init; } + public string? PartnerPersonalNumber { get; init; } [XmlElement(ElementName = "partnerDocumentNumber")] - public string PartnerDocumentNumber { get; init; } + public string? PartnerDocumentNumber { get; init; } [XmlElement(ElementName = "paymentId")] - public string PaymentId { get; init; } + public string? PaymentId { get; init; } [XmlElement(ElementName = "parentExternalPaymentId")] - public string ParentExternalPaymentId { get; init; } + public string? ParentExternalPaymentId { get; init; } } [XmlRoot(ElementName = "GetAccountMovementsResponseIo")] @@ -119,8 +119,8 @@ public class GetAccountMovementsResponseIo : ISoapResponse [XmlElement(ElementName = "result")] public ResultXml? ResultXml { get; init; } [XmlElement(ElementName = "accountMovement")] - public List? AccountMovement { get; init; } + public List AccountMovement { get; init; } = []; [XmlAttribute(AttributeName = "ns2", Namespace = "http://www.w3.org/2000/xmlns/")] - public string Ns2 { get; init; } + public string? Ns2 { get; init; } } \ No newline at end of file diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusRequestIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusRequestIo.cs index 9acff5a..7bd4212 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusRequestIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusRequestIo.cs @@ -3,8 +3,7 @@ namespace AppifySheets.TBC.IntegrationService.Client.SoapInfrastructure.GetPaymentOrderStatus; [UsedImplicitly] -public record GetPaymentOrderStatusRequestIo(int SinglePaymentId) - : RequestSoap +public record GetPaymentOrderStatusRequestIo(int SinglePaymentId) : RequestSoap { public override string SoapXml() => $""" diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusResponseIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusResponseIo.cs index 587a938..c5eef81 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusResponseIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/GetPaymentOrderStatus/GetPaymentOrderStatusResponseIo.cs @@ -8,7 +8,7 @@ public class GetPaymentOrderStatusResponseIo : ISoapResponse { [XmlElement(ElementName="status")] - public string Status { get; init; } + public string? Status { get; init; } public PaymentStatusEnum PaymentStatus => Status switch { diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/ImportSinglePaymentOrdersRequestIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/ImportSinglePaymentOrdersRequestIo.cs index f07e7d7..f048fcb 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/ImportSinglePaymentOrdersRequestIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/ImportSinglePaymentOrdersRequestIo.cs @@ -55,8 +55,6 @@ public override string SoapXml() public static class UseExtensions { - public static TY Use(this T t, Func tTy) => tTy(t); - public static string FormatXml(this string xml) { try diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeInterfaces.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeInterfaces.cs index d81a33a..938f5a3 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeInterfaces.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeInterfaces.cs @@ -26,16 +26,6 @@ public abstract record TransferTypeRecord public string? AdditionalDescription => TransferTypeRecordSpecific.AdditionalDescription; } -// public interface IDescription -// { -// public string? Description { get; } -// } - -// public interface IAdditionalDescription -// { -// public string? AdditionalDescription { get; } -// } - public interface IBeneficiaryName { public string BeneficiaryName { get; } diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeRecords.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeRecords.cs index 2890a0b..d0dd944 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeRecords.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/ImportSinglePaymentOrders/TransferTypeRecords.cs @@ -22,4 +22,4 @@ public record TransferToOtherBankNationalCurrencyPaymentOrderIo(BankAccountWithC public record TreasuryTransferPaymentOrderIo(long TreasuryCode) : TransferTypeRecord, ITreasury; [UsedImplicitly] -public record TransferToOwnAccountPaymentOrderIo(BankAccountWithCurrencyV RecipientAccountWithCurrency, string Description) : TransferTypeRecord, IRecipient, IBeneficiaryName, IDescription; \ No newline at end of file +public record TransferToOwnAccountPaymentOrderIo(BankAccountWithCurrencyV RecipientAccountWithCurrency) : TransferTypeRecord, IRecipient, IBeneficiaryName, IDescription; \ No newline at end of file diff --git a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs index 83851ac..757c4f1 100644 --- a/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs +++ b/AppifySheets.TBC.IntegrationService.Client/SoapInfrastructure/PasswordChangeRelated/ChangePasswordResponseIo.cs @@ -6,7 +6,8 @@ // } using System.Xml.Serialization; -using AppifySheets.TBC.IntegrationService.Client.SoapInfrastructure; + +namespace AppifySheets.TBC.IntegrationService.Client.SoapInfrastructure.PasswordChangeRelated; [XmlRoot(ElementName="ChangePasswordResponseIo")] public class ChangePasswordResponseIo : ISoapResponse { diff --git a/AppifySheets.TBC.IntegrationService.Client/TBC_Services/Extensions.cs b/AppifySheets.TBC.IntegrationService.Client/TBC_Services/Extensions.cs index fbdc3e6..49b8bd7 100644 --- a/AppifySheets.TBC.IntegrationService.Client/TBC_Services/Extensions.cs +++ b/AppifySheets.TBC.IntegrationService.Client/TBC_Services/Extensions.cs @@ -22,7 +22,7 @@ static object XmlDeserializeFromString(this string objectData, Type type) var serializer = new XmlSerializer(type); using TextReader reader = new StringReader(objectData); - var result = serializer.Deserialize(reader); + var result = serializer.Deserialize(reader)!; return result; }