How can we help you today? How can we help you today?

Private method access - wrong

Hi,
I've seen in some assemblies the following issue:

when a class implements some interface, the implemented methods cant be private, dont know if its up to protector or smth else. Is it possbile to add analysis in Refl to make these methods public?

example


source module with issues
=================

using System;
using System.Runtime.InteropServices;

public class c000806 : afv, IDisposable
{
private int f000002;
private int f00002f;
private IntPtr f000058;

public c000806(int A_0)
{
this.f000058 = Marshal.AllocCoTaskMem(A_0);
this.f000002 = A_0;
}

public void Dispose()
{
if (this.f000058 != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(this.f000058);
this.f000058 = IntPtr.Zero;
GC.SuppressFinalize(this);
}
}

~c000806()
{
this.Dispose();
}

public int m00000c()
{
return this.f00002f;
}

private int m000025(int A_0)
{
if (A_0 > this.f000002)
{
return -2147483645;
}
this.f00002f = A_0;
return 0;
}

private int m000025(out int A_0)
{
A_0 = this.f000002;
return 0;
}

public void m00003f(int A_0)
{
if (this.f00002f > this.f000002)
{
throw new ArgumentException("Cannot be greater than maximum buffer size");
}
this.f00002f = A_0;
}

private int m00055e(IntPtr A_0, IntPtr A_1)
{
if (A_0 != IntPtr.Zero)
{
Marshal.WriteIntPtr(A_0, this.f000058);
}
if (A_1 != IntPtr.Zero)
{
Marshal.WriteInt32(A_1, this.f00002f);
}
return 0;
}

public void m0009b5(byte[] A_0, int A_1)
{
this.m00003f(A_1);
Marshal.Copy(A_0, 0, this.f000058, A_1);
}

public void m000d5c(byte[] A_0, int A_1)
{
Marshal.Copy(this.f000058, A_0, A_1, this.m00000c());
}
}


interface
================
using System;
using System.Runtime.InteropServices;
using System.Security;

[ComImport, Guid("59eff8b9-938c-4a26-82f2-95cb84cdc837"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), SuppressUnmanagedCodeSecurity]
public interface afv
{
[PreserveSig]
int m000025(int A_0);
[PreserveSig]
int m000025(out int A_0);
[PreserveSig]
int m00055e(IntPtr A_0, IntPtr A_1);
}





issues
================

Error 3 'c000806' does not implement interface member 'afv.m000025(int)'. 'c000806.m000025(int)' cannot implement an interface member because it is not public.
Error 2 'c000806' does not implement interface member 'afv.m000025(out int)'. 'c000806.m000025(out int)' cannot implement an interface member because it is not public.
Error 1 'c000806' does not implement interface member 'afv.m00055e(System.IntPtr, System.IntPtr)'. 'c000806.m00055e(System.IntPtr, System.IntPtr)' cannot implement an interface member because it is not public. \NS371857150\c000806.cs 4 14
alehandro
0

Comments

4 comments

  • alehandro
    another sample:


    public class c00086a : IDisposable
    {
    ....

    private void Dispose() << private!!!??
    {
    try
    ....
    }
    }

    Error 54 'c00086a' does not implement interface member 'System.IDisposable.Dispose()'. 'c00086a.Dispose()' cannot implement an interface member because it is not public.
    alehandro
    0
  • Clive Tong
    I've logged that as RP-1028.
    Clive Tong
    0
  • screenpresso
    Hi,
    I am from Screenpresso software development team and I would be pleased to know why you, alehandro, are trying to disable our software which is something illegal.
    If you have any questions, fell free to contact us.
    Regards,
    Screenpresso team
    screenpresso
    0
  • alehandro
    Hi,
    I'm glad you are reading my poor posts
    Well, of course I"m not trying to disable any SW, my only aim was to make the tool more correct in some specific cases.
    As you see that case was to correct public/private visibility of members.

    My apoligies if I offend you.
    alehandro
    0

Add comment

Please sign in to leave a comment.