Permalink
Browse files

Add Leaks build configuration for #141

  • Loading branch information...
1 parent 8220ec6 commit 65aa0aa9737617b694558b92175387019643dac2 @dahlbyk dahlbyk committed with dahlbyk May 22, 2012
View
10 LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -32,6 +32,16 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile />
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Leaks|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Leaks\</OutputPath>
+ <DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile />
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
View
5 LibGit2Sharp.sln
@@ -8,15 +8,20 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Leaks|Any CPU = Leaks|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EE6ED99F-CB12-4683-B055-D28FC7357A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE6ED99F-CB12-4683-B055-D28FC7357A34}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EE6ED99F-CB12-4683-B055-D28FC7357A34}.Leaks|Any CPU.ActiveCfg = Leaks|Any CPU
+ {EE6ED99F-CB12-4683-B055-D28FC7357A34}.Leaks|Any CPU.Build.0 = Leaks|Any CPU
{EE6ED99F-CB12-4683-B055-D28FC7357A34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE6ED99F-CB12-4683-B055-D28FC7357A34}.Release|Any CPU.Build.0 = Release|Any CPU
{286E63EB-04DD-4ADE-88D6-041B57800761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{286E63EB-04DD-4ADE-88D6-041B57800761}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {286E63EB-04DD-4ADE-88D6-041B57800761}.Leaks|Any CPU.ActiveCfg = Leaks|Any CPU
+ {286E63EB-04DD-4ADE-88D6-041B57800761}.Leaks|Any CPU.Build.0 = Leaks|Any CPU
{286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.ActiveCfg = Release|Any CPU
{286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
View
23 LibGit2Sharp/Core/Handles/SafeHandleBase.cs
@@ -1,13 +1,36 @@
using System;
+using System.Diagnostics;
using System.Runtime.InteropServices;
namespace LibGit2Sharp.Core.Handles
{
internal abstract class SafeHandleBase : SafeHandle
{
+#if LEAKS
+ private readonly string trace;
+#endif
+
protected SafeHandleBase()
: base(IntPtr.Zero, true)
{
+#if LEAKS
+ trace = new StackTrace(2, true).ToString();
+#endif
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+#if DEBUG
+ if (!disposing && !IsInvalid)
+ {
+ Trace.WriteLine(string.Format("A {0} handle wrapper has not been properly disposed.", GetType().Name));
+#if LEAKS
+ Trace.WriteLine(trace);
+#endif
+ Trace.WriteLine("");
+ }
+#endif
+ base.Dispose(disposing);
}
public override bool IsInvalid
View
12 LibGit2Sharp/LibGit2Sharp.csproj
@@ -37,6 +37,18 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DocumentationFile>bin\Release\LibGit2Sharp.xml</DocumentationFile>
</PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Leaks|AnyCPU'">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Leaks\</OutputPath>
+ <DefineConstants>TRACE;DEBUG;NET35;LEAKS</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

0 comments on commit 65aa0aa

Please sign in to comment.