[tests] Improve trimmer warning diagnostics#11981
Merged
jonathanpeppers merged 2 commits intoJul 6, 2026
Merged
Conversation
Report the parsed warning summary and the warning lines found when BuildHasTrimmerWarnings gets an unexpected warning count. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Improves diagnostics in the BuildHasTrimmerWarnings test to make trimmer-warning failures easier to understand by extracting the warning summary count and printing the warning lines found when expectations don’t match.
Changes:
- Parse the MSBuild warning summary line (
N Warning(s)) and compare the parsed count to the expected total. - Collect and print up to 25 warning lines (
: warning) in assertion failures to aid debugging. - Add a local helper (
GetWarningCount) to parse the summary line.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs | Enhances BuildHasTrimmerWarnings failure output by parsing the warning summary and printing captured warning lines. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Comment on lines
+607
to
+611
| string warningSummaryLine = b.LastBuildOutput.LastOrDefault (line => line.Contains ("Warning(s)", StringComparison.Ordinal)) ?? ""; | ||
| var actualWarnings = GetWarningCount (warningSummaryLine); | ||
|
|
||
| var allWarningLines = b.LastBuildOutput | ||
| .Where (line => line.Contains (": warning ", StringComparison.OrdinalIgnoreCase)) |
Member
Author
There was a problem hiding this comment.
@copilot address this feedback and optimize this code
Contributor
There was a problem hiding this comment.
Fixed in 8b7a09c — b.LastBuildOutput is now materialized into a string[] once, and all three usages (LastOrDefault, Where/Take, and the per-code ContainsText loop) operate on that array.
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
jonathanpeppers
approved these changes
Jul 6, 2026
jonathanpeppers
deleted the
dev/simonrozsival/buildtest2-trimmer-warning-diagnostics
branch
July 6, 2026 13:42
jonathanpeppers
pushed a commit
that referenced
this pull request
Jul 7, 2026
… conflict warnings (#11669) ### Summary `Microsoft.Android.Runtime.RuntimeFeature` was compiled into **two** assemblies: - `Mono.Android.Runtime.dll` (`src/Mono.Android.Runtime/Mono.Android.Runtime.csproj`) - `Mono.Android.dll` (`src/Mono.Android/Mono.Android.csproj`) Because `Mono.Android` references `Mono.Android.Runtime`, compiling `Mono.Android.dll` emitted duplicate-type warnings like: ```text warning CS0436: The type 'RuntimeFeature' in 'src/Mono.Android/Microsoft.Android.Runtime/RuntimeFeature.cs' conflicts with the imported type 'RuntimeFeature' in 'Mono.Android.Runtime'. ``` This PR makes `RuntimeFeature` live in **exactly one** assembly: `Mono.Android.Runtime.dll`. ### Changes - **`Mono.Android.csproj`** — removes the duplicate `<Compile>` of `RuntimeFeature.cs`, so the type is no longer compiled into `Mono.Android.dll`. - **`AndroidRuntime.cs`, `JNIEnv.cs`, `TypeManager.cs`** — adds `using RuntimeFeature = Microsoft.Android.Runtime.RuntimeFeature;` because once `RuntimeFeature` is imported instead of source-compiled into `Mono.Android`, the bare name conflicts with `System.Runtime.CompilerServices.RuntimeFeature`. - **`Mono.Android.Runtime.csproj` / `Mono.Android.Runtime.targets`** — migrates assembly metadata from the hand-written `Properties/AssemblyInfo.cs.in` template to MSBuild `GenerateAssemblyInfo`: - Deletes `Properties/AssemblyInfo.cs.in` and the `_BuildAssemblyInfo_cs` target (which ran `ReplaceFileContents` on the template) from `Mono.Android.Runtime.targets`. - Sets `<GenerateAssemblyInfo>true</GenerateAssemblyInfo>` with `GenerateAssemblyConfigurationAttribute`, `GenerateAssemblyFileVersionAttribute`, `GenerateAssemblyVersionAttribute`, `GenerateRepositoryUrlAttribute`, and `IncludeSourceRevisionInInformationalVersion` all set to `false` so no new attributes are introduced vs. the old template. - Moves the attribute values to properties/items: `AssemblyTitle`, `Product`, `Company`, and the `InternalsVisibleTo` items. A new `_SetGeneratedAssemblyInfoProperties` target (before `GetAssemblyAttributes`) supplies `InformationalVersion`, `TargetPlatformIdentifier`/`TargetPlatformVersion`, and `SupportedOSPlatformVersion` from the existing `GetXAVersionInfo` version info. - Adds `InternalsVisibleTo` for `Microsoft.Android.Runtime.NativeAOT` and `Mono.Android.NET-Tests`, which previously reached `RuntimeFeature` through `Mono.Android.dll`. - Marks `Mono.Android.Runtime.dll` trimmable with `<IsTrimmable>true</IsTrimmable>`. This keeps the cross-assembly `RuntimeFeature` feature switches visible to ILLink in partial-trimmed apps. ### Why `IsTrimmable` is needed Moving `RuntimeFeature` into `Mono.Android.Runtime.dll` makes `Mono.Android.dll` consume feature-switch properties across an assembly boundary. In partial trimming, ILLink only substitutes feature-switch getters in assemblies it processes. Without marking `Mono.Android.Runtime.dll` trimmable, some runtime-specific branches stayed live, causing the CoreCLR APK size-regression test to fail. Marking `Mono.Android.Runtime.dll` trimmable lets ILLink fold those `RuntimeFeature` guards again. ### Relationship to #11625 This is a focused subset of #11625. It intentionally avoids the broader class rename (`RuntimeFeature` → `AndroidRuntimeFeature`) and resolves the resulting `CS0104` ambiguity with local `using` aliases instead. ### Follow-up The `BuildHasTrimmerWarnings` diagnostic improvement was split out into #11981 so this PR remains focused on the `RuntimeFeature` single-assembly change. ### Verification Latest PR validation: [dotnet-android #1496564](https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1496564) ✅ The produced `Mono.Android.Runtime.dll` from that build was inspected to confirm the `GenerateAssemblyInfo` migration is faithful — all attributes from the old `AssemblyInfo.cs.in` (`AssemblyTitle`, `Product`, `Company`, `AssemblyInformationalVersion`, `TargetPlatform=Android37.0`, `SupportedOSPlatform=Android24.0`, `InternalsVisibleTo` for `Mono.Android`) are present, the new `InternalsVisibleTo` (NativeAOT, NET-Tests) and `IsTrimmable` metadata are added, and no unexpected attributes (`AssemblyConfiguration`, `AssemblyFileVersion`, `AssemblyVersion`, `RepositoryUrl`) were introduced. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve the failure message in BuildHasTrimmerWarnings by parsing the warning summary and printing the warning lines found when the expected count does not match.
Split out from #11669 so the RuntimeFeature PR stays focused.