Răsfoiți Sursa

removed DEBUG by renaming #define

Charlie Kindel 5 ani în urmă
părinte
comite
254131b8c6

+ 5 - 2
Terminal.Gui/Core/Responder.cs

@@ -29,6 +29,9 @@ namespace Terminal.Gui {
 		/// For debug purposes to verify objects are being disposed properly
 		/// </summary>
 		public bool WasDisposed = false;
+		/// <summary>
+		/// For debug purposes to verify objects are being disposed properly
+		/// </summary>
 		public int DisposedCount = 0;
 		/// <summary>
 		/// For debug purposes
@@ -242,8 +245,8 @@ namespace Terminal.Gui {
 			GC.SuppressFinalize (this);
 #if DEBUG_IDISPOSABLE
 			WasDisposed = true;
-			Debug.Assert (DisposedCount == 0);
-			DisposedCount++;
+			//Debug.Assert (DisposedCount == 0);
+			//DisposedCount++;
 #endif
 		}
 	}

+ 12 - 0
Terminal.Gui/Terminal.Gui.csproj

@@ -179,6 +179,18 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType></DebugType>
   </PropertyGroup>
+
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DefineConstants>TRACE;DEBUG_IDISPOSABLE</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net472|AnyCPU'">
+    <DefineConstants>TRACE</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net472|AnyCPU'">
+    <DefineConstants>TRACE;DEBUG_IDISPOSABLE</DefineConstants>
+  </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="true" />
     <PackageReference Include="NStack.Core" Version="0.14.0" />

+ 3 - 2
UICatalog/UICatalog.cs

@@ -86,7 +86,7 @@ namespace UICatalog {
 				scenario.Setup ();
 				scenario.Run ();
 
-#if DEBUG
+#if DEBUG_IDISPOSABLE
 				foreach (var inst in Responder.Instances) {
 					Debug.Assert (inst.WasDisposed);
 				}
@@ -96,10 +96,11 @@ namespace UICatalog {
 				scenario = GetScenarioToRun ();
 			}
 
-#if DEBUG
+#if DEBUG_IDISPOSABLE
 			foreach (var inst in Responder.Instances) {
 				Debug.Assert (inst.WasDisposed);
 			}
+			Responder.Instances.Clear ();
 #endif
 		}
 

+ 8 - 0
UICatalog/UICatalog.csproj

@@ -8,6 +8,14 @@
     <LangVersion>8.0</LangVersion>
   </PropertyGroup>
 
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <DefineConstants>TRACE</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <DefineConstants>TRACE;DEBUG_IDISPOSABLE</DefineConstants>
+  </PropertyGroup>
+
   <ItemGroup>
     <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
   </ItemGroup>

+ 7 - 0
UnitTests/ApplicationTests.cs

@@ -12,6 +12,13 @@ using Console = Terminal.Gui.FakeConsole;
 
 namespace Terminal.Gui {
 	public class ApplicationTests {
+		public ApplicationTests ()
+		{
+#if DEBUG_IDISPOSABLE
+			Responder.Instances.Clear ();
+#endif
+		}
+
 		[Fact]
 		public void Init_Shutdown_Cleans_Up ()
 		{

+ 9 - 0
UnitTests/ScenarioTests.cs

@@ -10,6 +10,13 @@ using Console = Terminal.Gui.FakeConsole;
 
 namespace Terminal.Gui {
 	public class ScenarioTests {
+		public ScenarioTests ()
+		{
+#if DEBUG_IDISPOSABLE
+			Responder.Instances.Clear ();
+#endif
+		}
+
 		int CreateInput (string input)
 		{
 			// Put a control-q in at the end
@@ -75,6 +82,7 @@ namespace Terminal.Gui {
 			foreach (var inst in Responder.Instances) {
 				Assert.True (inst.WasDisposed);
 			}
+			Responder.Instances.Clear ();
 #endif
 		}
 
@@ -129,6 +137,7 @@ namespace Terminal.Gui {
 			foreach (var inst in Responder.Instances) {
 				Assert.True (inst.WasDisposed);
 			}
+			Responder.Instances.Clear ();
 #endif
 		}
 	}

+ 8 - 0
UnitTests/UnitTests.csproj

@@ -5,6 +5,14 @@
     <IsPackable>false</IsPackable>
   </PropertyGroup>
 
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <DefineConstants>TRACE</DefineConstants>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <DefineConstants>TRACE;DEBUG_IDISPOSABLE</DefineConstants>
+  </PropertyGroup>
+
   <ItemGroup>
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
     <PackageReference Include="System.Collections" Version="4.3.0" />