Skip to content

Commit 6ac69be

Browse files
[Mono.Android] Nix Xamarin.Android.VSAndroidDesigner.IsSupported (#9471)
Context: https://developercommunity.visualstudio.com/t/XamarinAndroid-Designer---Replacement/10728132 Context: 363935b As the Android designer is no longer supported in Visual Studio, we are removing the `Xamarin.Android.VSAndroidDesigner.IsSupported` feature switch and `$(VSAndroidDesigner)` MSBuild property. This removes the codepath for Java types at runtime (on desktop) via `TypeManager.TypeRegistrationFallback()`. This also removes a `Console.WriteLine()` call when `liblog` and `__android_log_print` cannot be found.
1 parent 165cef7 commit 6ac69be

File tree

7 files changed

+0
-69
lines changed

7 files changed

+0
-69
lines changed

src/Mono.Android/Android.Runtime/AndroidEnvironment.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@ static Type GetFallbackHttpMessageHandlerType ()
395395
return handlerType;
396396
}
397397

398-
internal static bool VSAndroidDesignerIsEnabled { get; } = InitializeVSAndroidDesignerIsEnabled ();
399-
400-
static bool InitializeVSAndroidDesignerIsEnabled () =>
401-
!AppContext.TryGetSwitch ("Xamarin.Android.VSAndroidDesigner.IsSupported", out bool isEnabled) || isEnabled;
402-
403398
class _Proxy : IWebProxy {
404399
readonly ProxySelector selector = ProxySelector.Default!;
405400

src/Mono.Android/Android.Runtime/Logger.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public static void Log (LogLevel level, string appname, string? log) {
5555
hasNoLibLog = true;
5656
}
5757
}
58-
if (AndroidEnvironment.VSAndroidDesignerIsEnabled && hasNoLibLog)
59-
System.Console.WriteLine ("[{0}] {1}: {2}", level, appname, line);
6058
}
6159
}
6260

src/Mono.Android/ILLink/ILLink.Substitutions.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<linker>
22
<assembly fullname="Mono.Android">
3-
<type fullname="Android.Runtime.AndroidEnvironment" feature="Android.Runtime.AndroidEnvironment.VSAndroidDesignerIsEnabled" featurevalue="false">
4-
<method signature="System.Boolean get_VSAndroidDesignerIsEnabled()" body="stub" value="false" />
5-
</type>
6-
<type fullname="Java.Interop.TypeManager" feature="Android.Runtime.AndroidEnvironment.VSAndroidDesignerIsEnabled" featurevalue="false">
7-
<method signature="System.Type TypeRegistrationFallback(System.String)" body="stub" />
8-
<method signature="System.Void RegisterPackage(System.String,System.Converter`2&lt;System.String,System.Type&gt;)" body="stub" />
9-
<method signature="System.Void RegisterPackages(System.String[],System.Converter`2&lt;System.String,System.Type&gt;[])" body="stub" />
10-
</type>
113
<type fullname="Xamarin.Android.Net.AndroidMessageHandler">
124
<method signature="System.Boolean get_NegotiateAuthenticationIsEnabled()" body="stub" feature="Xamarin.Android.Net.UseNegotiateAuthentication" featurevalue="false" value="false" />
135
<method signature="System.Boolean get_NegotiateAuthenticationIsEnabled()" body="stub" feature="Xamarin.Android.Net.UseNegotiateAuthentication" featurevalue="true" value="true" />

src/Mono.Android/Java.Interop/TypeManager.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -229,34 +229,6 @@ static Exception CreateJavaLocationException ()
229229
return null;
230230
}
231231

232-
if (AndroidEnvironment.VSAndroidDesignerIsEnabled)
233-
return TypeRegistrationFallback (class_name);
234-
235-
return null;
236-
}
237-
238-
internal static Type? TypeRegistrationFallback (string class_name)
239-
{
240-
[UnconditionalSuppressMessage ("Trimming", "IL2057", Justification = "Type should be preserved by the MarkJavaObjects trimmer step.")]
241-
static Type? TypeGetType (string name) =>
242-
Type.GetType (name, throwOnError: false);
243-
244-
__TypeRegistrations.RegisterPackages ();
245-
246-
Type? type = null;
247-
int ls = class_name.LastIndexOf ('/');
248-
var package = ls >= 0 ? class_name.Substring (0, ls) : "";
249-
if (packageLookup!.TryGetValue (package, out var mappers)) {
250-
foreach (Converter<string, Type?> c in mappers) {
251-
type = c (class_name);
252-
if (type == null)
253-
continue;
254-
return type;
255-
}
256-
}
257-
if ((type = TypeGetType (JavaNativeTypeManager.ToCliType (class_name))) != null) {
258-
return type;
259-
}
260232
return null;
261233
}
262234

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
<EnableTrimAnalyzer Condition="'$(EnableTrimAnalyzer)' == '' and '$(TrimMode)' == 'full'">true</EnableTrimAnalyzer>
125125

126126
<!-- XA feature switches defaults -->
127-
<VSAndroidDesigner Condition="'$(VSAndroidDesigner)' == ''">false</VSAndroidDesigner>
128127
<AndroidUseNegotiateAuthentication Condition="'$(AndroidUseNegotiateAuthentication)' == ''">false</AndroidUseNegotiateAuthentication>
129128

130129
<!-- profiler won't work without internet permission, we must thus force it -->

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ This file contains the .NET 5-specific targets to customize ILLink
2626
<_ProguardProjectConfiguration Condition=" '$(AndroidLinkTool)' != '' ">$(IntermediateOutputPath)proguard\proguard_project_references.cfg</_ProguardProjectConfiguration>
2727
</PropertyGroup>
2828
<ItemGroup>
29-
<RuntimeHostConfigurationOption Include="Android.Runtime.AndroidEnvironment.VSAndroidDesignerIsEnabled"
30-
Condition="'$(VSAndroidDesigner)' != ''"
31-
Value="$(VSAndroidDesigner)"
32-
Trim="true" />
33-
3429
<!--
3530
Used for the <ILLink CustomData="@(_TrimmerCustomData)" /> value:
3631
https://github.com/dotnet/sdk/blob/a5393731b5b7b225692fff121f747fbbc9e8b140/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets#L147

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -512,26 +512,6 @@ void CheckAssembly (string assemblyPath, string projectDir)
512512
}
513513
}
514514

515-
[Test]
516-
public void TypeRegistrationsFallback ([Values (true, false)] bool enabled)
517-
{
518-
var proj = new XamarinAndroidApplicationProject () { IsRelease = true };
519-
if (enabled)
520-
proj.SetProperty (proj.ActiveConfigurationProperties, "VSAndroidDesigner", "true");
521-
522-
using (var b = CreateApkBuilder ()) {
523-
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
524-
var assemblyFile = "Mono.Android.dll";
525-
var assemblyPath = BuildTest.GetLinkedPath (b, true, assemblyFile);
526-
using (var assembly = AssemblyDefinition.ReadAssembly (assemblyPath)) {
527-
Assert.IsTrue (assembly != null);
528-
529-
var td = assembly.MainModule.GetType ("Java.Interop.__TypeRegistrations");
530-
Assert.IsTrue ((td != null) == enabled);
531-
}
532-
}
533-
}
534-
535515
[Test]
536516
public void AndroidUseNegotiateAuthentication ([Values (true, false, null)] bool? useNegotiateAuthentication)
537517
{

0 commit comments

Comments
 (0)