Skip to content

[generator] Add string cast to prevent CS1503. #970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public unsafe int GetCountForKey (string key)
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_GetCountForKey_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public unsafe int GetCountForKey (string key)
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_GetCountForKey_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public unsafe string Key {
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_set_Key_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public unsafe string Key {
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_set_Key_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class MyClass {
if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
return;

IntPtr native_p0 = JNIEnv.NewString (p0);
IntPtr native_p0 = JNIEnv.NewString ((string?)p0);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_p0);
Expand Down Expand Up @@ -153,7 +153,7 @@ public partial class MyClass {
[Register ("set_Key", "(Ljava/lang/String;)V", "Getset_Key_Ljava_lang_String_Handler")]
set {
const string __id = "set_Key.(Ljava/lang/String;)V";
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string?)value);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
Expand Down Expand Up @@ -253,7 +253,7 @@ public partial class MyClass {
public virtual unsafe int GetCountForKey (string? key)
{
const string __id = "GetCountForKey.(Ljava/lang/String;)I";
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string?)key);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string?)value);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_set_Key_Ljava_lang_String_, __args);
Expand Down Expand Up @@ -303,7 +303,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string?)key);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_GetCountForKey_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class MyClass {
if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
return;

IntPtr native_p0 = JNIEnv.NewString (p0);
IntPtr native_p0 = JNIEnv.NewString ((string)p0);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_p0);
Expand Down Expand Up @@ -153,7 +153,7 @@ public partial class MyClass {
[Register ("set_Key", "(Ljava/lang/String;)V", "Getset_Key_Ljava_lang_String_Handler")]
set {
const string __id = "set_Key.(Ljava/lang/String;)V";
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
Expand Down Expand Up @@ -253,7 +253,7 @@ public partial class MyClass {
public virtual unsafe int GetCountForKey (string key)
{
const string __id = "GetCountForKey.(Ljava/lang/String;)I";
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_set_Key_Ljava_lang_String_, __args);
Expand Down Expand Up @@ -303,7 +303,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_GetCountForKey_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public partial class MyClass {
if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
return;

IntPtr native_p0 = JNIEnv.NewString (p0);
IntPtr native_p0 = JNIEnv.NewString ((string)p0);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_p0);
Expand Down Expand Up @@ -193,7 +193,7 @@ public partial class MyClass {
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
Expand Down Expand Up @@ -299,7 +299,7 @@ public partial class MyClass {
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static IntPtr id_ctor_Ljava_lang_String_;
if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
return;

IntPtr native_p0 = JNIEnv.NewString (p0);
IntPtr native_p0 = JNIEnv.NewString ((string)p0);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_p0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public virtual unsafe int GetCountForKey (string key)
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public virtual unsafe string Key {
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (bar_jfieldId == IntPtr.Zero)
bar_jfieldId = JNIEnv.GetFieldID (class_ref, "bar", "Ljava/lang/String;");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JNIEnv.SetField (((global::Java.Lang.Object) this).Handle, bar_jfieldId, native_value);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public string bar {
set {
if (bar_jfieldId == IntPtr.Zero)
bar_jfieldId = JNIEnv.GetFieldID (class_ref, "bar", "Ljava/lang/String;");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JNIEnv.SetField (((global::Java.Lang.Object) this).Handle, bar_jfieldId, native_value);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_set_Key_Ljava_lang_String_, __args);
Expand Down Expand Up @@ -285,7 +285,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_GetCountForKey_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
set {
if (id_set_Key_Ljava_lang_String_ == IntPtr.Zero)
id_set_Key_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "set_Key", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_set_Key_Ljava_lang_String_, __args);
Expand Down Expand Up @@ -214,7 +214,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
{
if (id_GetCountForKey_Ljava_lang_String_ == IntPtr.Zero)
id_GetCountForKey_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "GetCountForKey", "(Ljava/lang/String;)I");
IntPtr native_key = JNIEnv.NewString (key);
IntPtr native_key = JNIEnv.NewString ((string)key);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_key);
var __ret = JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_GetCountForKey_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public virtual unsafe string UsePartial (int partial)
public static unsafe string UseThis (string this_)
{
const string __id = "useThis.(Ljava/lang/String;)Ljava/lang/String;";
IntPtr native_this = JNIEnv.NewString (this_);
IntPtr native_this = JNIEnv.NewString ((string)this_);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public unsafe FrameworkMediaCrypto () : base (IntPtr.Zero, JniHandleOwnership.Do
public unsafe bool RequiresSecureDecoderComponent (string p0)
{
const string __id = "requiresSecureDecoderComponent.(Ljava/lang/String;)Z";
IntPtr native_p0 = JNIEnv.NewString (p0);
IntPtr native_p0 = JNIEnv.NewString ((string)p0);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_p0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public unsafe bool RequiresSecureDecoderComponent (string p0)
{
if (id_requiresSecureDecoderComponent_Ljava_lang_String_ == IntPtr.Zero)
id_requiresSecureDecoderComponent_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "requiresSecureDecoderComponent", "(Ljava/lang/String;)Z");
IntPtr native_p0 = JNIEnv.NewString (p0);
IntPtr native_p0 = JNIEnv.NewString ((string)p0);
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_p0);
var __ret = JNIEnv.CallBooleanMethod (((global::Java.Lang.Object) this).Handle, id_requiresSecureDecoderComponent_Ljava_lang_String_, __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static void n_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ (IntPtr
public virtual unsafe void VoidMethodWithParams (string astring, int anint, global::Java.Lang.Object anObject)
{
const string __id = "VoidMethodWithParams.(Ljava/lang/String;ILjava/lang/Object;)V";
IntPtr native_astring = JNIEnv.NewString (astring);
IntPtr native_astring = JNIEnv.NewString ((string)astring);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [3];
__args [0] = new JniArgumentValue (native_astring);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public override unsafe string SomeString {
[Register ("setSomeString", "(Ljava/lang/String;)V", "GetSetSomeString_Ljava_lang_String_Handler")]
set {
const string __id = "setSomeString.(Ljava/lang/String;)V";
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static unsafe string SomeString {
[Register ("setSomeString", "(Ljava/lang/String;)V", "")]
set {
const string __id = "setSomeString.(Ljava/lang/String;)V";
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public virtual unsafe string Object {
[Register ("SetObject", "(Ljava/lang/String;)V", "GetSetObject_Ljava_lang_String_Handler")]
set {
const string __id = "SetObject.(Ljava/lang/String;)V";
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static unsafe string UseThis (string this_)
{
if (id_useThis_Ljava_lang_String_ == IntPtr.Zero)
id_useThis_Ljava_lang_String_ = JNIEnv.GetStaticMethodID (class_ref, "useThis", "(Ljava/lang/String;)Ljava/lang/String;");
IntPtr native_this = JNIEnv.NewString (this_);
IntPtr native_this = JNIEnv.NewString ((string)this_);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public virtual unsafe void VoidMethodWithParams (string astring, int anint, glob
{
if (id_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ == IntPtr.Zero)
id_VoidMethodWithParams_Ljava_lang_String_ILjava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "VoidMethodWithParams", "(Ljava/lang/String;ILjava/lang/Object;)V");
IntPtr native_astring = JNIEnv.NewString (astring);
IntPtr native_astring = JNIEnv.NewString ((string)astring);
try {
JValue* __args = stackalloc JValue [3];
__args [0] = new JValue (native_astring);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public override unsafe string SomeString {
set {
if (id_setSomeString_Ljava_lang_String_ == IntPtr.Zero)
id_setSomeString_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "setSomeString", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static unsafe string SomeString {
set {
if (id_setSomeString_Ljava_lang_String_ == IntPtr.Zero)
id_setSomeString_Ljava_lang_String_ = JNIEnv.GetStaticMethodID (class_ref, "setSomeString", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public virtual unsafe string Object {
set {
if (id_SetObject_Ljava_lang_String_ == IntPtr.Zero)
id_SetObject_Ljava_lang_String_ = JNIEnv.GetMethodID (class_ref, "SetObject", "(Ljava/lang/String;)V");
IntPtr native_value = JNIEnv.NewString (value);
IntPtr native_value = JNIEnv.NewString ((string)value);
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public string[] PreCall (CodeGenerationOptions opt, string var_name)
};
}
return new[]{
$"IntPtr {native_name} = JNIEnv.NewString ({managed_name});",
$"IntPtr {native_name} = JNIEnv.NewString ((string{opt.NullableOperator}){managed_name});",
};
}

Expand Down