Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Commit 0eaa47e

Browse files
authored
[Java.Interop.Tools.JavaCallableWrappers] NRT Support (#1012)
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
1 parent 45fe392 commit 0eaa47e

11 files changed

Lines changed: 146 additions & 108 deletions

File tree

‎src/Java.Interop.NamingCustomAttributes/Android.Runtime/RegisterAttribute.cs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#nullable enable
2+
13
usingSystem;
24

35
usingMono.Cecil;
@@ -10,9 +12,9 @@ namespace Android.Runtime {
1012
#endif // !JCW_ONLY_TYPE_NAMES
1113
sealedclassRegisterAttribute:Attribute,Java.Interop.IJniNameProviderAttribute{
1214

13-
stringconnector;
15+
string?connector;
1416
stringname;
15-
stringsignature;
17+
string?signature;
1618

1719
publicRegisterAttribute(stringname)
1820
{
@@ -26,22 +28,22 @@ public RegisterAttribute (string name, string signature, string connector)
2628
this.signature=signature;
2729
}
2830
#if HAVE_CECIL
29-
publicRegisterAttribute(stringname,CustomAttributeoriginAttribute)
31+
publicRegisterAttribute(stringname,CustomAttribute?originAttribute)
3032
:this(name)
3133
{
3234
OriginAttribute=originAttribute;
3335
}
3436

35-
publicRegisterAttribute(stringname,stringsignature,stringconnector,CustomAttributeoriginAttribute)
37+
publicRegisterAttribute(stringname,stringsignature,stringconnector,CustomAttribute?originAttribute)
3638
:this(name,signature,connector)
3739
{
3840
OriginAttribute=originAttribute;
3941
}
4042

41-
publicCustomAttributeOriginAttribute{get;}
43+
publicCustomAttribute?OriginAttribute{get;}
4244
#endif // HAVE_CECIL
4345

44-
publicstringConnector{
46+
publicstring?Connector{
4547
get{returnconnector;}
4648
set{connector=value;}
4749
}
@@ -51,7 +53,7 @@ public string Name {
5153
set{name=value;}
5254
}
5355

54-
publicstringSignature{
56+
publicstring?Signature{
5557
get{returnsignature;}
5658
set{signature=value;}
5759
}

‎src/Java.Interop.NamingCustomAttributes/Java.Interop/ExportAttribute.cs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#nullable enable
2+
13
usingSystem;
24

35
namespaceJava.Interop{
@@ -15,15 +17,15 @@ public ExportAttribute ()
1517
{
1618
}
1719

18-
publicExportAttribute(stringname)
20+
publicExportAttribute(string?name)
1921
{
2022
Name=name;
2123
}
2224

23-
publicstringName{get;privateset;}
24-
publicstringSuperArgumentsString{get;set;}
25-
publicType[]Throws{get;set;}
26-
internalstring[]ThrownNames{get;set;}// msbuild internal use
25+
publicstring?Name{get;privateset;}
26+
publicstring?SuperArgumentsString{get;set;}
27+
publicType[]?Throws{get;set;}
28+
internalstring[]?ThrownNames{get;set;}// msbuild internal use
2729
}
2830
}
2931

‎src/Java.Interop.Tools.Diagnostics/Java.Interop.Tools.Diagnostics/Diagnostic.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace Java.Interop.Tools.Diagnostics {
148148
//
149149

150150
publicstaticclassDiagnostic{
151-
publicstaticvoidError(intcode,SequencePointlocation,stringmessage,paramsobject[]args)
151+
publicstaticvoidError(intcode,SequencePoint?location,stringmessage,paramsobject[]args)
152152
{
153153
thrownewXamarinAndroidException(code,message,args){
154154
Location=location,

‎src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
66
<LangVersion>8.0</LangVersion>
7+
<Nullable>enable</Nullable>
78
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
89
<SignAssembly>true</SignAssembly>
910
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>

‎src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/IdentifierValidator.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public static class IdentifierValidator
3131
// We use [^ ...] to detect any character that is NOT a match.
3232
staticRegexvalidIdentifier=newRegex($"[^{Identifier}]",RegexOptions.Compiled);
3333

34-
publicstaticstringCreateValidIdentifier(stringidentifier,booluseEncodedReplacements=false)
34+
publicstaticstringCreateValidIdentifier(string?identifier,booluseEncodedReplacements=false)
3535
{
36-
if(string.IsNullOrWhiteSpace(identifier))returnstring.Empty;
36+
if(identifier==null||string.IsNullOrWhiteSpace(identifier))returnstring.Empty;
3737

3838
varnormalizedIdentifier=identifier.Normalize();
3939

0 commit comments

Comments
 (0)