diff --git a/.agents/references/reviews/aot-package-compat.md b/.agents/references/reviews/aot-package-compat.md index 7e21792..609db39 100644 --- a/.agents/references/reviews/aot-package-compat.md +++ b/.agents/references/reviews/aot-package-compat.md @@ -2,8 +2,9 @@ Use this whenever a change touches resource lookup, culture fallback, satellite discovery, the source generator's output, or the analyzer and `buildTransitive` wiring the packages carry. This is a -**standing** checklist: `ResXLocalization.Avalonia` and `ResXLocalization.Core` advertise Native AOT -support, and everything here exists to keep it from regressing. +**standing** checklist: `ResXLocalization.Core`, `ResXLocalization.Avalonia` and +`ResXLocalization.MessageFormat` advertise Native AOT support, and everything here exists to keep it +from regressing. Read [docs/guides/native-aot.md](../../../docs/guides/native-aot.md) before reviewing. @@ -13,11 +14,12 @@ This is a **review**: report findings, cite file and line, do not edit files. Trimming damage does not announce itself. A resource that is no longer found, a satellite assembly that is no longer loaded, a typed key whose `ResourceManager` was trimmed away โ€” each produces a -binary that builds, starts, and answers with the `!key!` sentinel or the wrong language. Nothing is +binary that builds, starts, and answers with the `!key!` failure text or the wrong language. Nothing is trimmed on the just-in-time compiler, so **every test suite in this repository passes throughout**. -The only check that can see it is `scripts/verify-package-aot.ps1`, which publishes a package-only -consumer natively and runs it. A green test run is not evidence here. Neither is a native binary that +The only check that can see it is `scripts/verify-package-aot.ps1`, which publishes two package-only +consumers natively and runs them: `AvaloniaConsumer`, and `MessageFormatConsumer` for the ICU formatter +of `ResXLocalization.MessageFormat`. A green test run is not evidence here. Neither is a native binary that exists: the gate runs it and asserts exact strings for exactly this reason. ## Blocking findings @@ -31,9 +33,16 @@ exists: the gate runs it and asserts exact strings for exactly this reason. the requirement to the caller. But adding either to a public member is its own blocking finding โ€” it changes what a consumer sees when they publish, and the packages promise they see nothing. -- **`IsAotCompatible` removed from `ResXLocalization.Core` or `ResXLocalization.Avalonia`**, or added - to `ResXLocalization.WPF`. The first two set it through `src/Directory.Build.props`; WPF is - excluded there deliberately, because WPF has no Native AOT. +- **`IsAotCompatible` removed from `ResXLocalization.Core`, `ResXLocalization.Avalonia` or + `ResXLocalization.MessageFormat`**, or added to `ResXLocalization.WPF`. The first three set it + through `src/Directory.Build.props`; WPF is excluded there deliberately, because WPF has no Native + AOT. + +- **A call to an `object args` overload of the `MessageFormat` library** in + `src/ResXLocalization.MessageFormat` - the extension `MessageFormatterExtensions.FormatMessage` or the + static `MessageFormatter.Format(string, object, CultureInfo?)`. Both read properties by reflection, + carry `[RequiresUnreferencedCode]` and lose every argument in a Native AOT binary. The package calls + only the `IReadOnlyDictionary` overload of `FormatMessage`. - **A new reflection call** โ€” `Type.GetType`, `Assembly.Load`, `Activator.CreateInstance`, `GetMethod`, `GetProperty`, `MakeGenericType` โ€” reachable from a public entry point without a @@ -42,8 +51,9 @@ exists: the gate runs it and asserts exact strings for exactly this reason. reflection site is a change of kind rather than of degree. - **Anything that makes a satellite assembly optional.** The German satellite is what the AOT gate - asserts on: a change that stops the consumer producing `de/AvaloniaConsumer.resources.dll`, or - stops the library finding it, is the exact failure this gate exists for. + asserts on: a change that stops a consumer producing `de/AvaloniaConsumer.resources.dll` or + `de/MessageFormatConsumer.resources.dll`, or stops the library finding it, is the exact failure this + gate exists for. ## The generator's output @@ -106,8 +116,8 @@ check would have caught it. Where the answer needs a build, a pack or the AOT ga name the command: ```text -pwsh -File scripts/verify-package-aot.ps1 -Pack # both frameworks, from a fresh pack -pwsh -File scripts/verify-package-aot.ps1 -Framework net8.0 # the LTS floor alone +pwsh -File scripts/verify-package-aot.ps1 -Pack # both consumers on net10.0, from a fresh pack +pwsh -File scripts/verify-package-aot.ps1 -Framework net8.0 # both consumers on the LTS floor pwsh -File scripts/pre-release-gate.ps1 -SkipNativeAot -SkipDocumentation # every consumer, pinned SDK and .NET 8 SDK ``` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9165a08..1b8898d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ env: DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_NOLOGO: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + MESSAGEFORMAT_CONSUMER_PROJECT: tests/package-consumption/MessageFormatConsumer/MessageFormatConsumer.csproj NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_CONFIG: NuGet.config PACKAGE_OUTPUT: artifacts/packages @@ -414,6 +415,10 @@ jobs: working-directory: ${{ env.CONSUMER_DIRECTORY }} run: dotnet run --project AvaloniaConsumer/AvaloniaConsumer.csproj --framework net8.0 -p:TargetFrameworks=net8.0 --configuration ${{ env.CONFIGURATION }} -p:ResXLocalizationVersion=${{ needs.package-and-docs.outputs.version }} + - name: Run MessageFormat package consumer (net8.0 SDK) + working-directory: ${{ env.CONSUMER_DIRECTORY }} + run: dotnet run --project MessageFormatConsumer/MessageFormatConsumer.csproj --framework net8.0 -p:TargetFrameworks=net8.0 --configuration ${{ env.CONFIGURATION }} -p:ResXLocalizationVersion=${{ needs.package-and-docs.outputs.version }} + - name: Run WPF package consumer (net8.0 SDK) if: runner.os == 'Windows' working-directory: ${{ env.CONSUMER_DIRECTORY }} @@ -438,10 +443,10 @@ jobs: shell: bash run: rm -f "${CONSUMER_DIRECTORY}/global.json" - # The packed-package Native AOT gate. It publishes the Avalonia consumer with PublishAot, requires zero - # IL2xxx/IL3xxx diagnostics, and RUNS the native binary - a file that exists proves nothing, because - # everything trimming can break (a satellite that is no longer loaded, a resource name that no longer - # resolves) produces a binary that starts and answers wrongly. + # The packed-package Native AOT gate. It publishes AvaloniaConsumer and MessageFormatConsumer with + # PublishAot, requires zero IL2xxx/IL3xxx diagnostics, and RUNS each native binary - a file that exists + # proves nothing, because everything trimming can break (a satellite that is no longer loaded, a + # resource name that no longer resolves) produces a binary that starts and answers wrongly. # # Three runs. The trimming behaviour under test belongs to the ILC compiler and does not vary by host, # so net8.0 - the LTS floor the packages promise - is exercised on Linux, and net10.0 on both. @@ -529,7 +534,8 @@ jobs: path: ${{ env.PACKAGE_OUTPUT }} # The script is the gate, not this job: it validates the artifact set from each nuspec, isolates the - # consumer package cache, publishes, requires zero IL diagnostics, and runs the binary. + # consumer package cache, then publishes both consumers, requires zero IL diagnostics, and runs each + # binary. - name: Native AOT gate run: pwsh -NoProfile -NonInteractive -File scripts/verify-package-aot.ps1 -Framework ${{ matrix.framework }} -Runtime ${{ matrix.runtime }} -PackageVersion ${{ needs.package-and-docs.outputs.version }} -Configuration ${{ env.CONFIGURATION }} @@ -618,7 +624,7 @@ jobs: run: | tag_version="${GITHUB_REF_NAME#v}" status=0 - for id in ResXLocalization.Core ResXLocalization.Avalonia ResXLocalization.WPF; do + for id in ResXLocalization.Core ResXLocalization.Avalonia ResXLocalization.MessageFormat ResXLocalization.WPF; do if [[ ! -f "${PACKAGE_OUTPUT}/${id}.${tag_version}.nupkg" ]]; then echo "::error title=Tag/version mismatch::Tag ${GITHUB_REF_NAME} expects ${id}.${tag_version}.nupkg, but the build produced:" ls -1 "${PACKAGE_OUTPUT}" diff --git a/AGENTS.md b/AGENTS.md index 6d01ef9..a0d3598 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,7 +22,7 @@ Two things separate it from plain `.resx`: Around those: three lookup modes (typed, scoped, and search-all across registered resource managers) over .NET's own culture fallback chain, enum localization by naming convention, format arguments in code and in -XAML, a `!key!` sentinel plus a `TranslationNotFound` event for missing translations, and Native AOT and +XAML, a `!key!` failure text plus a `TranslationNotFound` event for missing translations, and Native AOT and trimming support on the Avalonia side (WPF supports neither). [`README.md`](README.md) is the user-facing version of the same story, with the quick start and the examples. diff --git a/PACKAGE_README.md b/PACKAGE_README.md index dfab3e0..2061dbd 100644 --- a/PACKAGE_README.md +++ b/PACKAGE_README.md @@ -15,7 +15,7 @@ you keep the `.resx` files and editors you already use, and get **compile-checke - ๐Ÿ—‚๏ธ **First-class multiple `.resx` support** - look up by typed key, scope to one file, or search across all registered files. - ๐Ÿ”ค **Enum localization built in** - localize enum members by naming convention. - ๐Ÿงฎ **Format arguments** - `Get(key, argsโ€ฆ)` formats in the active culture; in XAML, give `{l:Localize}` `` children with constant or bound values. -- ๐Ÿฉบ **Missing-translation diagnostics** - a visible, configurable `!key!` sentinel plus a `TranslationNotFound` event. +- ๐Ÿฉบ **Missing-translation diagnostics** - a visible, configurable `!key!` failure text plus a `TranslationNotFound` event. - ๐ŸŒ **Language-picker ready** - `GetAvailableCultures()` discovers the cultures your app actually ships. - ๐Ÿš€ **Native AOT & trim clean** (Avalonia package) - no reflection over your resources. diff --git a/README.md b/README.md index 1395d4f..a52fc97 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Localizer.Current.CurrentCulture = new CultureInfo("de"); - ๐Ÿ—‚๏ธ **First-class multiple `.resx`** - look up by **typed key**, **scope** to one file, or **search across all** registered files in a defined order. - ๐Ÿ”ค **Enum localization built in** - localize enum members by naming convention, in item templates and as bound values. - ๐Ÿงฎ **Format arguments** - `Get(key, argsโ€ฆ)` formats the translation in the active culture; in XAML, give `{l:Localize}` `` children with constant or bound values. -- ๐Ÿฉบ **Missing-translation diagnostics** - a visible `!key!` sentinel (configurable) plus a `TranslationNotFound` event for logging and coverage reports. +- ๐Ÿฉบ **Missing-translation diagnostics** - a visible `!key!` failure text (configurable) plus a `TranslationNotFound` event for logging and coverage reports. - ๐ŸŒ **Language-picker ready** - `GetAvailableCultures()` discovers the cultures your app actually ships. - ๐Ÿงฉ **MVVM-friendly** - an injectable `ILocalizer` service with `INotifyPropertyChanged`, markup extensions for XAML, and a clean code-behind API. - ๐Ÿชถ **Leak-safe** - discarded controls stay collectable (Avalonia uses weak events; WPF binds to the singleton through WPF's own weak binding-target references). @@ -176,7 +176,7 @@ public partial class App : Application Registration is only needed for **search-all** lookups; typed and scoped lookups need no registration. > [!TIP] -> In Avalonia, put the registration (and the initial `CurrentCulture`) inside **`BuildAvaloniaApp()`** rather than `Main`. `BuildAvaloniaApp` runs at runtime *and* under the XAML previewer, so search-all lookups like `{l:Localize Greeting}` resolve at design time too instead of showing the `!Greeting!` sentinel. +> In Avalonia, put the registration (and the initial `CurrentCulture`) inside **`BuildAvaloniaApp()`** rather than `Main`. `BuildAvaloniaApp` runs at runtime *and* under the XAML previewer, so search-all lookups like `{l:Localize Greeting}` resolve at design time too instead of showing the `!Greeting!` failure text. ### 4. Use it in XAML @@ -232,7 +232,7 @@ Localizer.Current.Get("Greeting"); // search-al ``` Fallback is .NET's own: a missing `de-DE` entry falls back to `de`, then to the neutral resources. A -key that cannot be resolved anywhere renders the configurable `!key!` sentinel and raises +key that cannot be resolved anywhere renders the configurable `!key!` failure text and raises `TranslationNotFound`. Because fallback runs first, a key that resolves from a parent or neutral value is not reported as missing. diff --git a/docs/guides/native-aot.md b/docs/guides/native-aot.md index a2245b2..07566d0 100644 --- a/docs/guides/native-aot.md +++ b/docs/guides/native-aot.md @@ -1,8 +1,8 @@ # Native AOT and trimming -`ResXLocalization.Avalonia` and `ResXLocalization.Core` publish with `PublishAot=true` and produce no -IL2xxx or IL3xxx diagnostic โ€” not from the library, not from a package in the closure, and not at -your own call sites. There is no `[RequiresUnreferencedCode]` or `[RequiresDynamicCode]` on any +`ResXLocalization.Avalonia`, `ResXLocalization.Core` and `ResXLocalization.MessageFormat` publish with +`PublishAot=true` and produce no IL2xxx or IL3xxx diagnostic โ€” not from the library, not from a package +in the closure, and not at your own call sites. There is no `[RequiresUnreferencedCode]` or `[RequiresDynamicCode]` on any public member, so nothing about a trimmed publish is a warning you have to read and dismiss. One annotation reaches your code: `MessageArguments.FromObject` reads the public properties of `T`, @@ -41,6 +41,24 @@ Two more are worth setting for an Avalonia application in general: ``` +Format arguments in XAML are trim safe when their bindings are compiled bindings: in Avalonia, +`Value="{Binding ...}"` of an `` is a compiled binding under +`AvaloniaUseCompiledBindingsByDefault` or `x:CompileBindings="True"`, and a reflection binding +otherwise. See [Dynamic format arguments](format-arguments.md#worth-knowing). + +## ICU MessageFormat + +The opt-in package `ResXLocalization.MessageFormat` adds about 160 KB to a Native AOT binary, the +`MessageFormat` library included. It produces no IL diagnostic on `net8.0` or `net10.0`, because it +calls only the `IReadOnlyDictionary` overload of the library's `FormatMessage`; the library's overloads +that take an `object` read the properties of that object by reflection and are not called. See +[ICU MessageFormat](message-format.md). + +`InvariantGlobalization=true` is often recommended for a small Native AOT binary, but it leaves a +localized application with the invariant culture only โ€” with `PredefinedCulturesOnly=false` as well, +with named cultures whose numbers and dates format invariantly. See +[Globalization-invariant mode](message-format.md#globalization-invariant-mode). + ## Publishing ```shell @@ -58,14 +76,15 @@ longer loaded, a typed key whose resource manager was trimmed away โ€” each of t that builds, starts, and answers wrongly. Nothing is trimmed on the just-in-time compiler, so a test suite passes throughout. -This repository's own gate therefore publishes a package-only consumer natively and **runs** it, -asserting exact strings before and after a culture change, through the typed, scoped and search-all -lookups, the enum convention, composite formatting, named arguments built by reflection with -`MessageArguments.FromObject`, and the fallback to the neutral culture. See -`scripts/verify-package-aot.ps1`. A check that only asserts the executable exists proves that the +This repository's own gate therefore publishes two package-only consumers natively and **runs** them, +asserting exact strings before and after a culture change. The first covers the typed, scoped and +search-all lookups, the enum convention, composite formatting, named arguments built by reflection with +`MessageArguments.FromObject`, and the fallback to the neutral culture. The second covers the ICU +formatter: `plural` patterns with a named argument from a compiled binding, in code and in XAML, and +the invariant culture formatted with English plural rules. See `scripts/verify-package-aot.ps1`. A check that only asserts the executable exists proves that the linker ran, and nothing else. -## If a lookup returns the sentinel only after publishing +## If a lookup returns the failure text only after publishing In order of likelihood: diff --git a/scripts/pre-commit-gate.ps1 b/scripts/pre-commit-gate.ps1 index c70e371..6311cca 100644 --- a/scripts/pre-commit-gate.ps1 +++ b/scripts/pre-commit-gate.ps1 @@ -30,7 +30,8 @@ the way a stranger would, which a project-referenced test cannot. Run: pwsh -File scripts/pre-release-gate.ps1 -SkipNativeAot -SkipDocumentation which packs and then runs all of them on the pinned SDK, on both of - AvaloniaConsumer's target frameworks, and again on the .NET 8 SDK. + the target frameworks of AvaloniaConsumer and MessageFormatConsumer, + and again on the .NET 8 SDK. .PARAMETER Fix Apply style, formatting and member ordering to the working tree before the checks, instead of only diff --git a/scripts/pre-release-gate.ps1 b/scripts/pre-release-gate.ps1 index f1d8be8..dac5edc 100644 --- a/scripts/pre-release-gate.ps1 +++ b/scripts/pre-release-gate.ps1 @@ -585,12 +585,14 @@ Invoke-Step 'Package consumers' { return } - # AvaloniaConsumer targets net8.0 and net10.0, and `dotnet run` runs a project with several target - # frameworks only when one is named, so the consumer runs once per framework with `--framework`. That - # way both of the packages' target frameworks are exercised. + # AvaloniaConsumer and MessageFormatConsumer target net8.0 and net10.0, and `dotnet run` runs a project + # with several target frameworks only when one is named, so each consumer runs once per framework with + # `--framework`. That way both of the packages' target frameworks are exercised. $consumers = @( @{ Name = 'AvaloniaConsumer'; Arguments = @('--framework', 'net8.0') } @{ Name = 'AvaloniaConsumer'; Arguments = @('--framework', 'net10.0') } + @{ Name = 'MessageFormatConsumer'; Arguments = @('--framework', 'net8.0') } + @{ Name = 'MessageFormatConsumer'; Arguments = @('--framework', 'net10.0') } ) if ($onWindows) @@ -659,7 +661,10 @@ Invoke-Step 'Package consumers (.NET 8 SDK)' { # -p:TargetFrameworks as well as --framework: restore evaluates every entry in TargetFrameworks, and # an 8.0 SDK cannot evaluate net10.0 (NETSDK1045). - $consumers = @(@{ Name = 'AvaloniaConsumer'; Arguments = @('--framework', 'net8.0', '-p:TargetFrameworks=net8.0') }) + $consumers = @( + @{ Name = 'AvaloniaConsumer'; Arguments = @('--framework', 'net8.0', '-p:TargetFrameworks=net8.0') } + @{ Name = 'MessageFormatConsumer'; Arguments = @('--framework', 'net8.0', '-p:TargetFrameworks=net8.0') } + ) if ($onWindows) { diff --git a/scripts/verify-package-aot.ps1 b/scripts/verify-package-aot.ps1 index 5567f68..d956890 100644 --- a/scripts/verify-package-aot.ps1 +++ b/scripts/verify-package-aot.ps1 @@ -1,7 +1,7 @@ <# .SYNOPSIS - Publishes the Avalonia package consumer with Native AOT, gates its IL diagnostics, and runs the native - binary. + Publishes the two Native AOT package consumers - AvaloniaConsumer and MessageFormatConsumer - with + Native AOT, gates their IL diagnostics, and runs each native binary. .DESCRIPTION This is the only check in the repository that can catch silent trimming damage. The library finds @@ -10,16 +10,20 @@ trimmed on the JIT, which is why the whole test suite passes while a trimmed application finds no translation at all. - The consumer reaches the library through PackageReference, never through a project reference. That + AvaloniaConsumer covers ResXLocalization.Core and ResXLocalization.Avalonia. MessageFormatConsumer + covers ResXLocalization.MessageFormat and its MessageFormat dependency next to them: ICU plural rules, + named arguments from a compiled binding, and the format culture. + + Each consumer reaches the library through PackageReference, never through a project reference. That matters: the packed source generator, the buildTransitive resx wiring that feeds it, the satellite assemblies and the trimming metadata all have to survive packing, and a project-referenced test would pass even if packing dropped every one of them. - Five things have to hold, and all five are gated here: + Five things have to hold, and all five are gated here, for each consumer in turn: 1. The expected packages exist locally, at the expected version, by the id and version in their own nuspec - not by their file name. - 2. They restore into a consumer that has nothing but a PackageReference, from the local feed and never + 2. They restore into a consumer that has nothing but PackageReferences, from the local feed and never from nuget.org. 3. The Native AOT publish succeeds and produces the native binary and the German satellite assembly. 4. NO IL2xxx/IL3xxx diagnostic is reported, from anywhere - not from the library, not from a package in @@ -45,8 +49,8 @@ .PARAMETER Pack Pack first, into artifacts/packages. On Windows that is every shipping project; elsewhere the WPF - project cannot build, so Core and Avalonia are packed on their own - which is all this gate consumes. - Full release packaging stays on Windows. + project cannot build, so Core, Avalonia and MessageFormat are packed on their own - which is all the + two consumers of this gate consume. Full release packaging stays on Windows. CI does not use this: it downloads the exact packages the publish job produced. @@ -95,15 +99,16 @@ if ($Runtime -notin $supportedRuntimes) # scripts/ - the repository root is one level up, whatever the current directory is. Every path # below is anchored to it. $repositoryRoot = (Resolve-Path -LiteralPath (Split-Path -Parent $PSScriptRoot)).Path -$consumerDirectory = Join-Path $repositoryRoot 'tests/package-consumption/AvaloniaConsumer' $packageDirectory = Join-Path $repositoryRoot 'artifacts/packages' $packageCache = Join-Path $repositoryRoot 'tests/package-consumption/.packages' $consumerNuGetConfig = Join-Path $repositoryRoot 'tests/package-consumption/nuget.config' -$publishDirectory = Join-Path $repositoryRoot "artifacts/package-aot/$Framework-$Runtime" $logDirectory = Join-Path $repositoryRoot 'artifacts/package-aot/logs' -# The Avalonia gate consumes these two. WPF is not among them and never will be. -$requiredPackageIds = @('ResXLocalization.Core', 'ResXLocalization.Avalonia') +# The consumers this gate publishes and runs, in this order, under tests/package-consumption. +$consumerNames = @('AvaloniaConsumer', 'MessageFormatConsumer') + +# The two consumers consume these three. WPF is not among them and never will be. +$requiredPackageIds = @('ResXLocalization.Core', 'ResXLocalization.Avalonia', 'ResXLocalization.MessageFormat') if (-not $PackageVersion) { @@ -158,9 +163,9 @@ try } else { - # ResXLocalization.WPF targets net*-windows and cannot build here. Packing the two this gate + # ResXLocalization.WPF targets net*-windows and cannot build here. Packing the three this gate # needs is the honest thing to do; a full release pack stays on Windows. - Write-Host "Packing ResXLocalization.Core and ResXLocalization.Avalonia ($PackageVersion) - WPF needs Windows..." -ForegroundColor Cyan + Write-Host "Packing $($requiredPackageIds -join ', ') ($PackageVersion) - WPF needs Windows..." -ForegroundColor Cyan foreach ($packageId in $requiredPackageIds) { @@ -326,9 +331,6 @@ try Write-Host "Every package this gate needs is present at $PackageVersion, by their nuspec metadata." -ForegroundColor Cyan - Write-Host "Publishing the Avalonia package consumer ($Framework, $Runtime, packages $PackageVersion)..." ` - -ForegroundColor Cyan - # NUGET_PACKAGES is set explicitly, and to the CONSUMER's isolated cache. The environment variable takes # precedence over the globalPackagesFolder setting in tests/package-consumption/nuget.config, so an # inherited one - CI sets NUGET_PACKAGES to a workspace-wide cache - would silently defeat the isolation @@ -336,168 +338,177 @@ try # never came out of these packages. It is restored in the finally block at the end of the script. $env:NUGET_PACKAGES = $packageCache - # PublishAot is passed here rather than set in the project file, so that an ordinary `dotnet run` of the - # consumer stays a genuine JIT baseline. - # - # RestoreConfigFile names the CONSUMER's NuGet configuration explicitly rather than relying on NuGet's - # upward search finding it. That file is what maps ResXLocalization.* to the local artifact feed and - # s the sources first - so a missing local package fails instead of resolving from nuget.org, - # where a published package of the same version exists and would look like a pass. - # - # TrimmerSingleWarn=false is what makes the gate meaningful: left at its default, ILC collapses every - # diagnostic from one assembly into a single IL2104 "assembly produced trim warnings" line, and the - # individual IL2xxx codes this script counts never appear. - # - # Run from the consumer directory, which is where a consumer would run it. - Push-Location -LiteralPath $consumerDirectory - try - { - $publishOutput = & dotnet publish 'AvaloniaConsumer.csproj' ` - --configuration $Configuration ` - --framework $Framework ` - --runtime $Runtime ` - --self-contained true ` - -p:RestoreConfigFile=$consumerNuGetConfig ` - -p:PublishAot=true ` - -p:TrimmerSingleWarn=false ` - -p:SuppressTrimAnalysisWarnings=false ` - -p:ResXLocalizationVersion=$PackageVersion ` - --output $publishDirectory 2>&1 - } - finally + foreach ($consumerName in $consumerNames) { - Pop-Location - } - - $publishExitCode = $LASTEXITCODE - - $publishOutput | ForEach-Object { Write-Host $_ } - - # The log is kept whatever happens, because a failure here is the one worth reading twice and the - # console scrolls. - New-Item -ItemType Directory -Force -Path $logDirectory | Out-Null - $publishLog = Join-Path $logDirectory "publish-$Framework-$Runtime.log" - $publishOutput | Out-File -LiteralPath $publishLog -Encoding utf8 + $consumerDirectory = Join-Path $repositoryRoot "tests/package-consumption/$consumerName" + $publishDirectory = Join-Path $repositoryRoot "artifacts/package-aot/$consumerName-$Framework-$Runtime" - if ($publishExitCode -ne 0) - { Write-Host '' - Write-Host "FAILED. The Native AOT publish exited with code $publishExitCode. Log: $publishLog" -ForegroundColor Red - - exit 1 - } - - # --- The warning gate ----------------------------------------------------------------------------- - - $diagnostics = $publishOutput | - Select-String -Pattern 'IL[23]\d{3}' | - ForEach-Object { - # Every diagnostic line ends with the MSBuild project suffix "[...csproj::TargetFramework=...]", - # which names this project no matter which assembly the diagnostic came from. Strip it before - # deciding where the diagnostic originated, or everything would look like it came from the - # consumer. - $origin = $_.Line.Trim() -replace '\s*\[[^\[\]]*\]\s*$', '' - - [PSCustomObject] @{ - Origin = $origin - Code = [Regex]::Match($_.Line, 'IL[23]\d{3}').Value - Text = $_.Line.Trim() - } + Write-Host "Publishing $consumerName ($Framework, $Runtime, packages $PackageVersion)..." -ForegroundColor Cyan + + # PublishAot is passed here rather than set in the project file, so that an ordinary `dotnet run` of + # the consumer stays a genuine JIT baseline. + # + # RestoreConfigFile names the CONSUMER's NuGet configuration explicitly rather than relying on NuGet's + # upward search finding it. That file is what maps ResXLocalization.* to the local artifact feed and + # s the sources first - so a missing local package fails instead of resolving from nuget.org, + # where a published package of the same version exists and would look like a pass. + # + # TrimmerSingleWarn=false is what makes the gate meaningful: left at its default, ILC collapses every + # diagnostic from one assembly into a single IL2104 "assembly produced trim warnings" line, and the + # individual IL2xxx codes this script counts never appear. + # + # Run from the consumer directory, which is where a consumer would run it. + Push-Location -LiteralPath $consumerDirectory + try + { + $publishOutput = & dotnet publish "$consumerName.csproj" ` + --configuration $Configuration ` + --framework $Framework ` + --runtime $Runtime ` + --self-contained true ` + -p:RestoreConfigFile=$consumerNuGetConfig ` + -p:PublishAot=true ` + -p:TrimmerSingleWarn=false ` + -p:SuppressTrimAnalysisWarnings=false ` + -p:ResXLocalizationVersion=$PackageVersion ` + --output $publishDirectory 2>&1 + } + finally + { + Pop-Location } - # The gate is ZERO diagnostics, from anywhere. The packages advertise Native AOT support without - # [RequiresUnreferencedCode] or [RequiresDynamicCode] on any public member, so a consumer publishing - # this way sees nothing - and a warning appearing anywhere is a regression against that promise. - # - # The split below only shapes the failure message, because "the library started warning" and "our own - # call site started warning" have different causes. The same site is reported twice, once by the Roslyn - # analyzer and once by ILC, so the list is de-duplicated. - $fromConsumer = @($diagnostics | Where-Object { $_.Origin.StartsWith($consumerDirectory, [StringComparison]::OrdinalIgnoreCase) }) - $fromElsewhere = @($diagnostics | Where-Object { -not $_.Origin.StartsWith($consumerDirectory, [StringComparison]::OrdinalIgnoreCase) }) + $publishExitCode = $LASTEXITCODE - Write-Host '' + $publishOutput | ForEach-Object { Write-Host $_ } - if ($diagnostics.Count -eq 0) - { - Write-Host 'IL diagnostics: none, from anywhere. A consumer publishing this way sees no warnings.' -ForegroundColor Cyan - } - else - { - Write-Host 'FAILED. The publish reported IL diagnostics, and the gate is zero:' -ForegroundColor Red + # The log is kept whatever happens, because a failure here is the one worth reading twice and the + # console scrolls. + New-Item -ItemType Directory -Force -Path $logDirectory | Out-Null + $publishLog = Join-Path $logDirectory "publish-$consumerName-$Framework-$Runtime.log" + $publishOutput | Out-File -LiteralPath $publishLog -Encoding utf8 - if ($fromElsewhere.Count -gt 0) + if ($publishExitCode -ne 0) { Write-Host '' - Write-Host " From the library or a package ($($fromElsewhere.Count) before de-duplication):" -ForegroundColor Red - $fromElsewhere | Sort-Object Text -Unique | ForEach-Object { Write-Host " $($_.Text)" -ForegroundColor Red } + Write-Host "FAILED. The Native AOT publish exited with code $publishExitCode. Log: $publishLog" -ForegroundColor Red + + exit 1 } - if ($fromConsumer.Count -gt 0) - { - Write-Host '' - Write-Host " At the consumer's own call sites ($($fromConsumer.Count) before de-duplication):" -ForegroundColor Red - $fromConsumer | Sort-Object Origin -Unique | Group-Object Code | Sort-Object Name | ForEach-Object { - Write-Host (" {0,-8} {1} call site(s)" -f $_.Name, $_.Count) -ForegroundColor Red + # --- The warning gate ------------------------------------------------------------------------- + + $diagnostics = $publishOutput | + Select-String -Pattern 'IL[23]\d{3}' | + ForEach-Object { + # Every diagnostic line ends with the MSBuild project suffix + # "[...csproj::TargetFramework=...]", which names this project no matter which assembly the + # diagnostic came from. Strip it before deciding where the diagnostic originated, or + # everything would look like it came from the consumer. + $origin = $_.Line.Trim() -replace '\s*\[[^\[\]]*\]\s*$', '' + + [PSCustomObject] @{ + Origin = $origin + Code = [Regex]::Match($_.Line, 'IL[23]\d{3}').Value + Text = $_.Line.Trim() + } } - Write-Host '' - Write-Host ' A diagnostic here means a public API started carrying [RequiresUnreferencedCode] or' -ForegroundColor Red - Write-Host ' [RequiresDynamicCode], which the packages promise their consumers they do not.' -ForegroundColor Red - } + + # The gate is ZERO diagnostics, from anywhere. The packages advertise Native AOT support without + # [RequiresUnreferencedCode] or [RequiresDynamicCode] on any public member, so a consumer publishing + # this way sees nothing - and a warning appearing anywhere is a regression against that promise. + # + # The split below only shapes the failure message, because "the library started warning" and "our + # own call site started warning" have different causes. The same site is reported twice, once by the + # Roslyn analyzer and once by ILC, so the list is de-duplicated. + $fromConsumer = @($diagnostics | Where-Object { $_.Origin.StartsWith($consumerDirectory, [StringComparison]::OrdinalIgnoreCase) }) + $fromElsewhere = @($diagnostics | Where-Object { -not $_.Origin.StartsWith($consumerDirectory, [StringComparison]::OrdinalIgnoreCase) }) Write-Host '' - Write-Host "Log: $publishLog" -ForegroundColor Red - Write-Host 'Do not silence these at the call site or with NoWarn. An IL2xxx warning is the only' -ForegroundColor Red - Write-Host 'build-time evidence that a reflection path survives trimming - restructure the code, or' -ForegroundColor Red - Write-Host 'answer the diagnostic where it occurs with a justified, tested suppression.' -ForegroundColor Red - exit 1 - } + if ($diagnostics.Count -eq 0) + { + Write-Host 'IL diagnostics: none, from anywhere. A consumer publishing this way sees no warnings.' -ForegroundColor Cyan + } + else + { + Write-Host 'FAILED. The publish reported IL diagnostics, and the gate is zero:' -ForegroundColor Red - # --- The published output ------------------------------------------------------------------------- + if ($fromElsewhere.Count -gt 0) + { + Write-Host '' + Write-Host " From the library or a package ($($fromElsewhere.Count) before de-duplication):" -ForegroundColor Red + $fromElsewhere | Sort-Object Text -Unique | ForEach-Object { Write-Host " $($_.Text)" -ForegroundColor Red } + } - $executableName = $IsWindows ? 'AvaloniaConsumer.exe' : 'AvaloniaConsumer' - $executable = Join-Path $publishDirectory $executableName - $germanSatellite = Join-Path $publishDirectory 'de/AvaloniaConsumer.resources.dll' + if ($fromConsumer.Count -gt 0) + { + Write-Host '' + Write-Host " At the consumer's own call sites ($($fromConsumer.Count) before de-duplication):" -ForegroundColor Red + $fromConsumer | Sort-Object Origin -Unique | Group-Object Code | Sort-Object Name | ForEach-Object { + Write-Host (" {0,-8} {1} call site(s)" -f $_.Name, $_.Count) -ForegroundColor Red + } + Write-Host '' + Write-Host ' A diagnostic here means a public API started carrying [RequiresUnreferencedCode] or' -ForegroundColor Red + Write-Host ' [RequiresDynamicCode], which the packages promise their consumers they do not.' -ForegroundColor Red + } - foreach ($expected in @($executable, $germanSatellite)) - { - if (-not (Test-Path -LiteralPath $expected)) - { Write-Host '' - Write-Host "FAILED. The publish did not produce $expected." -ForegroundColor Red Write-Host "Log: $publishLog" -ForegroundColor Red + Write-Host 'Do not silence these at the call site or with NoWarn. An IL2xxx warning is the only' -ForegroundColor Red + Write-Host 'build-time evidence that a reflection path survives trimming - restructure the code, or' -ForegroundColor Red + Write-Host 'answer the diagnostic where it occurs with a justified, tested suppression.' -ForegroundColor Red exit 1 } - } - # --- Running the native binary -------------------------------------------------------------------- - # The file existing is not the check. Everything that can go wrong under trimming - a resource that is - # no longer found, a satellite that is no longer loaded, a typed key whose ResourceManager was trimmed - # away - produces a binary that exists, starts, and answers wrongly. + # --- The published output --------------------------------------------------------------------- - Write-Host '' - Write-Host 'Running the native binary...' -ForegroundColor Cyan - Write-Host '' + $executableName = $IsWindows ? "$consumerName.exe" : $consumerName + $executable = Join-Path $publishDirectory $executableName + $germanSatellite = Join-Path $publishDirectory "de/$consumerName.resources.dll" - $runOutput = & $executable 2>&1 - $runExitCode = $LASTEXITCODE + foreach ($expected in @($executable, $germanSatellite)) + { + if (-not (Test-Path -LiteralPath $expected)) + { + Write-Host '' + Write-Host "FAILED. The publish did not produce $expected." -ForegroundColor Red + Write-Host "Log: $publishLog" -ForegroundColor Red - $runOutput | ForEach-Object { Write-Host $_ } + exit 1 + } + } - $runLog = Join-Path $logDirectory "run-$Framework-$Runtime.log" - $runOutput | Out-File -LiteralPath $runLog -Encoding utf8 + # --- Running the native binary ---------------------------------------------------------------- + # The file existing is not the check. Everything that can go wrong under trimming - a resource that is + # no longer found, a satellite that is no longer loaded, a typed key whose ResourceManager was trimmed + # away - produces a binary that exists, starts, and answers wrongly. - Write-Host '' + Write-Host '' + Write-Host "Running the native $consumerName binary..." -ForegroundColor Cyan + Write-Host '' - if ($runExitCode -ne 0) - { - Write-Host "FAILED. The native binary exited with code $runExitCode. Log: $runLog" -ForegroundColor Red + $runOutput = & $executable 2>&1 + $runExitCode = $LASTEXITCODE - exit 1 + $runOutput | ForEach-Object { Write-Host $_ } + + $runLog = Join-Path $logDirectory "run-$consumerName-$Framework-$Runtime.log" + $runOutput | Out-File -LiteralPath $runLog -Encoding utf8 + + Write-Host '' + + if ($runExitCode -ne 0) + { + Write-Host "FAILED. The native binary exited with code $runExitCode. Log: $runLog" -ForegroundColor Red + + exit 1 + } } - Write-Host "PASSED. $Framework/$Runtime published from the packages with no IL diagnostics at all, and every assertion passed." ` + Write-Host "PASSED. $($consumerNames -join ' and ') published for $Framework/$Runtime from the packages with no IL diagnostics at all, and every assertion passed." ` -ForegroundColor Green exit 0 diff --git a/tests/ResXLocalization.Core.Tests/LocalizerLookupTests.cs b/tests/ResXLocalization.Core.Tests/LocalizerLookupTests.cs index cfcf47c..bf0fc28 100644 --- a/tests/ResXLocalization.Core.Tests/LocalizerLookupTests.cs +++ b/tests/ResXLocalization.Core.Tests/LocalizerLookupTests.cs @@ -18,7 +18,7 @@ public void Indexer_IsShorthandForSearchAllGet() } [Fact] - public void MissingKey_ReturnsTheBangSentinel() + public void MissingKey_ReturnsTheFailureText() { var localizer = this.resources.CreateLocalizer(); @@ -97,7 +97,7 @@ public void SearchAll_SwitchesLive_OnCultureChange() } [Fact] - public void SearchAll_WithNothingRegistered_ReturnsTheSentinel() + public void SearchAll_WithNothingRegistered_ReturnsTheFailureText() { var localizer = new Localizer { CurrentCulture = TestResources.English }; diff --git a/tests/package-consumption/AvaloniaConsumer/Program.cs b/tests/package-consumption/AvaloniaConsumer/Program.cs index f02e654..b35a58e 100644 --- a/tests/package-consumption/AvaloniaConsumer/Program.cs +++ b/tests/package-consumption/AvaloniaConsumer/Program.cs @@ -149,7 +149,7 @@ void Check(string description, string actual, string expected) // --- Culture fallback, which is what a trimmed satellite would break silently ------------------------ // -// Neither key exists in the German files. The neutral value has to come back - not the sentinel, and not +// Neither key exists in the German files. The neutral value has to come back - not the failure text, and not // an empty string. Check( diff --git a/tests/package-consumption/MessageFormatConsumer/LocalizedView.axaml b/tests/package-consumption/MessageFormatConsumer/LocalizedView.axaml new file mode 100644 index 0000000..f5b635f --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/LocalizedView.axaml @@ -0,0 +1,27 @@ +๏ปฟ + + + + + + + + + + + + + + diff --git a/tests/package-consumption/MessageFormatConsumer/LocalizedView.axaml.cs b/tests/package-consumption/MessageFormatConsumer/LocalizedView.axaml.cs new file mode 100644 index 0000000..d162642 --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/LocalizedView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace MessageFormatConsumer; + +public partial class LocalizedView : UserControl +{ + /// + /// Creates the view without a data context: the caller assigns one, so a view can also be observed + /// before its argument binding resolves. + /// + public LocalizedView() => this.InitializeComponent(); +} diff --git a/tests/package-consumption/MessageFormatConsumer/LocalizedViewModel.cs b/tests/package-consumption/MessageFormatConsumer/LocalizedViewModel.cs new file mode 100644 index 0000000..d0563bf --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/LocalizedViewModel.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; + +namespace MessageFormatConsumer; + +/// +/// The data context of : the value its compiled argument binding reads. +/// +public sealed class LocalizedViewModel : INotifyPropertyChanged +{ + private int count; + + /// + public event PropertyChangedEventHandler? PropertyChanged; + + /// Gets or sets the number the ICU plural pattern of "PeopleInvited" selects its branch by. + public int Count + { + get => this.count; + set + { + this.count = value; + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.Count))); + } + } +} diff --git a/tests/package-consumption/MessageFormatConsumer/MessageFormatConsumer.csproj b/tests/package-consumption/MessageFormatConsumer/MessageFormatConsumer.csproj new file mode 100644 index 0000000..3401e9c --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/MessageFormatConsumer.csproj @@ -0,0 +1,22 @@ + + + + Exe + + net8.0;net10.0 + enable + enable + en;de + + 1.0.0 + + + + + + + + + diff --git a/tests/package-consumption/MessageFormatConsumer/Program.cs b/tests/package-consumption/MessageFormatConsumer/Program.cs new file mode 100644 index 0000000..d70dcaf --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/Program.cs @@ -0,0 +1,118 @@ +// End-to-end consumption check for the ResXLocalization.MessageFormat NuGet package, next to +// ResXLocalization.Avalonia. The ICU formatter, its MessageFormat dependency and - proven at compile time +// by the StringsKeys class of a .resx without a designer - the packaged source generator must all arrive +// through the two PackageReferences. Exits non-zero when any check failed. +// +// This program is also the assertion set the Native AOT gate runs for the ICU formatter. Everything a +// trimmer can break and a JIT cannot is here: the plural rules of the MessageFormat library, the named +// argument delivered by a compiled binding, the German satellite, and the format culture of the invariant +// culture. + +using System.Globalization; +using Avalonia.Threading; +using MessageFormatConsumer; +using MessageFormatConsumer.Resources; +using RentADeveloper.ResXLocalization; +using RentADeveloper.ResXLocalization.MessageFormat; + +var failures = 0; + +void Check(string description, string actual, string expected) +{ + if (actual == expected) + { + Console.WriteLine($"PASS {description}"); + } + else + { + Console.Error.WriteLine($"FAIL {description}: expected \"{expected}\", got \"{actual}\""); + failures++; + } +} + +Localizer.Current.UseMessageFormat(); +Localizer.Current.RegisterResourceManager(StringsKeys.ResourceManager); +Localizer.Current.CurrentCulture = new CultureInfo("en"); + +// --- The compiled XAML ------------------------------------------------------------------------------ + +var viewModel = new LocalizedViewModel { Count = 1 }; +var localizedView = new LocalizedView { DataContext = viewModel }; +Dispatcher.UIThread.RunJobs(); + +Check("compiled XAML plural, one", localizedView.PeopleInvitedText.Text ?? "", "1 person invited"); + +viewModel.Count = 5; +Dispatcher.UIThread.RunJobs(); +Check("compiled XAML plural, other", localizedView.PeopleInvitedText.Text ?? "", "5 people invited"); + +Localizer.Current.CurrentCulture = new CultureInfo("de"); +Dispatcher.UIThread.RunJobs(); +Check( + "compiled XAML plural after the live switch to de (satellite)", + localizedView.PeopleInvitedText.Text ?? "", + "5 Personen eingeladen" +); + +// --- Named arguments in code ------------------------------------------------------------------------ + +Localizer.Current.CurrentCulture = new CultureInfo("en"); +Check( + "named argument in code", + Localizer.Current.Get(StringsKeys.PeopleInvited, MessageArguments.FromTuples(("Count", 1))), + "1 person invited" +); + +// The invariant culture has only CLDR's root plural rules; the ICU formatter formats it as en. +Localizer.Current.CurrentCulture = CultureInfo.InvariantCulture; +Check( + "named argument in code, invariant culture formatted as en", + Localizer.Current.Get(StringsKeys.PeopleInvited, MessageArguments.FromTuples(("Count", 1))), + "1 person invited" +); + +// --- An argument binding that has not resolved yet -------------------------------------------------- +// +// A view whose data context arrives after it is created formats with a null argument first, which ICU +// renders without throwing - so no lookup failure is reported. + +Localizer.Current.CurrentCulture = new CultureInfo("en"); + +var lookupFailures = 0; +void OnLookupFailed(object? sender, LookupFailedEventArgs e) => lookupFailures++; + +Localizer.Current.LookupFailed += OnLookupFailed; +try +{ + var lateView = new LocalizedView(); + Dispatcher.UIThread.RunJobs(); + + lateView.DataContext = new LocalizedViewModel { Count = 1 }; + Dispatcher.UIThread.RunJobs(); +} +finally +{ + Localizer.Current.LookupFailed -= OnLookupFailed; +} + +Check( + "data context set after the view was created, lookup failures", + lookupFailures.ToString(CultureInfo.InvariantCulture), + "0" +); + +// --- A value without arguments, which ICU parses as well -------------------------------------------- + +Check("ICU escaping without arguments in code", Localizer.Current.Get(StringsKeys.Ready), "It's ready"); +Check("ICU escaping without arguments in compiled XAML", localizedView.ReadyText.Text ?? "", "It's ready"); + +if (failures > 0) +{ + Console.Error.WriteLine($"{failures} package consumption check(s) FAILED."); + + return 1; +} + +Console.WriteLine("All package consumption checks passed."); + +return 0; diff --git a/tests/package-consumption/MessageFormatConsumer/Resources/Strings.de.resx b/tests/package-consumption/MessageFormatConsumer/Resources/Strings.de.resx new file mode 100644 index 0000000..5897dc5 --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/Resources/Strings.de.resx @@ -0,0 +1,21 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {Count, plural, one {# Person eingeladen} other {# Personen eingeladen}} + + + Bereit + + diff --git a/tests/package-consumption/MessageFormatConsumer/Resources/Strings.resx b/tests/package-consumption/MessageFormatConsumer/Resources/Strings.resx new file mode 100644 index 0000000..5712297 --- /dev/null +++ b/tests/package-consumption/MessageFormatConsumer/Resources/Strings.resx @@ -0,0 +1,21 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {Count, plural, one {# person invited} other {# people invited}} + + + It''s ready + + diff --git a/tests/package-consumption/README.md b/tests/package-consumption/README.md index afaf685..93579c1 100644 --- a/tests/package-consumption/README.md +++ b/tests/package-consumption/README.md @@ -15,12 +15,18 @@ only place the most fragile parts of the packaging are exercised end to end: - the source generator shipped as `analyzers/dotnet/cs`, - the transitive `ResXLocalization.Core` package, - the `net8.0` target of the multi-targeted packages, -- the satellite-assembly flow of a real consumer. +- the satellite-assembly flow of a real consumer, +- the opt-in `ResXLocalization.MessageFormat` package with its `MessageFormat` dependency + (`MessageFormatConsumer`): ICU plural patterns with a named argument from a compiled binding, in + code and in compiled XAML, a live switch to German, the invariant culture formatted as `en`, an + argument binding that resolves after the view was created, and ICU escaping in a value without + arguments. The Avalonia and WPF apps compile real framework XAML against the generated `StringsKeys` and `DesignerlessKeys` classes, instantiate the view, and assert rendered live language switching. `CombinedConsumer` references both UI packages and proves that one Core assembly is resolved. Every -app exits non-zero on failure. +app exits non-zero on failure. `AvaloniaConsumer` and `MessageFormatConsumer` are also the two apps +`scripts/verify-package-aot.ps1` publishes with Native AOT and runs. The folder has its own `Directory.Build.props`/`.targets`/`Directory.Packages.props` boundary so none of the repository's in-repo wiring leaks in, and its own isolated package cache (`.packages`). @@ -31,12 +37,17 @@ none of the repository's in-repo wiring leaks in, and its own isolated package c # From the repository root: pack the packages, then run the consumers. dotnet pack src/ResXLocalization.Core/ResXLocalization.Core.csproj -c Release -o artifacts/packages dotnet pack src/ResXLocalization.Avalonia/ResXLocalization.Avalonia.csproj -c Release -o artifacts/packages +dotnet pack src/ResXLocalization.MessageFormat/ResXLocalization.MessageFormat.csproj -c Release -o artifacts/packages dotnet pack src/ResXLocalization.WPF/ResXLocalization.WPF.csproj -c Release -o artifacts/packages # Windows only # A reused MSBuild node keeps evaluating the previously packed targets of the same version; stop it. dotnet build-server shutdown -dotnet run --project tests/package-consumption/AvaloniaConsumer/AvaloniaConsumer.csproj -c Release +# The two multi-targeted consumers run once per target framework, which `dotnet run` needs named. +dotnet run --project tests/package-consumption/AvaloniaConsumer/AvaloniaConsumer.csproj -c Release --framework net8.0 +dotnet run --project tests/package-consumption/AvaloniaConsumer/AvaloniaConsumer.csproj -c Release --framework net10.0 +dotnet run --project tests/package-consumption/MessageFormatConsumer/MessageFormatConsumer.csproj -c Release --framework net8.0 +dotnet run --project tests/package-consumption/MessageFormatConsumer/MessageFormatConsumer.csproj -c Release --framework net10.0 dotnet run --project tests/package-consumption/WpfConsumer/WpfConsumer.csproj -c Release # Windows only dotnet run --project tests/package-consumption/WpfDerivedNamespaceConsumer/WpfDerivedNamespaceConsumer.csproj -c Release # Windows only dotnet run --project tests/package-consumption/CombinedConsumer/CombinedConsumer.csproj -c Release # Windows only