Can external method parameters be renamed in C #?

I am currently cleaning up the part of our old codebase where we use methods extern

. Parameter names are all over the place in terms of naming conventions. I would like to consolidate them.

Example

[DllImport("customdll", CallingConvention = CallingConvention.Cdecl)]
public static extern void SetStatus(int new_status);

      

Is it safe to rename new_status

to newStatus

or break a contract?

ReSharper suggests this as a change, but I'd like to test it out. I couldn't find any documentation on it (for or against it).

I am not asking if it is possible to rename the method name, only parameter definitions.

Links

+3


source to share


1 answer


Yes, it is safe to change the name of the parameters (but not the method itself) as long as you keep them in the same order with their respective datatypes. Parameters in traditional DLLs are populated in order, not by name.



You can also change the name of the method itself if you use the EntryPoint parameter in the DllImport constructor.

+5


source







All Articles