Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ If you need to encode international characters (e.g., Chinese, Japanese, Arabic,
```

The `CharacterSet` property is not set by default, which lets the barcode encoder use its native encoding. This avoids adding ECI (Extended Channel Interpretation) headers that some barcode scanners may not support. Common values include "UTF-8", "ISO-8859-1", "Shift_JIS", etc., depending on your barcode format requirements.

## Trimming and AOT

ZXing.Net.Maui and ZXing.Net.Maui.Controls declare AOT compatibility and are validated with the .NET trim/AOT analyzers. Normal usage through `UseBarcodeReader()` should not require linker or trimmer exceptions.

If you register a custom barcode reader with `UseBarcodeReader<TBarcodeReader>()`, make sure the implementation has public constructors that `Microsoft.Extensions.DependencyInjection` can activate.
4 changes: 3 additions & 1 deletion ZXing.Net.MAUI.Controls/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Microsoft.Maui;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -48,7 +49,8 @@ public static MauiAppBuilder UseBarcodeReader(this MauiAppBuilder builder)
return builder;
}

public static MauiAppBuilder UseBarcodeReader<TBarcodeReader>(this MauiAppBuilder builder) where TBarcodeReader : class, Readers.IBarcodeReader
public static MauiAppBuilder UseBarcodeReader<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TBarcodeReader>(this MauiAppBuilder builder)
where TBarcodeReader : class, Readers.IBarcodeReader
{
builder.ConfigureMauiHandlers(handlers =>
{
Expand Down
4 changes: 3 additions & 1 deletion ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<DebugType>portable</DebugType>
<OutputType>Library</OutputType>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ZXing.Net" Version="0.16.11" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion ZXing.Net.MAUI/ZXing.Net.MAUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<DebugType>portable</DebugType>
<IsPackable>true</IsPackable>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.4.2.3" />
<PackageReference Include="Xamarin.AndroidX.Camera.Lifecycle" Version="1.4.2.3" />
Expand Down
Loading