Skip to content

Address Trimmer Warnings in RussiaPaymentOrder Payload #538

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

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 22 additions & 3 deletions QRCoder/PayloadGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System.Linq;
using System.Globalization;
using System.Text;
Expand Down Expand Up @@ -2479,6 +2482,12 @@ public class RussiaPaymentOrder : Payload
private CharacterSets characterSet;
private MandatoryFields mFields;
private OptionalFields oFields;
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)]
private Type _mFields => typeof(MandatoryFields);
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
private Type _oFields => typeof(OptionalFields);
#endif
private string separator = "|";

private RussiaPaymentOrder()
Expand Down Expand Up @@ -2605,7 +2614,12 @@ private List<string> GetOptionalFieldsAsList()
})
.ToList();
#else
return oFields.GetType().GetProperties()
#if NET6_0_OR_GREATER
return _oFields
#else
return oFields.GetType()
#endif
.GetProperties()
.Where(field => field.GetValue(oFields, null) != null)
.Select(field => {
var objValue = field.GetValue(oFields, null);
Expand All @@ -2621,7 +2635,7 @@ private List<string> GetOptionalFieldsAsList()
/// Takes all mandatory fields that are not null and returns their string represantion
/// </summary>
/// <returns>A List of strings</returns>
private List<string> GetMandatoryFieldsAsList()
private List<string> GetMandatoryFieldsAsList()
{
#if NETSTANDARD1_3
return mFields.GetType().GetRuntimeFields()
Expand All @@ -2633,7 +2647,12 @@ private List<string> GetMandatoryFieldsAsList()
})
.ToList();
#else
return mFields.GetType().GetFields()
#if NET6_0_OR_GREATER
return _mFields
#else
return mFields.GetType()
#endif
.GetFields()
.Where(field => field.GetValue(mFields) != null)
.Select(field => {
var objValue = field.GetValue(mFields);
Expand Down