- IntPtr should be checked by IntPtr.Zero because it is value type
- Add an exception handler to avoid invalid type at 'Listen' method
Change-Id: I6f5613e6d27050e3b0c314ff5c24e0c6f9ff5303
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
);
stream << NLine(1);
- stream << Tab(4) << "private IntPtr _port = IntPtr.Zero;" << NLine(1);
+ stream << Tab(4) << "private IntPtr _port;" << NLine(1);
stream << Tab(4) << "public delegate void Callback(";
GenParameters(stream, decl.GetParameters());
stream << ");" << NLine(1);
" {\n" \
" }\n" \
"\n" \
- " if (_proxy != null)\n" \
+ " if (_proxy != IntPtr.Zero)\n" \
" Interop.LibRPCPort.Proxy.Destroy(_proxy);\n" \
"\n" \
" disposedValue = true;\n" \
const char method_listen[] =
"public void Listen(Type serviceType)\n" \
"{\n" \
+ " if (!typeof(ServiceBase).IsAssignableFrom(serviceType))\n" \
+ " throw new InvalidOperationException(\"Invalid type\");\n" \
" _serviceType = serviceType;\n" \
" Interop.LibRPCPort.Stub.Listen(_stub);\n" \
"}\n";
" }\n" \
"\n" \
" _services = null;\n" \
- " if (_stub != null)\n" \
+ " if (_stub != IntPtr.Zero)\n" \
" Interop.LibRPCPort.Stub.Destroy(_stub);\n" \
" disposedValue = true;\n" \
" }\n" \