Skip to content

Commit

Permalink
[build] Fix various warnings (#812)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jpobst committed Mar 6, 2021
1 parent 678c4bd commit daec07b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
Expand Up @@ -5,6 +5,7 @@
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<DefineConstants>INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/Java.Interop/Java.Interop/JavaArray.cs
Expand Up @@ -30,7 +30,10 @@ internal JavaArray (ref JniObjectReference handle, JniObjectReferenceOptions tra

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

Expand Down
2 changes: 1 addition & 1 deletion src/Java.Interop/Java.Interop/JniEnvironment.Types.cs
Expand Up @@ -180,7 +180,7 @@ public static void RegisterNatives (JniObjectReference type, JniNativeMethodRegi
var method = m.Marshaler.Method;
Debug.WriteLine ($"JNIEnv::RegisterNatives() given a generic delegate type. .NET Core doesn't like this.");
Debug.WriteLine ($" Java: {m.Name}{m.Signature}");
Debug.WriteLine ($" Marshaler Type={m.Marshaler.GetType ().FullName} Method={method.DeclaringType.FullName}.{method.Name}");
Debug.WriteLine ($" Marshaler Type={m.Marshaler.GetType ().FullName} Method={method.DeclaringType!.FullName}.{method.Name}");
}
}
#endif // DEBUG && NETCOREAPP
Expand Down
Expand Up @@ -87,7 +87,7 @@ public Delegate CreateMarshalToM
{
if (value == null)
throw new ArgumentNullException (nameof (value));
return CreateMarshalToManagedExpression (value.GetMethodInfo ()).Compile ();
return CreateMarshalToManagedExpression (value.GetMethodInfo ()!).Compile ();
}

public abstract LambdaExpression CreateMarshalToManagedExpression (MethodInfo method);
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Interop/Java.Interop/JniType.cs
Expand Up @@ -14,7 +14,7 @@ namespace Java.Interop {

public sealed class JniType : IDisposable {

[return: NotNullIfNotNull ("name")]
[return: NotNullIfNotNull ("classFileData")]
public static unsafe JniType? DefineClass (string name, JniObjectReference loader, byte[] classFileData)
{
if (classFileData == null)
Expand Down
Expand Up @@ -7,6 +7,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit daec07b

Please sign in to comment.