From 274bb4be19786c97b235a1c270929fd76849ef42 Mon Sep 17 00:00:00 2001
From: Martijn Bodeman <11424653+skwasjer@users.noreply.github.com>
Date: Fri, 4 Oct 2024 01:04:11 +0200
Subject: [PATCH] chore: make SwiftPattern fully internal, instead of public in
DEBUG. Instead expose the parsed pattern via the import record/DTO. (#213)
---
src/IbanNet.CodeGen/IbanNet.CodeGen.csproj | 4 ++++
src/IbanNet.CodeGen/Swift/SwiftCsvRecord.cs | 4 ++++
src/IbanNet/Properties/AssemblyInfoAttributes.cs | 3 +++
src/IbanNet/Registry/Swift/SwiftPattern.cs | 7 +------
src/IbanNet/Registry/Swift/SwiftRegistryProvider.tt | 2 +-
5 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/IbanNet.CodeGen/IbanNet.CodeGen.csproj b/src/IbanNet.CodeGen/IbanNet.CodeGen.csproj
index 938f975f..8ba33aa2 100644
--- a/src/IbanNet.CodeGen/IbanNet.CodeGen.csproj
+++ b/src/IbanNet.CodeGen/IbanNet.CodeGen.csproj
@@ -12,4 +12,8 @@
+
+
+
+
diff --git a/src/IbanNet.CodeGen/Swift/SwiftCsvRecord.cs b/src/IbanNet.CodeGen/Swift/SwiftCsvRecord.cs
index 9f8e235a..39f0a3a9 100644
--- a/src/IbanNet.CodeGen/Swift/SwiftCsvRecord.cs
+++ b/src/IbanNet.CodeGen/Swift/SwiftCsvRecord.cs
@@ -1,6 +1,8 @@
using System.Globalization;
using CsvHelper.Configuration.Attributes;
using IbanNet.CodeGen.Swift.Converters;
+using IbanNet.Registry.Patterns;
+using IbanNet.Registry.Swift;
namespace IbanNet.CodeGen.Swift;
@@ -78,6 +80,8 @@ public record IbanCsvData
[Name("IBAN structure")]
public string Pattern { get; set; } = default!;
+ public Pattern SwiftPattern => new SwiftPattern(Pattern);
+
[Name("IBAN length")]
public int Length { get; set; }
diff --git a/src/IbanNet/Properties/AssemblyInfoAttributes.cs b/src/IbanNet/Properties/AssemblyInfoAttributes.cs
index 863c88cd..d1afbe3a 100644
--- a/src/IbanNet/Properties/AssemblyInfoAttributes.cs
+++ b/src/IbanNet/Properties/AssemblyInfoAttributes.cs
@@ -3,5 +3,8 @@
[assembly: InternalsVisibleTo("IbanNet.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
+#if DEBUG
+[assembly: InternalsVisibleTo("IbanNet.CodeGen")]
+#endif
[assembly: NeutralResourcesLanguage("en")]
[assembly: CLSCompliant(true)]
diff --git a/src/IbanNet/Registry/Swift/SwiftPattern.cs b/src/IbanNet/Registry/Swift/SwiftPattern.cs
index e948719a..b6ae324d 100644
--- a/src/IbanNet/Registry/Swift/SwiftPattern.cs
+++ b/src/IbanNet/Registry/Swift/SwiftPattern.cs
@@ -3,12 +3,7 @@
namespace IbanNet.Registry.Swift;
///
-#if DEBUG
-public
-#else
-internal
-#endif
- class SwiftPattern : Pattern
+internal class SwiftPattern : Pattern
{
private static readonly SwiftPatternTokenizer Tokenizer = new();
private string? _pattern;
diff --git a/src/IbanNet/Registry/Swift/SwiftRegistryProvider.tt b/src/IbanNet/Registry/Swift/SwiftRegistryProvider.tt
index dfb22a4c..ab684294 100644
--- a/src/IbanNet/Registry/Swift/SwiftRegistryProvider.tt
+++ b/src/IbanNet/Registry/Swift/SwiftRegistryProvider.tt
@@ -152,7 +152,7 @@ public class SwiftRegistryProvider : IIbanRegistryProvider
<#
foreach (var record in records)
{
- var pattern = new SwiftPattern(record.Iban.Pattern);
+ var pattern = record.Iban.SwiftPattern;
#>
[GeneratedCode("SwiftRegistryProviderT4", "1.1-<#= registryReleaseVersion #>")]