Skip to content

Commit daec07b

Browse files
authored
[build] Fix various warnings (#812)
Update `Java.Interop.dll` to fix some nullable reference type warnings. Update `Java.Interop.Localization.csproj` to add `$(NeutralLanguage)`=en, which fixes: Warning CA1824: Mark assemblies with NeutralResourcesLanguageAttribute This basically says that the "neutral" language within `Java.Interop.Localization.dll` is also the English translation, so we don't need to spend time probing for satellite resource assemblies when the English language is requested. Update `Java.Runtime.Environment.csproj` to add `$(MSBuildWarningsAsMessages)`=NU1702, to suppress the following: Warning NU1702: ProjectReference 'D:\a\1\s\src\java-interop\java-interop.csproj' was resolved using '.NETFramework,Version=v4.7.2' instead of the project target framework '.NETStandard,Version=v2.0'. This project may not be fully compatible with your project.
1 parent 678c4bd commit daec07b

File tree

6 files changed

+8
-3
lines changed

6 files changed

+8
-3
lines changed

src/Java.Interop.Localization/Java.Interop.Localization.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<LangVersion>8.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
8+
<NeutralLanguage>en</NeutralLanguage>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Java.Interop/Java.Interop/JavaArray.cs

+3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public int Length {
3030

3131
[MaybeNull]
3232
public abstract T this [int index] {
33+
// I think this will be fixable in .NET5+ with support for "T?"
34+
#pragma warning disable CS8766 // Nullability of reference types in return type doesn't match implicitly implemented member (possibly because of nullability attributes).
3335
get;
36+
#pragma warning restore CS8766
3437
set;
3538
}
3639

src/Java.Interop/Java.Interop/JniEnvironment.Types.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static void RegisterNatives (JniObjectReference type, JniNativeMethodRegi
180180
var method = m.Marshaler.Method;
181181
Debug.WriteLine ($"JNIEnv::RegisterNatives() given a generic delegate type. .NET Core doesn't like this.");
182182
Debug.WriteLine ($" Java: {m.Name}{m.Signature}");
183-
Debug.WriteLine ($" Marshaler Type={m.Marshaler.GetType ().FullName} Method={method.DeclaringType.FullName}.{method.Name}");
183+
Debug.WriteLine ($" Marshaler Type={m.Marshaler.GetType ().FullName} Method={method.DeclaringType!.FullName}.{method.Name}");
184184
}
185185
}
186186
#endif // DEBUG && NETCOREAPP

src/Java.Interop/Java.Interop/JniRuntime.JniMarshalMemberBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public Delegate CreateMarshalToM
8787
{
8888
if (value == null)
8989
throw new ArgumentNullException (nameof (value));
90-
return CreateMarshalToManagedExpression (value.GetMethodInfo ()).Compile ();
90+
return CreateMarshalToManagedExpression (value.GetMethodInfo ()!).Compile ();
9191
}
9292

9393
public abstract LambdaExpression CreateMarshalToManagedExpression (MethodInfo method);

src/Java.Interop/Java.Interop/JniType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Java.Interop {
1414

1515
public sealed class JniType : IDisposable {
1616

17-
[return: NotNullIfNotNull ("name")]
17+
[return: NotNullIfNotNull ("classFileData")]
1818
public static unsafe JniType? DefineClass (string name, JniObjectReference loader, byte[] classFileData)
1919
{
2020
if (classFileData == null)

src/Java.Runtime.Environment/Java.Runtime.Environment.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<LangVersion>8.0</LangVersion>
99
<Nullable>enable</Nullable>
10+
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
1011
</PropertyGroup>
1112

1213
<PropertyGroup>

0 commit comments

Comments
 (0)