From cff9786d6bac334271b7eb11641c7b6dfad3772b Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Sat, 4 Jul 2026 08:47:48 +0200 Subject: [PATCH] Fix build warnings in jnienv-gen project --- Directory.Build.props | 1 - build-tools/jnienv-gen/Generator.cs | 28 ++++++---------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 808e27ca4d0..c28659799a3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -68,7 +68,6 @@ This can be opted into locally with $(_AndroidTreatWarningsAsErrors) = true. --> - <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'jnienv-gen.csproj' ">true <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Mono.Android.csproj' ">true <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Mono.Android.NET-Tests.csproj' ">true <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'MSBuildDeviceIntegration.csproj' ">true diff --git a/build-tools/jnienv-gen/Generator.cs b/build-tools/jnienv-gen/Generator.cs index 14a290c98e4..dffd88e3c2a 100644 --- a/build-tools/jnienv-gen/Generator.cs +++ b/build-tools/jnienv-gen/Generator.cs @@ -120,15 +120,6 @@ static void GenerateJniNativeInterfaceInvoker (TextWriter o) o.WriteLine ("\t\tpublic unsafe JniNativeInterfaceInvoker (JniNativeInterfaceStruct* p)"); o.WriteLine ("\t\t{"); o.WriteLine ("\t\t\tJniEnv = *p;"); - - foreach (var e in JNIEnvEntries) { - if (e.Delegate == null) - continue; - if (!e.Prebind) - continue; - o.WriteLine ("\t\t\t{0}", Initialize (e, "")); - } - o.WriteLine ("\t\t}"); o.WriteLine (); @@ -136,16 +127,12 @@ static void GenerateJniNativeInterfaceInvoker (TextWriter o) if (e.Delegate == null) continue; o.WriteLine (); - if (e.Prebind) - o.WriteLine ("\t\tpublic readonly {0} {1};\n", e.Delegate, e.Name); - else { - o.WriteLine ("\t\t{0} _{1};", e.Delegate, e.Name); - o.WriteLine ("\t\tpublic {0} {1} {{", e.Delegate, e.Name); - o.WriteLine ("\t\t\tget {"); - o.WriteLine ("\t\t\t\tif (_{0} == null)\n\t\t\t\t\t{1}", e.Name, Initialize (e, "_")); - o.WriteLine ("\t\t\t\treturn _{0};\n\t\t\t}}", e.Name); - o.WriteLine ("\t\t}"); - } + o.WriteLine ("\t\t{0} _{1};", e.Delegate, e.Name); + o.WriteLine ("\t\tpublic {0} {1} {{", e.Delegate, e.Name); + o.WriteLine ("\t\t\tget {"); + o.WriteLine ("\t\t\t\tif (_{0} == null)\n\t\t\t\t\t{1}", e.Name, Initialize (e, "_")); + o.WriteLine ("\t\t\t\treturn _{0};\n\t\t\t}}", e.Name); + o.WriteLine ("\t\t}"); } o.WriteLine ("\t}"); @@ -520,9 +507,6 @@ public string ApiName public TypeInfo ReturnType; public ParamInfo [] Parameters; - // If true, then we initialize the binding on the static ctor, we dont lazy-define it - public bool Prebind; - // If there is a custom wrapper in JNIEnv (so an automatic one shouldn't be generated) public bool CustomWrapper;