Skip to content

Commit 3a845e6

Browse files
dannyhaakclaude
andcommitted
fix: CI workflow fixes and AOT-safe JSON serialization
- Android: install full MAUI workload (not just maui-android) for multi-target csproj dependency resolution - PyPI: override TargetFrameworks to net8.0 so MAUI workloads are not needed on ubuntu CI runner - pub.dev: remove iOS simulator xcframework slice before publishing to stay under 100 MB package size limit - Replace reflection-based JsonSerializer calls with source-generated JsonSerializerContext to eliminate IL2026 trimming warnings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2342b42 commit 3a845e6

File tree

7 files changed

+70
-18
lines changed

7 files changed

+70
-18
lines changed

.github/workflows/release-maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
distribution: temurin
3030
java-version: 17
3131

32-
- name: Install Android workload
33-
run: dotnet workload install maui-android
32+
- name: Install MAUI workloads
33+
run: dotnet workload install maui
3434

3535
- name: Build Android SDK
3636
run: |

.github/workflows/release-pub.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,41 @@ jobs:
2525
cd sdk/flutter/tag_data_translation
2626
sed -i "s/^version: .*/version: ${VERSION}/" pubspec.yaml
2727
28+
# pub.dev has a 100 MB package size limit. The iOS xcframework includes both
29+
# device (arm64) and simulator (arm64-simulator) slices at ~48 MB each, pushing
30+
# the total over 100 MB. Remove the simulator slice before publishing.
31+
- name: Reduce package size
32+
run: |
33+
cd sdk/flutter/tag_data_translation
34+
rm -rf ios/Frameworks/TagDataTranslation.xcframework/ios-arm64-simulator
35+
cat > ios/Frameworks/TagDataTranslation.xcframework/Info.plist << 'PLIST'
36+
<?xml version="1.0" encoding="UTF-8"?>
37+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
38+
<plist version="1.0">
39+
<dict>
40+
<key>AvailableLibraries</key>
41+
<array>
42+
<dict>
43+
<key>HeadersPath</key>
44+
<string>Headers</string>
45+
<key>LibraryIdentifier</key>
46+
<string>ios-arm64</string>
47+
<key>LibraryPath</key>
48+
<string>TagDataTranslation.iOS.a</string>
49+
<key>SupportedArchitectures</key>
50+
<array><string>arm64</string></array>
51+
<key>SupportedPlatform</key>
52+
<string>ios</string>
53+
</dict>
54+
</array>
55+
<key>CFBundlePackageType</key>
56+
<string>XFWK</string>
57+
<key>XCFrameworkFormatVersion</key>
58+
<string>1.0</string>
59+
</dict>
60+
</plist>
61+
PLIST
62+
2863
- name: Get dependencies
2964
run: cd sdk/flutter/tag_data_translation && flutter pub get
3065

pip/scripts/build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def main() -> None:
2525
"dotnet", "build", str(CSPROJ),
2626
"-c", "Release",
2727
"-f", FRAMEWORK,
28+
# override TargetFrameworks to avoid needing MAUI workloads on CI
29+
f"/p:TargetFrameworks={FRAMEWORK}",
2830
],
2931
check=True,
3032
)

sdk/flutter/tag_data_translation/.pubignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ coverage/
1818
# git
1919
.git/
2020
.gitkeep
21+
22+
# iOS simulator framework — saves ~48 MB to stay under pub.dev's 100 MB limit.
23+
# Simulator builds use the device .a via Rosetta or require building from source.
24+
ios/Frameworks/TagDataTranslation.xcframework/ios-arm64-simulator/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace TagDataTranslation.Models;
5+
6+
[JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)]
7+
[JsonSerializable(typeof(TdtRoot))]
8+
[JsonSerializable(typeof(Dictionary<string, string>))]
9+
internal partial class TdtJsonContext : JsonSerializerContext
10+
{
11+
}

src/TagDataTranslation/TDTEngine.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ private static Regex GetCachedRegex(string pattern)
5151
private EncodedAICodec encodedAICodec = null!;
5252
private VariableLengthFieldCodec variableLengthFieldCodec = null!;
5353

54-
// JSON serialization options
55-
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions
56-
{
57-
PropertyNameCaseInsensitive = true
58-
};
5954

6055
// static compiled regex for grammar string parsing
6156
private static readonly Regex GrammarRegex = new(@"\'.*?\'|\s*[\w]+\s*", RegexOptions.Compiled);
@@ -131,7 +126,7 @@ public TDTEngine()
131126
if (stream == null) continue;
132127
try
133128
{
134-
var root = JsonSerializer.Deserialize<TdtRoot>(stream, JsonOptions);
129+
var root = JsonSerializer.Deserialize(stream, TdtJsonContext.Default.TdtRoot);
135130
if (root?.EpcTagDataTranslation?.Scheme != null)
136131
{
137132
epcTagDataTranslations.Add(root.EpcTagDataTranslation);
@@ -1504,7 +1499,7 @@ private string FormatAsAiJson(Dictionary<string, string> parameterDictionary, Op
15041499
}
15051500
}
15061501

1507-
return JsonSerializer.Serialize(jsonObject);
1502+
return JsonSerializer.Serialize(jsonObject, TdtJsonContext.Default.DictionaryStringString);
15081503
}
15091504

15101505
#endregion

src/TagDataTranslation/Tables/TableLoader.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ namespace TagDataTranslation.Tables;
1111
/// <summary>
1212
/// Provides static methods to load TDT 2.2 tables from JSON streams.
1313
/// </summary>
14-
public static class TableLoader
14+
public static partial class TableLoader
1515
{
16-
private static readonly JsonSerializerOptions JsonOptions = new()
17-
{
18-
PropertyNameCaseInsensitive = true
19-
};
2016

2117
#region JSON Models for Deserialization
2218

@@ -170,14 +166,23 @@ private class TableBRow
170166

171167
#endregion
172168

169+
[JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)]
170+
[JsonSerializable(typeof(TableJsonRoot<TableFRow>))]
171+
[JsonSerializable(typeof(TableJsonRoot<TableKRow>))]
172+
[JsonSerializable(typeof(TableJsonRoot<TableERow>))]
173+
[JsonSerializable(typeof(TableJsonRoot<TableBRow>))]
174+
private partial class TableJsonContext : JsonSerializerContext
175+
{
176+
}
177+
173178
/// <summary>
174179
/// Loads Table F from a JSON stream.
175180
/// </summary>
176181
/// <param name="stream">The JSON stream to read from.</param>
177182
/// <returns>The loaded TableF instance.</returns>
178183
public static TableF LoadTableF(Stream stream)
179184
{
180-
var root = JsonSerializer.Deserialize<TableJsonRoot<TableFRow>>(stream, JsonOptions)
185+
var root = JsonSerializer.Deserialize(stream, TableJsonContext.Default.TableJsonRootTableFRow)
181186
?? throw new InvalidOperationException("Failed to deserialize Table F JSON");
182187

183188
var table = new TableF();
@@ -221,7 +226,7 @@ public static TableF LoadTableF(Stream stream)
221226
/// <returns>The loaded TableK instance.</returns>
222227
public static TableK LoadTableK(Stream stream)
223228
{
224-
var root = JsonSerializer.Deserialize<TableJsonRoot<TableKRow>>(stream, JsonOptions)
229+
var root = JsonSerializer.Deserialize(stream, TableJsonContext.Default.TableJsonRootTableKRow)
225230
?? throw new InvalidOperationException("Failed to deserialize Table K JSON");
226231

227232
var table = new TableK();
@@ -253,7 +258,7 @@ public static TableK LoadTableK(Stream stream)
253258
/// <returns>The loaded TableE instance.</returns>
254259
public static TableE LoadTableE(Stream stream)
255260
{
256-
var root = JsonSerializer.Deserialize<TableJsonRoot<TableERow>>(stream, JsonOptions)
261+
var root = JsonSerializer.Deserialize(stream, TableJsonContext.Default.TableJsonRootTableERow)
257262
?? throw new InvalidOperationException("Failed to deserialize Table E JSON");
258263

259264
var table = new TableE();
@@ -287,7 +292,7 @@ public static TableE LoadTableE(Stream stream)
287292
/// <returns>The loaded TableB instance.</returns>
288293
public static TableB LoadTableB(Stream stream)
289294
{
290-
var root = JsonSerializer.Deserialize<TableJsonRoot<TableBRow>>(stream, JsonOptions)
295+
var root = JsonSerializer.Deserialize(stream, TableJsonContext.Default.TableJsonRootTableBRow)
291296
?? throw new InvalidOperationException("Failed to deserialize Table B JSON");
292297

293298
var table = new TableB();

0 commit comments

Comments
 (0)