Skip to content

Commit

Permalink
[One .NET] set $(EnableSingleFileAnalyzer)=True by default (#5989)
Browse files Browse the repository at this point in the history
Fixes: #5943

Context: https://github.com/dotnet/sdk/blob/c1b8e80be1f7cca767ed9f3c90a45d6830b166a0/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets#L92-L96
Context: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
Context: dotnet/sdk#15239

[.NET Single File Apps][0] are a .NET deployment construct in which
"all application-dependent files [are built] into a single binary."
It's conceptually similar to Xamarin.Android `.apk` files, and there
is some overlap in the "semantic [API incompatibilities][1]" between
"normal" desktop .NET apps and Xamarin.Android/single-file apps,
such as the (lack of) utility in `Assembly.Location`, which is the
empty string in Xamarin.Android apps when
`$(EmbedAssembliesIntoApk)`=True, which is required for "app store"
distribution.

For .NET 6+ app builds, enable analyzers which check for usage of
these "semantically changed" APIs, by setting
`$(EnableSingleFileAnalyzer)`=True.

Update `Mono.Android.csproj` and `Mono.Android.Export.csproj` to also
enable the single-file analyzers.

After enabling this analyzer, no warnings appeared. But I do see the
appropriate analyzers setup in projects now:

	Analyzer
	    ~\android-toolchain\dotnet\sdk\6.0.100-preview.6.21280.2\Sdks\Microsoft.NET.Sdk\targets\..\analyzers\ILLink.CodeFixProvider.dll
	        IsImplicitlyDefined = true
	    ~\android-toolchain\dotnet\sdk\6.0.100-preview.6.21280.2\Sdks\Microsoft.NET.Sdk\targets\..\analyzers\ILLink.RoslynAnalyzer.dll
	        IsImplicitlyDefined = true

[0]: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
[1]: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file#api-incompatibility
  • Loading branch information
jonathanpeppers committed Jun 9, 2021
1 parent de9e623 commit d644609
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Mono.Android.Export/Mono.Android.Export.csproj
Expand Up @@ -11,6 +11,7 @@
<NoStdLib>true</NoStdLib>
<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'monoandroid10' ">
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Mono.Android.csproj
Expand Up @@ -21,6 +21,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>enable</Nullable>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
</PropertyGroup>

<PropertyGroup>
Expand Down
Expand Up @@ -78,6 +78,7 @@
<HttpActivityPropagationSupport Condition="'$(HttpActivityPropagationSupport)' == ''">false</HttpActivityPropagationSupport>
<StartupHookSupport Condition="'$(StartupHookSupport)' == ''">false</StartupHookSupport>
<UseNativeHttpHandler Condition="'$(UseNativeHttpHandler)' == ''">true</UseNativeHttpHandler>
<EnableSingleFileAnalyzer Condition="'$(EnableSingleFileAnalyzer)' == ''">true</EnableSingleFileAnalyzer>

<!-- XA feature switches defaults -->
<VSAndroidDesigner Condition="'$(VSAndroidDesigner)' == ''">false</VSAndroidDesigner>
Expand Down

0 comments on commit d644609

Please sign in to comment.