-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Port Xamarin samples to .NET MAUI #2929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+1,067
−920
Conversation
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
Fixes: dotnet#2910 Copilot was able to automate much of this. I got "nerd sniped" to fix some of the issues I found along the way. There are some fixes required for iOS and Android to work, I will send in separate PRs.
jonathanpeppers
added a commit
to jonathanpeppers/BenchmarkDotNet
that referenced
this pull request
Dec 16, 2025
Context: dotnet#2929 Without this fix, I was getting the exception on `net10.0-ios` and `net10.0-maccatalyst` projects: Access to the path '~/src/dotnet/BenchmarkDotNet/samples/BenchmarkDotNet.Samples.Maui/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/BenchmarkDotNet.Samples.Maui.app/BenchmarkDotNet.Artifacts' is denied. This change was already here for Android, but it feels like it should have been here for iOS as well. `net10.0-maccatalyst` will also respond to this fix, as it is basically iOS "emulated" on macOS.
jonathanpeppers
added a commit
to jonathanpeppers/BenchmarkDotNet
that referenced
this pull request
Dec 16, 2025
… platforms Context: dotnet#2929 Context: https://github.com/dotnet/android/blob/4aa9af89102af2e745a8507992187d3c5993d638/Documentation/guides/MSBuildBestPractices.md In initially testing BenchmarkDotNet with .NET MAUI, I found that the weaver was not being executed because the `Publish` target is not called during the build process for Android and iOS projects. I think the target could actually run much sooner during builds and achieve better results. To address this, I refactored the `BenchmarkDotNet.Weaver.targets` file to run after `CoreCompile` on the `@(IntermediateAssembly)` in the `obj` directory. This is similar to what other targets do, such as the XamlC compiler: https://github.com/dotnet/maui/blob/8224becbb3a8a6bb1caaca4bbe70c56e88875506/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets#L213-L255 Other general MSBuild improvements: * Defined an MSBuild property for everything that seems useful. This allows consuming projects to configure the behavior (or workarounds!) as needed. * Made the MSBuild target incremental by using inputs and outputs. If the `.dll` file is an input, we can write a `.stamp` file as an output to indicate that the weaver has already been run for that assembly. If the `.dll` file changes, the weaver will run again. I tested this change with a .NET MAUI on 4 platforms and also the existing `BenchmarkDotNet.Samples` console app.
timcassell
reviewed
Dec 16, 2025
timcassell
pushed a commit
that referenced
this pull request
Dec 16, 2025
Context: #2929 Without this fix, I was getting the exception on `net10.0-ios` and `net10.0-maccatalyst` projects: Access to the path '~/src/dotnet/BenchmarkDotNet/samples/BenchmarkDotNet.Samples.Maui/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/BenchmarkDotNet.Samples.Maui.app/BenchmarkDotNet.Artifacts' is denied. This change was already here for Android, but it feels like it should have been here for iOS as well. `net10.0-maccatalyst` will also respond to this fix, as it is basically iOS "emulated" on macOS.
timcassell
approved these changes
Dec 16, 2025
timcassell
pushed a commit
that referenced
this pull request
Dec 16, 2025
… platforms (#2931) * [msbuild] refactor `BenchmarkDotNet.Weaver.targets` to support mobile platforms Context: #2929 Context: https://github.com/dotnet/android/blob/4aa9af89102af2e745a8507992187d3c5993d638/Documentation/guides/MSBuildBestPractices.md In initially testing BenchmarkDotNet with .NET MAUI, I found that the weaver was not being executed because the `Publish` target is not called during the build process for Android and iOS projects. I think the target could actually run much sooner during builds and achieve better results. To address this, I refactored the `BenchmarkDotNet.Weaver.targets` file to run after `CoreCompile` on the `@(IntermediateAssembly)` in the `obj` directory. This is similar to what other targets do, such as the XamlC compiler: https://github.com/dotnet/maui/blob/8224becbb3a8a6bb1caaca4bbe70c56e88875506/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets#L213-L255 Other general MSBuild improvements: * Defined an MSBuild property for everything that seems useful. This allows consuming projects to configure the behavior (or workarounds!) as needed. * Made the MSBuild target incremental by using inputs and outputs. If the `.dll` file is an input, we can write a `.stamp` file as an output to indicate that the weaver has already been run for that assembly. If the `.dll` file changes, the weaver will run again. I tested this change with a .NET MAUI on 4 platforms and also the existing `BenchmarkDotNet.Samples` console app. * Prefix `BenchmarkDotNet`
Member
|
@jonathanpeppers thanks a lot for your contribution! |
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.
Fixes: #2910
Copilot was able to automate much of this. I got "nerd sniped" to fix some of the issues I found along the way.
There are some fixes required for iOS and Android to work, I will send in separate PRs.