Fix C# CA1063 warning by implementing the recommended Dispose methods.
Previously just the Dispose() method was generated. Now the Dispose() and Dispose(bool disposing) methods are generated. Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived" typemaps are being used. Details in #421 on Github. SWIG will error out if one of the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example error message: foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps. Closes #421
This commit is contained in:
parent
33f8c36813
commit
06462acdf9
9 changed files with 113 additions and 45 deletions
|
|
@ -13,6 +13,20 @@ public class runme
|
|||
{
|
||||
MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase");
|
||||
mpb.accessProtected();
|
||||
try {
|
||||
// C++ destructor is protected
|
||||
mpb.Dispose();
|
||||
throw new Exception("failed to catch MethodAccessException");
|
||||
} catch (MethodAccessException) {
|
||||
// Exception message: C++ destructor does not have public access
|
||||
}
|
||||
ProtectedDerived pd = new ProtectedDerived("ProtectedDerived");
|
||||
// Destroying via the ProtectedDerived's destructor should work
|
||||
pd.Dispose();
|
||||
|
||||
ProtectedBase pb = new ProtectedDerived("ProtectedDerived");
|
||||
// ProtectedDerived's destructor should be called via the Dispose(disposing) virtual call
|
||||
pb.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue