Skip to content

Remove dead OnlyAndroid method from integration tests#34517

Merged
PureWeen merged 1 commit intomainfrom
fix/remove-dead-onlyandroid
Mar 18, 2026
Merged

Remove dead OnlyAndroid method from integration tests#34517
PureWeen merged 1 commit intomainfrom
fix/remove-dead-onlyandroid

Conversation

@PureWeen
Copy link
Copy Markdown
Member

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!

Description

Removes the dead OnlyAndroid method from BaseTemplateTests and its 3 call sites in AOTTemplateTest and SimpleTemplateTest.

Why this is dead code

OnlyAndroid calls ReplaceInFile searching for:

<TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>

But MAUI templates now use MSBuild conditions with DOTNET_TFM-android placeholders — the static string above no longer exists in generated projects. The method is a silent no-op on every call.

Why remove it now

On net11.0, this method was already removed by PR #33576. When merging main → net11.0, the call sites in AOTTemplateTest.cs (added by PR #33756) cause CS0103 build errors since the method does not exist on net11.0. Removing it from main prevents these merge conflicts going forward.

Changes

  • BaseTemplateTests.cs: Removed OnlyAndroid method definition
  • AOTTemplateTest.cs: Removed 2 call sites (PublishNativeAOT, PublishNativeAOTRootAllMauiAssemblies)
  • SimpleTemplateTest.cs: Removed 1 call site (Build)

The OnlyAndroid method in BaseTemplateTests searches for a static
TargetFrameworks string that no longer exists in MAUI templates.
Since PR #33576 on net11.0, templates use MSBuild conditions to
restrict TargetFrameworks to Android-only on Linux, making OnlyAndroid
a silent no-op.

Removing the method and its 3 call sites:
- AOTTemplateTest.PublishNativeAOT
- AOTTemplateTest.PublishNativeAOTRootAllMauiAssemblies
- SimpleTemplateTest.Build

This also prevents merge conflicts when merging main into net11.0,
where OnlyAndroid was already removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 17, 2026 15:13
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34517

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34517"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@PureWeen PureWeen merged commit acdb7b2 into main Mar 18, 2026
32 of 35 checks passed
@PureWeen PureWeen deleted the fix/remove-dead-onlyandroid branch March 18, 2026 20:05
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Mar 30, 2026
<!-- 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!

## Description

Removes the dead `OnlyAndroid` method from `BaseTemplateTests` and its 3
call sites in `AOTTemplateTest` and `SimpleTemplateTest`.

### Why this is dead code

`OnlyAndroid` calls `ReplaceInFile` searching for:
```
<TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
```

But MAUI templates now use MSBuild conditions with `DOTNET_TFM-android`
placeholders — the static string above no longer exists in generated
projects. The method is a silent no-op on every call.

### Why remove it now

On `net11.0`, this method was already removed by PR dotnet#33576. When merging
`main → net11.0`, the call sites in `AOTTemplateTest.cs` (added by PR
dotnet#33756) cause CS0103 build errors since the method does not exist on
`net11.0`. Removing it from `main` prevents these merge conflicts going
forward.

### Changes

- **`BaseTemplateTests.cs`**: Removed `OnlyAndroid` method definition
- **`AOTTemplateTest.cs`**: Removed 2 call sites (`PublishNativeAOT`,
`PublishNativeAOTRootAllMauiAssemblies`)
- **`SimpleTemplateTest.cs`**: Removed 1 call site (`Build`)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <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.

3 participants