Skip to content

Commit 4f546a6

Browse files
Shane32gfoidl
andauthored
Add Micro QR code support (#592)
* Split QRCodeGenerator further * update * update * update * update * update test * update * update * update * Separate GaloisField from CapacityTables * update * remove using * Progress * update format information writing for micro codes * Update * Update api approvals * update * progress * Fix ECC for M1 and M3 sizes * Update QRCoder/QRCodeGenerator/GaloisField.cs Co-authored-by: Günther Foidl <[email protected]> * update * update * update * Update QRCoder/QRCodeGenerator.cs Co-authored-by: Günther Foidl <[email protected]> * update * Update QRCoder/QRCodeGenerator.cs Co-authored-by: Günther Foidl <[email protected]> * Update QRCoder/QRCodeGenerator.cs Co-authored-by: Günther Foidl <[email protected]> * Update QRCoder/QRCodeGenerator.cs Co-authored-by: Günther Foidl <[email protected]> * update * update * update * update * update * Fix CI * update * a * a * update * Revert "update" This reverts commit 271c243. * Update --------- Co-authored-by: Günther Foidl <[email protected]>
1 parent 8048168 commit 4f546a6

File tree

20 files changed

+638
-108
lines changed

20 files changed

+638
-108
lines changed

.github/workflows/wf-build-release-ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
jobs:
88
build:
9-
runs-on: windows-2019
9+
runs-on: windows-latest
1010
env:
1111
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1212
steps:
@@ -33,17 +33,17 @@ jobs:
3333
uses: actions/upload-artifact@v4
3434
with:
3535
name: Compiled project
36-
path: D:\a\qrcoder\qrcoder
36+
path: ${{ github.workspace }}
3737

3838
test:
3939
needs: build
40-
runs-on: windows-2019
40+
runs-on: windows-latest
4141
steps:
4242
- name: Download artifacts
4343
uses: actions/download-artifact@v4
4444
with:
4545
name: Compiled project
46-
path: D:\a\qrcoder\qrcoder
46+
path: ${{ github.workspace }}
4747

4848
- name: Install additional .NET SDKs
4949
uses: actions/setup-dotnet@v4
@@ -139,15 +139,15 @@ jobs:
139139

140140
pack-push-ci:
141141
needs: test
142-
runs-on: windows-2019
142+
runs-on: windows-latest
143143
env:
144144
GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }}
145145
steps:
146146
- name: Download artifacts
147147
uses: actions/download-artifact@v4
148148
with:
149149
name: Compiled project
150-
path: D:\a\qrcoder\qrcoder
150+
path: ${{ github.workspace }}
151151

152152
- name: Install additional .NET SDKs
153153
uses: actions/setup-dotnet@v4
@@ -193,7 +193,7 @@ jobs:
193193
clean:
194194
needs: [build, test, pack-push-ci]
195195
if: always()
196-
runs-on: windows-2019
196+
runs-on: windows-latest
197197
steps:
198198
- name: Delete artifacts
199199
uses: GeekyEggo/delete-artifact@v5

.github/workflows/wf-build-release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
required: true
88
jobs:
99
build:
10-
runs-on: windows-2019
10+
runs-on: windows-latest
1111
env:
1212
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1313
steps:
@@ -34,17 +34,17 @@ jobs:
3434
uses: actions/upload-artifact@v4
3535
with:
3636
name: Compiled project
37-
path: D:\a\qrcoder\qrcoder
37+
path: ${{ github.workspace }}
3838

3939
test:
4040
needs: build
41-
runs-on: windows-2019
41+
runs-on: windows-latest
4242
steps:
4343
- name: Download artifacts
4444
uses: actions/download-artifact@v4
4545
with:
4646
name: Compiled project
47-
path: D:\a\qrcoder\qrcoder
47+
path: ${{ github.workspace }}
4848

4949
- name: Install additional .NET SDKs
5050
uses: actions/setup-dotnet@v4
@@ -139,15 +139,15 @@ jobs:
139139

140140
pack-push-release:
141141
needs: test
142-
runs-on: windows-2019
142+
runs-on: windows-latest
143143
env:
144144
GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }}
145145
steps:
146146
- name: Download artifacts
147147
uses: actions/download-artifact@v4
148148
with:
149149
name: Compiled project
150-
path: D:\a\qrcoder\qrcoder
150+
path: ${{ github.workspace }}
151151

152152
- name: Install additional .NET SDKs
153153
uses: actions/setup-dotnet@v4
@@ -187,7 +187,7 @@ jobs:
187187
clean:
188188
needs: [build, test, pack-push-release]
189189
if: always()
190-
runs-on: windows-2019
190+
runs-on: windows-latest
191191
steps:
192192
- name: Delete artifacts
193193
uses: GeekyEggo/delete-artifact@v5

.github/workflows/wf-build-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
jobs:
88
build:
9-
runs-on: windows-2019
9+
runs-on: windows-latest
1010
env:
1111
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1212
steps:
@@ -33,17 +33,17 @@ jobs:
3333
uses: actions/upload-artifact@v4
3434
with:
3535
name: Compiled project
36-
path: D:\a\qrcoder\qrcoder
36+
path: ${{ github.workspace }}
3737

3838
test:
3939
needs: build
40-
runs-on: windows-2019
40+
runs-on: windows-latest
4141
steps:
4242
- name: Download artifacts
4343
uses: actions/download-artifact@v4
4444
with:
4545
name: Compiled project
46-
path: D:\a\qrcoder\qrcoder
46+
path: ${{ github.workspace }}
4747

4848
- name: Install additional .NET SDKs
4949
uses: actions/setup-dotnet@v4
@@ -98,7 +98,7 @@ jobs:
9898
clean:
9999
needs: [build, test]
100100
if: always()
101-
runs-on: windows-2019
101+
runs-on: windows-latest
102102
steps:
103103
- name: Delete artifacts
104104
uses: GeekyEggo/delete-artifact@v5

.github/workflows/wf-verify-formatting.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ on:
77

88
jobs:
99
format:
10-
runs-on: windows-2019
10+
runs-on: ubuntu-latest
11+
env:
12+
EnableWindowsTargeting: true
1113
steps:
1214
- uses: actions/checkout@v4
1315
name: Checkout Code
1416

1517
- name: Install additional .NET SDKs
1618
uses: actions/setup-dotnet@v4
1719
with:
18-
dotnet-version: |
19-
2.0.x
20-
5.0.x
21-
6.0.x
22-
8.0.x
20+
dotnet-version: 8.0.x
2321

2422
- name: Restore NuGet Packages
2523
run: dotnet restore

QRCoder/PayloadGenerator/BezahlCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
143143
}
144144

145145
_authority = authority;
146-
146+
147147
var oldWayFilled = (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(bnc));
148148
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic));
149149

@@ -163,7 +163,7 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
163163
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment || authority == AuthorityType.contact || (authority == AuthorityType.contact_v2 && oldWayFilled))
164164
{
165165
#pragma warning restore CS0612
166-
166+
167167
if (!Regex.IsMatch(account.Replace(" ", ""), @"^[0-9]{1,9}$"))
168168
throw new BezahlCodeException("The account entered isn't valid.");
169169
_account = account.Replace(" ", "").ToUpper();

QRCoder/QRCodeData.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,12 @@ public void SaveRawData(string filePath, Compression compressMode)
193193
/// <summary>
194194
/// Gets the number of modules per side from the specified version.
195195
/// </summary>
196-
/// <param name="version">The version of the QR code.</param>
196+
/// <param name="version">The version of the QR code (1 to 40, or -1 to -4 for Micro QR codes).</param>
197197
/// <returns>Returns the number of modules per side.</returns>
198198
private static int ModulesPerSideFromVersion(int version)
199-
=> 21 + (version - 1) * 4;
199+
=> version > 0
200+
? 21 + (version - 1) * 4
201+
: 11 + (-version - 1) * 2;
200202

201203
/// <summary>
202204
/// Releases all resources used by the <see cref="QRCodeData"/>.

0 commit comments

Comments
 (0)