Skip to content

Commit f1b9365

Browse files
authored
[generator] Change generated code to not emit CA1305 warning. (#771)
Fixes: #763 Today we generate this code: ``` throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); ``` In newer CSC versions (.NET5+), this produces a [CA1305](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1305) warning. We can avoid this warning with string interpolation: ``` throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); ```
1 parent 2244407 commit f1b9365

File tree

41 files changed

+46
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+46
-46
lines changed

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteDuplicateInterfaceEventArgs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal partial class AnimatorListenerInvoker : global::Java.Lang.Object, Anima
4747
static IntPtr Validate (IntPtr handle)
4848
{
4949
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
50-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.AnimatorListener"));
50+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.AnimatorListener'.");
5151
return handle;
5252
}
5353

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/ObsoleteInterfaceAlternativeClass.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
135135
static IntPtr Validate (IntPtr handle)
136136
{
137137
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
138-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
138+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
139139
return handle;
140140
}
141141

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteDefaultInterfaceMethodInvoker.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
7272
static IntPtr Validate (IntPtr handle)
7373
{
7474
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
75-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
75+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
7676
return handle;
7777
}
7878

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterface.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
111111
static IntPtr Validate (IntPtr handle)
112112
{
113113
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
114-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
114+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
115115
return handle;
116116
}
117117

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultMethod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
6868
static IntPtr Validate (IntPtr handle)
6969
{
7070
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
71-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
71+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
7272
return handle;
7373
}
7474

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultProperty.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
9797
static IntPtr Validate (IntPtr handle)
9898
{
9999
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
100-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
100+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
101101
return handle;
102102
}
103103

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
7070
static IntPtr Validate (IntPtr handle)
7171
{
7272
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
73-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
73+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
7474
return handle;
7575
}
7676

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal partial class IMyInterface2Invoker : global::Java.Lang.Object, IMyInter
4343
static IntPtr Validate (IntPtr handle)
4444
{
4545
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
46-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface2"));
46+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface2'.");
4747
return handle;
4848
}
4949

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceClass.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
7878
static IntPtr Validate (IntPtr handle)
7979
{
8080
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
81-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
81+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
8282
return handle;
8383
}
8484

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceTypes.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public partial interface IParent : IJavaObject, IJavaPeerable {
5454
static IntPtr Validate (IntPtr handle)
5555
{
5656
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
57-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child"));
57+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'.");
5858
return handle;
5959
}
6060

@@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
138138
static IntPtr Validate (IntPtr handle)
139139
{
140140
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
141-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
141+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
142142
return handle;
143143
}
144144

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceMethod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
8282
static IntPtr Validate (IntPtr handle)
8383
{
8484
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
85-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
85+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
8686
return handle;
8787
}
8888

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceProperty.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
6565
static IntPtr Validate (IntPtr handle)
6666
{
6767
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
68-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
68+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
6969
return handle;
7070
}
7171

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteUnnestedInterfaceTypes.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal partial class IParentChildInvoker : global::Java.Lang.Object, IParentCh
4545
static IntPtr Validate (IntPtr handle)
4646
{
4747
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
48-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child"));
48+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'.");
4949
return handle;
5050
}
5151

@@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
138138
static IntPtr Validate (IntPtr handle)
139139
{
140140
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
141-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
141+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
142142
return handle;
143143
}
144144

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
111111
static IntPtr Validate (IntPtr handle)
112112
{
113113
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
114-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
114+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
115115
return handle;
116116
}
117117

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/ObsoleteInterfaceAlternativeClass.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
135135
static IntPtr Validate (IntPtr handle)
136136
{
137137
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
138-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
138+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
139139
return handle;
140140
}
141141

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
7272
static IntPtr Validate (IntPtr handle)
7373
{
7474
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
75-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
75+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
7676
return handle;
7777
}
7878

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterface.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
111111
static IntPtr Validate (IntPtr handle)
112112
{
113113
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
114-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
114+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
115115
return handle;
116116
}
117117

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultMethod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
6868
static IntPtr Validate (IntPtr handle)
6969
{
7070
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
71-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
71+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
7272
return handle;
7373
}
7474

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultProperty.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
9797
static IntPtr Validate (IntPtr handle)
9898
{
9999
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
100-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
100+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
101101
return handle;
102102
}
103103

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
7070
static IntPtr Validate (IntPtr handle)
7171
{
7272
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
73-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
73+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
7474
return handle;
7575
}
7676

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal partial class IMyInterface2Invoker : global::Java.Lang.Object, IMyInter
4343
static IntPtr Validate (IntPtr handle)
4444
{
4545
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
46-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface2"));
46+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface2'.");
4747
return handle;
4848
}
4949

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceClass.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
7878
static IntPtr Validate (IntPtr handle)
7979
{
8080
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
81-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
81+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
8282
return handle;
8383
}
8484

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceTypes.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public partial interface IParent : IJavaObject, IJavaPeerable {
5454
static IntPtr Validate (IntPtr handle)
5555
{
5656
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
57-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child"));
57+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'.");
5858
return handle;
5959
}
6060

@@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
138138
static IntPtr Validate (IntPtr handle)
139139
{
140140
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
141-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
141+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
142142
return handle;
143143
}
144144

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceMethod.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
8282
static IntPtr Validate (IntPtr handle)
8383
{
8484
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
85-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
85+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
8686
return handle;
8787
}
8888

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceProperty.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
6565
static IntPtr Validate (IntPtr handle)
6666
{
6767
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
68-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
68+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");
6969
return handle;
7070
}
7171

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteUnnestedInterfaceTypes.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal partial class IParentChildInvoker : global::Java.Lang.Object, IParentCh
4545
static IntPtr Validate (IntPtr handle)
4646
{
4747
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
48-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child"));
48+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'.");
4949
return handle;
5050
}
5151

@@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
138138
static IntPtr Validate (IntPtr handle)
139139
{
140140
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
141-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
141+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'.");
142142
return handle;
143143
}
144144

tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static IProtectedInterface GetObject (IntPtr handle, JniHandleOwnership t
5353
static IntPtr Validate (IntPtr handle)
5454
{
5555
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
56-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.PublicClass.ProtectedInterface"));
56+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.PublicClass.ProtectedInterface'.");
5757
return handle;
5858
}
5959

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static IAdapter GetObject (IntPtr handle, JniHandleOwnership transfer)
4646
static IntPtr Validate (IntPtr handle)
4747
{
4848
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
49-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.Adapter"));
49+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.Adapter'.");
5050
return handle;
5151
}
5252

tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static ISpinnerAdapter GetObject (IntPtr handle, JniHandleOwnership trans
4646
static IntPtr Validate (IntPtr handle)
4747
{
4848
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
49-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.SpinnerAdapter"));
49+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.SpinnerAdapter'.");
5050
return handle;
5151
}
5252

tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static ISpannable GetObject (IntPtr handle, JniHandleOwnership transfer)
4646
static IntPtr Validate (IntPtr handle)
4747
{
4848
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
49-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "android.text.Spannable"));
49+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spannable'.");
5050
return handle;
5151
}
5252

tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static ISpanned GetObject (IntPtr handle, JniHandleOwnership transfer)
5151
static IntPtr Validate (IntPtr handle)
5252
{
5353
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
54-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "android.text.Spanned"));
54+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spanned'.");
5555
return handle;
5656
}
5757

tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static IOnClickListener GetObject (IntPtr handle, JniHandleOwnership tran
5353
static IntPtr Validate (IntPtr handle)
5454
{
5555
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
56-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "android.view.View.OnClickListener"));
56+
throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.view.View.OnClickListener'.");
5757
return handle;
5858
}
5959

0 commit comments

Comments
 (0)