Skip to content

Commit

Permalink
[Java.Interop.Tools.JavaCallableWrappers] NRT Support (#1012)
Browse files Browse the repository at this point in the history
Context: 3226a4b
Context: 7068f4b

Enable [C# 8 Nullable Reference Types][0] for
`Java.Interop.Tools.JavaCallableWrappers.dll`.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references
  • Loading branch information
jonpryor committed Jul 16, 2022
1 parent 45fe392 commit 0eaa47e
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 108 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System;

using Mono.Cecil;
Expand All @@ -10,9 +12,9 @@ namespace Android.Runtime {
#endif // !JCW_ONLY_TYPE_NAMES
sealed class RegisterAttribute : Attribute, Java.Interop.IJniNameProviderAttribute {

string connector;
string? connector;
string name;
string signature;
string? signature;

public RegisterAttribute (string name)
{
Expand All @@ -26,22 +28,22 @@ public RegisterAttribute (string name, string signature, string connector)
this.signature = signature;
}
#if HAVE_CECIL
public RegisterAttribute (string name, CustomAttribute originAttribute)
public RegisterAttribute (string name, CustomAttribute? originAttribute)
: this (name)
{
OriginAttribute = originAttribute;
}

public RegisterAttribute (string name, string signature, string connector, CustomAttribute originAttribute)
public RegisterAttribute (string name, string signature, string connector, CustomAttribute? originAttribute)
: this (name, signature, connector)
{
OriginAttribute = originAttribute;
}

public CustomAttribute OriginAttribute { get; }
public CustomAttribute? OriginAttribute { get; }
#endif // HAVE_CECIL

public string Connector {
public string? Connector {
get { return connector; }
set { connector = value; }
}
Expand All @@ -51,7 +53,7 @@ public RegisterAttribute (string name, string signature, string connector, Custo
set { name = value; }
}

public string Signature {
public string? Signature {
get { return signature; }
set { signature = value; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System;

namespace Java.Interop {
Expand All @@ -15,15 +17,15 @@ public ExportAttribute ()
{
}

public ExportAttribute (string name)
public ExportAttribute (string? name)
{
Name = name;
}

public string Name {get; private set;}
public string SuperArgumentsString {get; set;}
public Type [] Throws {get; set;}
internal string [] ThrownNames {get; set;} // msbuild internal use
public string? Name {get; private set;}
public string? SuperArgumentsString {get; set;}
public Type []? Throws {get; set;}
internal string []? ThrownNames {get; set;} // msbuild internal use
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace Java.Interop.Tools.Diagnostics {
//

public static class Diagnostic {
public static void Error (int code, SequencePoint location, string message, params object[] args)
public static void Error (int code, SequencePoint? location, string message, params object[] args)
{
throw new XamarinAndroidException (code, message, args) {
Location = location,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public static class IdentifierValidator
// We use [^ ...] to detect any character that is NOT a match.
static Regex validIdentifier = new Regex ($"[^{Identifier}]", RegexOptions.Compiled);

public static string CreateValidIdentifier (string identifier, bool useEncodedReplacements = false)
public static string CreateValidIdentifier (string? identifier, bool useEncodedReplacements = false)
{
if (string.IsNullOrWhiteSpace (identifier)) return string.Empty;
if (identifier == null || string.IsNullOrWhiteSpace (identifier)) return string.Empty;

var normalizedIdentifier = identifier.Normalize ();

Expand Down
Loading

0 comments on commit 0eaa47e

Please sign in to comment.