From b32508e7fddddb2bf0bc63ed9fbccdd55d9bcc25 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 5 Jan 2021 15:00:37 -0600 Subject: [PATCH] [generator] Change generated code to not emit CA1305 warning. --- .../Common/WriteDuplicateInterfaceEventArgs.txt | 2 +- .../JavaInterop1/ObsoleteInterfaceAlternativeClass.txt | 2 +- .../JavaInterop1/WriteDefaultInterfaceMethodInvoker.txt | 2 +- .../JavaInterop1/WriteInterface.txt | 2 +- .../JavaInterop1/WriteInterfaceDefaultMethod.txt | 2 +- .../JavaInterop1/WriteInterfaceDefaultProperty.txt | 2 +- .../JavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt | 2 +- .../JavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt | 2 +- .../JavaInterop1/WriteNestedInterfaceClass.txt | 2 +- .../JavaInterop1/WriteNestedInterfaceTypes.txt | 4 ++-- .../JavaInterop1/WriteStaticInterfaceMethod.txt | 2 +- .../JavaInterop1/WriteStaticInterfaceProperty.txt | 2 +- .../JavaInterop1/WriteUnnestedInterfaceTypes.txt | 4 ++-- .../XAJavaInterop1-NRT/WriteInterface.txt | 2 +- .../XAJavaInterop1/ObsoleteInterfaceAlternativeClass.txt | 2 +- .../XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt | 2 +- .../XAJavaInterop1/WriteInterface.txt | 2 +- .../XAJavaInterop1/WriteInterfaceDefaultMethod.txt | 2 +- .../XAJavaInterop1/WriteInterfaceDefaultProperty.txt | 2 +- .../WriteInterfaceDefaultPropertyGetterOnly.txt | 2 +- .../XAJavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt | 2 +- .../XAJavaInterop1/WriteNestedInterfaceClass.txt | 2 +- .../XAJavaInterop1/WriteNestedInterfaceTypes.txt | 4 ++-- .../XAJavaInterop1/WriteStaticInterfaceMethod.txt | 2 +- .../XAJavaInterop1/WriteStaticInterfaceProperty.txt | 2 +- .../XAJavaInterop1/WriteUnnestedInterfaceTypes.txt | 4 ++-- .../expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs | 2 +- .../expected.ji/Adapters/Xamarin.Test.IAdapter.cs | 2 +- .../expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs | 2 +- .../expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs | 2 +- .../expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs | 2 +- .../expected.ji/Core_Jar2Xml/Android.Views.View.cs | 2 +- .../Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs | 4 ++-- .../expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs | 2 +- .../expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs | 2 +- .../NestedTypes/Xamarin.Test.NotificationCompatBase.cs | 2 +- .../expected.ji/TestInterface/Test.ME.IGenericInterface.cs | 2 +- .../TestInterface/Test.ME.IGenericPropertyInterface.cs | 2 +- .../expected.ji/TestInterface/Test.ME.ITestInterface.cs | 2 +- .../expected.ji/java.lang.Enum/Java.Lang.IComparable.cs | 2 +- tools/generator/SourceWriters/InterfaceInvokerClass.cs | 2 +- 41 files changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteDuplicateInterfaceEventArgs.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteDuplicateInterfaceEventArgs.txt index 57a6aed74..e54b7fe0a 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteDuplicateInterfaceEventArgs.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/Common/WriteDuplicateInterfaceEventArgs.txt @@ -47,7 +47,7 @@ internal partial class AnimatorListenerInvoker : global::Java.Lang.Object, Anima static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.AnimatorListener")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.AnimatorListener'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/ObsoleteInterfaceAlternativeClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/ObsoleteInterfaceAlternativeClass.txt index 74c5b3e13..fbe6e214c 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/ObsoleteInterfaceAlternativeClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/ObsoleteInterfaceAlternativeClass.txt @@ -135,7 +135,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteDefaultInterfaceMethodInvoker.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteDefaultInterfaceMethodInvoker.txt index a78a81e6c..dd52db14e 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteDefaultInterfaceMethodInvoker.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteDefaultInterfaceMethodInvoker.txt @@ -72,7 +72,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterface.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterface.txt index 7ade1fa6d..9e1e2b197 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterface.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterface.txt @@ -111,7 +111,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultMethod.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultMethod.txt index b7d74e73b..0519e02e9 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultMethod.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultMethod.txt @@ -68,7 +68,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultProperty.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultProperty.txt index 3285fb854..86dc61b03 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultProperty.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultProperty.txt @@ -97,7 +97,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt index a23042001..06c671418 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt @@ -70,7 +70,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt index b779ee749..e9c2e38cb 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt @@ -43,7 +43,7 @@ internal partial class IMyInterface2Invoker : global::Java.Lang.Object, IMyInter static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface2")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface2'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceClass.txt index 8799b7a59..f45877dbb 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceClass.txt @@ -78,7 +78,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceTypes.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceTypes.txt index b1fac6fb1..ac13ce1b1 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceTypes.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteNestedInterfaceTypes.txt @@ -54,7 +54,7 @@ public partial interface IParent : IJavaObject, IJavaPeerable { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'."); return handle; } @@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceMethod.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceMethod.txt index ee52af84d..3f2286499 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceMethod.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceMethod.txt @@ -82,7 +82,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceProperty.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceProperty.txt index db0a0bb3a..94761e7ed 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceProperty.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteStaticInterfaceProperty.txt @@ -65,7 +65,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteUnnestedInterfaceTypes.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteUnnestedInterfaceTypes.txt index 2322a5ce1..d8ef1ab56 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteUnnestedInterfaceTypes.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteUnnestedInterfaceTypes.txt @@ -45,7 +45,7 @@ internal partial class IParentChildInvoker : global::Java.Lang.Object, IParentCh static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'."); return handle; } @@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt index 643f92a43..cdb8ba370 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt @@ -111,7 +111,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/ObsoleteInterfaceAlternativeClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/ObsoleteInterfaceAlternativeClass.txt index 6d885142d..1066cf81b 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/ObsoleteInterfaceAlternativeClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/ObsoleteInterfaceAlternativeClass.txt @@ -135,7 +135,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt index d376f3267..80bbdcf77 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteDefaultInterfaceMethodInvoker.txt @@ -72,7 +72,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterface.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterface.txt index 94a5aa814..3ebc0914c 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterface.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterface.txt @@ -111,7 +111,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultMethod.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultMethod.txt index 343aa4490..ef50cb158 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultMethod.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultMethod.txt @@ -68,7 +68,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultProperty.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultProperty.txt index e0d621db1..c10907ab8 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultProperty.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultProperty.txt @@ -97,7 +97,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt index 889176e7a..595e6de5e 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceDefaultPropertyGetterOnly.txt @@ -70,7 +70,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt index 0e70bbbfc..76ebb857e 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceRedeclaredDefaultMethod.txt @@ -43,7 +43,7 @@ internal partial class IMyInterface2Invoker : global::Java.Lang.Object, IMyInter static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface2")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface2'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceClass.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceClass.txt index 50a270a50..635d09f5e 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceClass.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceClass.txt @@ -78,7 +78,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceTypes.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceTypes.txt index 4b5d1f6f0..1d9557528 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceTypes.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteNestedInterfaceTypes.txt @@ -54,7 +54,7 @@ public partial interface IParent : IJavaObject, IJavaPeerable { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'."); return handle; } @@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceMethod.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceMethod.txt index 3b0d60816..a2f3e5f59 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceMethod.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceMethod.txt @@ -82,7 +82,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceProperty.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceProperty.txt index bbfc235e9..8afb38a63 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceProperty.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceProperty.txt @@ -65,7 +65,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'."); return handle; } diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteUnnestedInterfaceTypes.txt b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteUnnestedInterfaceTypes.txt index 676225cf3..c434c906f 100644 --- a/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteUnnestedInterfaceTypes.txt +++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteUnnestedInterfaceTypes.txt @@ -45,7 +45,7 @@ internal partial class IParentChildInvoker : global::Java.Lang.Object, IParentCh static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent.Child")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent.Child'."); return handle; } @@ -138,7 +138,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent { static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.xamarin.android.Parent'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs index 02d4738e4..9a482e985 100644 --- a/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs +++ b/tests/generator-Tests/expected.ji/AccessModifiers/Xamarin.Test.PublicClass.cs @@ -53,7 +53,7 @@ public static IProtectedInterface GetObject (IntPtr handle, JniHandleOwnership t static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.PublicClass.ProtectedInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.PublicClass.ProtectedInterface'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs index 7479c86b7..8d197615c 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs @@ -46,7 +46,7 @@ public static IAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.Adapter")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.Adapter'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs index 9ff2a7638..9852897fc 100644 --- a/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs +++ b/tests/generator-Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs @@ -46,7 +46,7 @@ public static ISpinnerAdapter GetObject (IntPtr handle, JniHandleOwnership trans static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.SpinnerAdapter")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.SpinnerAdapter'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs index 66511adce..d02344c46 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpannable.cs @@ -46,7 +46,7 @@ public static ISpannable GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "android.text.Spannable")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spannable'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs index e91387d36..d668acb08 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Text.ISpanned.cs @@ -51,7 +51,7 @@ public static ISpanned GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "android.text.Spanned")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.text.Spanned'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs index 35d48977c..d1df8da63 100644 --- a/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs +++ b/tests/generator-Tests/expected.ji/Core_Jar2Xml/Android.Views.View.cs @@ -53,7 +53,7 @@ public static IOnClickListener GetObject (IntPtr handle, JniHandleOwnership tran static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "android.view.View.OnClickListener")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'android.view.View.OnClickListener'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs b/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs index 4928e0dcc..4768d16cf 100644 --- a/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs +++ b/tests/generator-Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs @@ -51,7 +51,7 @@ public static IExoMediaDrmOnEventListener GetObject (IntPtr handle, JniHandleOwn static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaDrm.OnEventListener'."); return handle; } @@ -237,7 +237,7 @@ public static IExoMediaDrm GetObject (IntPtr handle, JniHandleOwnership transfer static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.google.android.exoplayer.drm.ExoMediaDrm")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'com.google.android.exoplayer.drm.ExoMediaDrm'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs index 08c191861..75ea1a3c2 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II1.cs @@ -50,7 +50,7 @@ public static II1 GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.I1")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.I1'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs index 6611e27a0..ac69ad552 100644 --- a/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs +++ b/tests/generator-Tests/expected.ji/InterfaceMethodsConflict/Xamarin.Test.II2.cs @@ -50,7 +50,7 @@ public static II2 GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.I2")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.I2'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs index aa3dac3a0..1a9ef663a 100644 --- a/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs +++ b/tests/generator-Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -56,7 +56,7 @@ public static IFactory GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "xamarin.test.NotificationCompatBase.Action.Factory")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'xamarin.test.NotificationCompatBase.Action.Factory'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs index 826b4f568..55919db03 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs @@ -51,7 +51,7 @@ public static IGenericInterface GetObject (IntPtr handle, JniHandleOwnership tra static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "test.me.GenericInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.GenericInterface'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs index c7171a455..f32b194c8 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs @@ -57,7 +57,7 @@ public static IGenericPropertyInterface GetObject (IntPtr handle, JniHandleOwner static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "test.me.GenericPropertyInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.GenericPropertyInterface'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs index a63a97a79..25e8fca1c 100644 --- a/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs +++ b/tests/generator-Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs @@ -112,7 +112,7 @@ public static ITestInterface GetObject (IntPtr handle, JniHandleOwnership transf static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "test.me.TestInterface")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'test.me.TestInterface'."); return handle; } diff --git a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs index ebe536f95..e5d745baa 100644 --- a/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs +++ b/tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs @@ -51,7 +51,7 @@ public static IComparable GetObject (IntPtr handle, JniHandleOwnership transfer) static IntPtr Validate (IntPtr handle) { if (!JNIEnv.IsInstanceOf (handle, java_class_ref)) - throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.lang.Comparable")); + throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.lang.Comparable'."); return handle; } diff --git a/tools/generator/SourceWriters/InterfaceInvokerClass.cs b/tools/generator/SourceWriters/InterfaceInvokerClass.cs index 4c6db530c..683f4b191 100644 --- a/tools/generator/SourceWriters/InterfaceInvokerClass.cs +++ b/tools/generator/SourceWriters/InterfaceInvokerClass.cs @@ -132,7 +132,7 @@ public ValidateMethod (InterfaceGen iface) Parameters.Add (new MethodParameterWriter ("handle", TypeReferenceWriter.IntPtr)); Body.Add ("if (!JNIEnv.IsInstanceOf (handle, java_class_ref))"); - Body.Add ($"\tthrow new InvalidCastException (string.Format (\"Unable to convert instance of type '{{0}}' to type '{{1}}'.\", JNIEnv.GetClassNameFromInstance (handle), \"{iface.JavaName}\"));"); + Body.Add ($"\tthrow new InvalidCastException ($\"Unable to convert instance of type '{{JNIEnv.GetClassNameFromInstance (handle)}}' to type '{iface.JavaName}'.\");"); Body.Add ("return handle;"); } }