xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.46k stars 512 forks source link

Make it possible to enable profiling without enabling anything else #19370

Open rolfbjarne opened 12 months ago

rolfbjarne commented 12 months ago

Currently we link with the diagnostics libraries if _BundleDebug is true:

https://github.com/xamarin/xamarin-macios/blob/f12ba7fcf52cc22980cc1731e42c6bf904594d4a/dotnet/targets/Xamarin.Shared.Sdk.targets#L418

However, we enable a lot of other stuff too when _BundlerDebug is enabled, so it would make sense to have a separate opt-in mechanism to enable profiling.

Android uses AndroidEnableProfiler:

https://github.com/xamarin/xamarin-android/blob/d5c4ec09f7658428a10bbe49c8a7a3eb2f71cb86/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets#L216

In Xamarin.iOS, we used MtouchProfiling:

https://github.com/xamarin/xamarin-macios/blob/f12ba7fcf52cc22980cc1731e42c6bf904594d4a/msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets#L246

For Xamarin.Mac, we used Profiling:

https://github.com/xamarin/xamarin-macios/blob/f12ba7fcf52cc22980cc1731e42c6bf904594d4a/msbuild/Xamarin.Shared/Xamarin.Mac.Common.targets#L101

although MtouchProfiling was also accepted:

https://github.com/xamarin/xamarin-macios/blob/f12ba7fcf52cc22980cc1731e42c6bf904594d4a/msbuild/Xamarin.Shared/Xamarin.Mac.Common.props#L49

I believe .NET projects in general always include profiling support when they're built (it's enabled at launch using environment variables), so there's no existing project property we can use, but I think it would make sense to share the same property between all mobile platforms, so either of these two comes to mind:

CC @jonathanpeppers

jonathanpeppers commented 12 months ago

I like EnableProfiler, and then we would just keep supporting the old name, too: AndroidEnableProfiler.