Skip to content

[Resizetizer] Retry splash cleanup deletes while a file is briefly locked - #40351

Merged
kubaflo merged 2 commits into
candidate/11.0.1xx-sr2from
fix-resizetizer-splash-delete-retry
Nov 18, 2026
Merged

kubaflo merged 2 commits into
candidate/11.0.1xx-sr2from
fix-resizetizer-splash-delete-retry

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

This is a repair for the SR2 candidate (#40116), so it targets candidate/11.0.1xx-sr2 as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

Failure. A Windows Debug Resizetizer unit test failed on candidate CI in maui-pr build 1686611 (run 47069628, result 106302, Helix job 14b1fbed-f357-4884-a932-9373167fdc39):

  • Test: GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png", "light").
  • Error: System.IO.IOException: The process cannot access the file 'MauiSplashImage.png' because it is being used by another process.
  • Stack: Directory.Delete → GenerateSplashAssetCatalog.CleanImageSet() (line 289) → Execute() (line 35).

The task regenerates its splash outputs by deleting the previous Assets.xcassets/MauiSplashImage.imageset folder. On Windows, another process briefly held the previous PNG open, so the delete threw, the task logged an error and returned false. In the same run, the test's own cleanup also hit the lock on its first three retries. This is the first such failure I found in about 200 builds. The lock holder is most likely an external scanner or indexer, but that isn't proven. This fix handles the mechanism (a sharing violation during cleanup), not the lock holder.

SkiaSharpTools.Save already retries image writes when Windows reports a sharing or access violation. It reads its policy from DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS / DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS, defaulting to 10 attempts at 1000 ms. The deletes in the splash tasks had no such protection.

Fix

  • Utils.DeleteFileWithRetries / Utils.DeleteDirectoryWithRetries reuse that same retry policy. They retry only an IOException / UnauthorizedAccessException whose HRESULT is ERROR_SHARING_VIOLATION or ERROR_ACCESS_DENIED, and only while attempts remain. Any other error, or the last attempt's error, still propagates unchanged.
  • GenerateSplashAssetCatalog, GenerateSplashAndroidResources and GenerateSplashStoryboard use these helpers for their cleanup File.Delete / Directory.Delete calls. Their behaviour is otherwise unchanged.
  • SkiaSharpTools' two error-code constants change from private to internal so the helpers can share them. The retry loop also has an internal overload that takes the attempt count and delay explicitly, so tests can exercise it without waiting through the default 10 × 1 s policy. There are no public API changes.

Test. The new [WindowsFact] RegeneratingWaitsForTemporarilyLockedPreviousImage (in GenerateSplashAssetCatalogTests) does the following:

  1. Generates the asset catalog.
  2. Opens the generated MauiSplashImage.png with FileShare.Read, which reproduces the sharing violation.
  3. Releases the file after 1.5 s.
  4. Regenerates, then asserts that the task succeeds and that the regenerated image has the expected size.

A new WindowsFact attribute, which mirrors the existing UnixTheory, skips the test on other platforms. No existing test, assertion, retry budget or skip was changed.

Two cross-platform helper tests in UtilsTests.RetryWhileFileIsLocked pin the exception filter, using 3 attempts and no delay:

  • PropagatesOtherIOErrorsWithoutRetrying: a DirectoryNotFoundException, which is an IOException but not a lock, propagates unchanged after exactly 1 call.
  • PropagatesLockThatOutlastsAllRetries: a sharing violation that never clears propagates after exactly 4 calls (attempts + 1).

Validation

Causal check on Helix Windows.10.Amd64.Open (full Resizetizer.UnitTests, Debug, submitted locally):

  • The payloads are deterministic: baseline and reverted are byte-identical, as are fix and restored.
  • A temporary control test, not included in this PR, regenerated without a lock. It passed in all four runs.
Variant Helix job Machine Product / test DLL sha256 Result
Baseline (new test, no fix) cfa5da13-137c-44f9-ba16-e19ca0f381da a00GG1H 97fde500… / 2dc3f20d… Failed (798 total, 1 failed, 2 skipped). Only failure: the new test, with the exact CI signature (IOException … being used by another process at CleanImageSet() line 289)
Fix 55936228-b40c-4490-92a6-83e763e844d1 a00GG4K b9cc28ae… / 3bacf8d6… Passed (798 total, 0 failed, 2 skipped)
Fix reverted 9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc a00GG47 97fde500… / 2dc3f20d… Failed, with the same new-test IOException (798 total, 1 failed)
Restored 2680c012-48d5-4866-bbed-5f8f1026a0b9 a00GG49 b9cc28ae… / 3bacf8d6… Passed (798 total, 0 failed, 2 skipped)

The only skips in every run were the existing ValidFilenames_Unix and InvalidFilenames_Unix tests.

Local checks

  • macOS, head d90bbd4605: dotnet test src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj passed: 795 passed, 0 failed, 3 skipped. The 3 skips are the two existing Unix-filename tests and the new Windows-only test.
  • Mutation check of the helper tests (--filter "FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"):
    • With the lock filter IsFileLocked(ex) removed, PropagatesOtherIOErrorsWithoutRetrying failed (expected 1 call, got 4).
    • With the retry bound changed from attempt < attempts to attempt <= attempts, PropagatesLockThatOutlastsAllRetries failed (expected 4 calls, got 5).
    • With the code restored, both passed.
  • dotnet format whitespace --folder --verify-no-changes --include <7 changed files>: passed. dotnet format whitespace --verify-no-changes on Utils.cs and UtilsTests.cs after the follow-up commit also passed.

Not shown here: the original CI failure has occurred only once, so this PR's CI can't show directly that it won't recur. The new test reproduces it deterministically instead.

Issues Fixed

Fixes the Windows Resizetizer ResizeQualityMetadataAffectsImageAsset cleanup failure (IOException from CleanImageSet) found while validating #40116.

…cked

Windows can refuse to delete a just-written splash image while another
process (antivirus, indexer) briefly holds it open. GenerateSplashAssetCatalog,
GenerateSplashStoryboard and GenerateSplashAndroidResources deleted their
previous outputs without retrying, failing the task with
'The process cannot access the file ... because it is being used by
another process'. Apply the existing image-write retry policy
(ERROR_SHARING_VIOLATION / ERROR_ACCESS_DENIED, DOTNET_ANDROID_FILE_WRITE_RETRY_*)
to these cleanup deletes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 00:33 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026
@kubaflo

kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 1 finding

Reviewed commit aa7b15c.

See inline comments for details.

@MauiBot

MauiBot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026
…tries

Expose the retry loop with an explicit attempt count and delay so tests can
pin its exception filter without waiting on the default 10 x 1 s policy:

- an I/O error that is not a lock propagates after a single attempt
- a lock that outlasts every retry propagates after attempts + 1 tries

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

This comment has been minimized.

@kubaflo

kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 0 findings

Reviewed commit d90bbd4.

@kubaflo kubaflo mentioned this pull request Nov 18, 2026
1 task
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@kubaflo — test-failure analysis for commit d90bbd4.

Scope CI failures Commit d90bbd4


🧪 CI Analysis — click to expand
📊 maui-pr
  • 🟢 Likely unrelated — Windows Debug/Release, macOS Debug/Pack: Arcade rejects BuildNumber: 20261117.204 during versioning, before the changed splash-cleanup code executes; this PR changes no version inputs.
  • 🟡 Needs human investigation — Publish Mac Native Artifacts: missing native-binaries; confirm whether failed packing prevented its production.
  • Insufficient data — macOS Release: failed-task diagnostic was not captured.

🧪 maui-pr-devicetests
  • 🟡 Needs human investigation — Android CoreCLR ReleasingImageSourceReturnsDifferentBitmap: Assert.True returned false; the five target runs provide no equivalent diagnostic establishing unrelatedness.
  • 🟡 Needs human investigation — Windows Border clipping, packaged/unpackaged (2 failures): transparent instead of red at (50,50), scale=3/shadow enabled; all five target runs have name-only matches without comparable parameters/assertions.
  • 🟡 Needs human investigation — iOS Mono Gesture Does Not Leak (TapGestureRecognizer): a Label remains alive; no equivalent target failure establishes causality.
  • Insufficient data — Android/iOS work-item completion is flagged incomplete, but neither has a captured crash dump; nonzero exits alone do not prove crashes.

🧪 maui-pr-uitests

No failures found.


🧭 Follow-up — actions and refresh

Next action: Restore missing diagnostics/completion evidence; compare the exact device-test variants on the target branch.

Maintainers: comment /review tests to refresh this report.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Attribution for the tests-failure analysis of d90bbd4. None of these failures come from this PR's change, which only touches Resizetizer splash cleanup.

  • maui-pr 1687175: every error line in the macOS Debug/Release/Pack raw logs is Arcade's Invalid format of BuildNumber: 20261117.204. Log 216 has 64 error lines and all 64 are BuildNumber; Windows logs 226 and 236 show the same. Arcade rejects any daily counter above 199. The missing native-binaries artifact is a downstream effect of the failed pack. I requeued maui-pr after the Pacific-day reset; it's now 1687325, build 20261118.3.
  • Windows Border Issue 17523(3,0,0,0,true), packaged and unpackaged: a candidate regression from [Windows] Fix Boxview shadow is not aligned with box view shape #40175. [Windows] Keep the shadow host out of XAML bounds so Border captures stay clipped #40353 fixes it; its device build 1686843 passes all 17 Issue17523 rows.
  • Android Glide ReleasingImageSourceReturnsDifferentBitmap: pre-existing. main device build 1667947 fails it the same way.
  • iOS Mono GestureDoesNotLeak(TapGestureRecognizer) (Label alive): this exact case also failed on candidate device build 1679922 (osx26 queue), before this PR existed. It's an unmatched GC variable outcome; I made no budget or assertion change.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026
@MauiBot

MauiBot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 0 findings

Reviewed commit d90bbd4.

@kubaflo
kubaflo merged commit f5af218 into candidate/11.0.1xx-sr2 Nov 18, 2026
174 of 181 checks passed
@kubaflo
kubaflo deleted the fix-resizetizer-splash-delete-retry branch November 18, 2026 10:48
kubaflo added a commit that referenced this pull request Nov 18, 2026
…cked (#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating #40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…40391)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

CI hardening only. No product, test, or pipeline YAML changes.

**Symptom.** Candidate UI build
[1687815](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687815)
(#40116), job *Controls Lifecycle,ManualReview,Maps* on Mac, failed in
**Install Appium** before any test ran. All 5 RetryHelper attempts
failed. Log 4334 shows this chain:

1. `npm list -g appium` → not installed.
2. The normal `npm i --location=global appium@2.17.1` fails with a
transient `ERR_SOCKET_TIMEOUT`.
3. `InstallAppium` falls back to `sudo -E npm i --location=global
appium@2.17.1`, which **succeeds**.
4. `appium driver install uiautomator2@4.2.1` (runs as the agent user)
fails with `EACCES: mkdir '/Users/cloudtest/.npm/_cacache/index-v5/…'`.
npm explains: *"Your cache folder contains root-owned files … sudo chown
-R 501:20 /Users/cloudtest/.npm"*.
5. Retries 2–5 fail on the same root-owned cache (`EACCES`/`EEXIST`),
then on `ENOTEMPTY` debris in `.appium/node_modules/appium`.

**Root cause.** `sudo -E` preserves `HOME`, so the elevated npm uses and
populates the user's `~/.npm/_cacache` as root. Every later non-root npm
call on the agent then fails. A single network blip becomes a job
failure that retries cannot fix.

**Same signature elsewhere (UI pipeline 313, builds since 11-13):**

| Build | Context | Agent / log | Notes |
| --- | --- | --- | --- |
| 1687815 | candidate | Mac, AcesShared 107, log 4334 | This failure. |
| 1686824 | PR #40351 | Mac, AcesShared 90, log 3817 | Identical chain.
|
| 1685341 | main | 13 Linux jobs | Network outage; the sudo fallback
then hit `EACCES` on `/home/cloudtest/.npm/_cacache`. |

The next job on AcesShared 107 (log 5398) passed, so the damage is per
job, not per machine.

**Fix.** In `src/Provisioning/Provisioning.csproj`, the macOS/Linux
`ElevatedNpmCommand` now passes `--cache
"<temp>/maui-elevated-npm-cache"`. npm keeps its logs and
update-notifier state under the cache directory too, so the elevated
install no longer writes anything into `~/.npm`. The normal
(non-elevated) path, the Windows elevation command, versions, timeouts,
and retry budgets are unchanged.

**Validation.** Real root was unavailable locally, so I emulated it:

- Node/npm matched CI: Node 20.3.1 / npm 9.6.7, the UseNode version in
`ui-tests-steps.yml`.
- `HOME`, `APPIUM_HOME`, and the npm global prefix were isolated.
- A `sudo` shim runs the command, then removes write permission from
every path that command **created**. This matches what a non-root user
can do with root-owned 755/644 entries.
- An `npm` shim fails the first non-elevated `npm i --location=global
appium@…` with `ERR_SOCKET_TIMEOUT`.

Each state ran the real target, `dotnet build
./src/Provisioning/Provisioning.csproj -t:ProvisionAppium
-p:SkipAppiumDoctor=true`, repeated up to CI's 5 attempts:

| State | Result |
| --- | --- |
| Baseline (`origin/net11`) | **Red 4/4**: `appium driver install
uiautomator2@4.2.1` fails with npm's "cache folder contains root-owned
files" `EACCES`; 3,612 non-writable entries left in `~/.npm`. |
| Fix | **Green on attempt 1**: uiautomator2 4.2.1, mac2 1.20.3, and
xcuitest 7.32.0 installed; 0 root-created paths under `HOME` or
`APPIUM_HOME`. |
| Fix reverted | **Red 5/5**, same `EACCES`. |
| Fix restored | **Green on attempt 1**. |
| Control (no network failure) | **Green**; the elevated command is not
invoked. |

In the emulation, the elevated install created nothing under
`APPIUM_HOME`, so isolating the npm cache is enough. Other checks:
`xmllint --noout` on the csproj and `git diff --check` both pass. Real
CI on this PR exercises the normal path; the elevated path only runs
after a network failure.

I found no open or recently merged PR that changes the elevated npm
install. `Provisioning.csproj` is byte-identical on `net11`, `main`,
`inflight/current`, and `candidate/11.0.1xx-sr2`.

### Issues Fixed

No tracking issue. Found while analysing candidate PR #40116 CI (UI
build 1687815).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…cked (#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating #40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…cked (#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating #40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…cked (#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating #40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…cked (#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating #40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…cked (#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating #40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…cked (dotnet#40351)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a repair for the SR2 candidate (dotnet#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure.** A Windows Debug Resizetizer unit test failed on candidate
CI in maui-pr build
[1686611](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1686611)
(run 47069628, result 106302, Helix job
`14b1fbed-f357-4884-a932-9373167fdc39`):
- Test:
`GenerateSplashAssetCatalogTests.ResizeQualityMetadataAffectsImageAsset("MauiSplashImage.png",
"light")`.
- Error: `System.IO.IOException: The process cannot access the file
'MauiSplashImage.png' because it is being used by another process`.
- Stack: `Directory.Delete` →
`GenerateSplashAssetCatalog.CleanImageSet()` (line 289) → `Execute()`
(line 35).

The task regenerates its splash outputs by deleting the previous
`Assets.xcassets/MauiSplashImage.imageset` folder. On Windows, another
process briefly held the previous PNG open, so the delete threw, the
task logged an error and returned `false`. In the same run, the test's
own cleanup also hit the lock on its first three retries. This is the
first such failure I found in about 200 builds. The lock holder is most
likely an external scanner or indexer, but that isn't proven. This fix
handles the mechanism (a sharing violation during cleanup), not the lock
holder.

`SkiaSharpTools.Save` already retries image **writes** when Windows
reports a sharing or access violation. It reads its policy from
`DOTNET_ANDROID_FILE_WRITE_RETRY_ATTEMPTS` /
`DOTNET_ANDROID_FILE_WRITE_RETRY_DELAY_MS`, defaulting to 10 attempts at
1000 ms. The **deletes** in the splash tasks had no such protection.

**Fix**
- `Utils.DeleteFileWithRetries` / `Utils.DeleteDirectoryWithRetries`
reuse that same retry policy. They retry only an `IOException` /
`UnauthorizedAccessException` whose HRESULT is `ERROR_SHARING_VIOLATION`
or `ERROR_ACCESS_DENIED`, and only while attempts remain. Any other
error, or the last attempt's error, still propagates unchanged.
- `GenerateSplashAssetCatalog`, `GenerateSplashAndroidResources` and
`GenerateSplashStoryboard` use these helpers for their cleanup
`File.Delete` / `Directory.Delete` calls. Their behaviour is otherwise
unchanged.
- `SkiaSharpTools`' two error-code constants change from `private` to
`internal` so the helpers can share them. The retry loop also has an
`internal` overload that takes the attempt count and delay explicitly,
so tests can exercise it without waiting through the default 10 × 1 s
policy. There are no public API changes.

**Test.** The new `[WindowsFact]
RegeneratingWaitsForTemporarilyLockedPreviousImage` (in
`GenerateSplashAssetCatalogTests`) does the following:
1. Generates the asset catalog.
2. Opens the generated `MauiSplashImage.png` with `FileShare.Read`,
which reproduces the sharing violation.
3. Releases the file after 1.5 s.
4. Regenerates, then asserts that the task succeeds and that the
regenerated image has the expected size.

A new `WindowsFact` attribute, which mirrors the existing `UnixTheory`,
skips the test on other platforms. No existing test, assertion, retry
budget or skip was changed.

Two cross-platform helper tests in `UtilsTests.RetryWhileFileIsLocked`
pin the exception filter, using 3 attempts and no delay:
- `PropagatesOtherIOErrorsWithoutRetrying`: a
`DirectoryNotFoundException`, which is an `IOException` but not a lock,
propagates unchanged after exactly 1 call.
- `PropagatesLockThatOutlastsAllRetries`: a sharing violation that never
clears propagates after exactly 4 calls (attempts + 1).

### Validation

**Causal check on Helix `Windows.10.Amd64.Open`** (full
Resizetizer.UnitTests, Debug, submitted locally):
- The payloads are deterministic: baseline and reverted are
byte-identical, as are fix and restored.
- A temporary control test, not included in this PR, regenerated without
a lock. It passed in all four runs.

| Variant | Helix job | Machine | Product / test DLL sha256 | Result |
|---|---|---|---|---|
| Baseline (new test, no fix) | `cfa5da13-137c-44f9-ba16-e19ca0f381da` |
a00GG1H | `97fde500…` / `2dc3f20d…` | **Failed** (798 total, 1 failed, 2
skipped). Only failure: the new test, with the exact CI signature
(`IOException … being used by another process` at `CleanImageSet()` line
289) |
| Fix | `55936228-b40c-4490-92a6-83e763e844d1` | a00GG4K | `b9cc28ae…` /
`3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped) |
| Fix reverted | `9f66e88d-ba22-4d86-8d6d-48d5ccbbdccc` | a00GG47 |
`97fde500…` / `2dc3f20d…` | **Failed**, with the same new-test
`IOException` (798 total, 1 failed) |
| Restored | `2680c012-48d5-4866-bbed-5f8f1026a0b9` | a00GG49 |
`b9cc28ae…` / `3bacf8d6…` | **Passed** (798 total, 0 failed, 2 skipped)
|

The only skips in every run were the existing `ValidFilenames_Unix` and
`InvalidFilenames_Unix` tests.

**Local checks**
- macOS, head `d90bbd4605`: `dotnet test
src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj`
**passed**: 795 passed, 0 failed, 3 skipped. The 3 skips are the two
existing Unix-filename tests and the new Windows-only test.
- Mutation check of the helper tests (`--filter
"FullyQualifiedName~UtilsTests+RetryWhileFileIsLocked"`):
- With the lock filter `IsFileLocked(ex)` removed,
`PropagatesOtherIOErrorsWithoutRetrying` **failed** (expected 1 call,
got 4).
- With the retry bound changed from `attempt < attempts` to `attempt <=
attempts`, `PropagatesLockThatOutlastsAllRetries` **failed** (expected 4
calls, got 5).
  - With the code restored, both **passed**.
- `dotnet format whitespace --folder --verify-no-changes --include <7
changed files>`: **passed**. `dotnet format whitespace
--verify-no-changes` on `Utils.cs` and `UtilsTests.cs` after the
follow-up commit also **passed**.

**Not shown here:** the original CI failure has occurred only once, so
this PR's CI can't show directly that it won't recur. The new test
reproduces it deterministically instead.

### Issues Fixed

Fixes the Windows Resizetizer `ResizeQualityMetadataAffectsImageAsset`
cleanup failure (`IOException` from `CleanImageSet`) found while
validating dotnet#40116.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants