Skip to content

Commit 88415fb

Browse files
committed
Remove multiple conditions, leaving only a single condition to evaluate because conditions are OR'd, not AND'd. Using the unlikely flag will have to suffice. Also remove some stray Debug.Print methods.
1 parent cbaa7fb commit 88415fb

File tree

6 files changed

+0
-17
lines changed

6 files changed

+0
-17
lines changed

Rubberduck.VBEEditor/ComManagement/TypeLibs/TypeApiFactory.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ internal static ITypeLibWrapper GetTypeLibWrapper(IntPtr rawObjectPtr, bool addR
2626
return wrapper;
2727
}
2828

29-
[Conditional("DEBUG")]
3029
[Conditional("TRACE_TYPEAPI")]
3130
private static void TraceWrapper(ref ITypeLibWrapper wrapper)
3231
{
@@ -47,7 +46,6 @@ internal static ITypeInfoWrapper GetTypeInfoWrapper(ITypeInfo rawTypeInfo)
4746
return wrapper;
4847
}
4948

50-
[Conditional("DEBUG")]
5149
[Conditional("TRACE_TYPEAPI")]
5250
private static void TraceWrapper(ref ITypeInfoWrapper wrapper)
5351
{

Rubberduck.VBEEditor/ComManagement/TypeLibs/Unmanaged/ComPointer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ private void ReleaseUnmanagedResources()
168168
_disposed = true;
169169
}
170170

171-
[Conditional("DEBUG")]
172171
[Conditional("TRACE_COM_POINTERS")]
173172
private void TraceRelease(int rcwCount, ref bool addRef)
174173
{

Rubberduck.VBEEditor/ComManagement/TypeLibs/Unmanaged/RDMarshal.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Diagnostics;
33
using System.Linq;
4-
using System.Reflection;
54
using System.Runtime.CompilerServices;
65
using System.Runtime.InteropServices;
76
using System.Runtime.InteropServices.ComTypes;
@@ -256,7 +255,6 @@ internal static int QueryInterface(IntPtr pUnk, ref Guid iid, out IntPtr ppv)
256255
Debug.Assert(iid_local != Guid.Empty, "Empty IID passed in");
257256
});
258257

259-
Debug.Print($"Entering {nameof(QueryInterface)}; {nameof(pUnk)}: {FormatPtr(pUnk)}, {nameof(iid)}: {iid.ToString()}");
260258
Trace(TraceAction.Entering, pUnk, args: (nameof(iid), iid.ToString()));
261259
var result = Marshal.QueryInterface(pUnk, ref iid, out ppv);
262260
Trace(TraceAction.Leaving, pUnk, args: new (string Name, object Value)[]
@@ -312,7 +310,6 @@ internal static int ReleaseComObject(object o)
312310
Assert(() =>
313311
{
314312
var ptr = Marshal.GetIUnknownForObject(o);
315-
Debug.Print($"Entering {nameof(ReleaseComObject)}; {nameof(o)}: {FormatPtr(ptr)}, {o.GetType().Name}");
316313
var debugResult = Marshal.Release(ptr);
317314
Debug.Assert(debugResult > 0,
318315
$"The ref count is at zero or is invalid before calling the {nameof(Marshal.ReleaseComObject)}.");
@@ -403,8 +400,6 @@ private enum TraceAction
403400
Executing
404401
}
405402

406-
407-
[Conditional("DEBUG")]
408403
[Conditional("TRACE_MARSHAL")]
409404
private static void Trace(TraceAction action, IntPtr pUnk, [CallerMemberName]string MethodName = null, params (string Name, object Value)[] args)
410405
{
@@ -418,7 +413,6 @@ private static void Trace(TraceAction action, IntPtr pUnk, [CallerMemberName]str
418413
Debug.Print($"{Enum.GetName(typeof(TraceAction), action)} {MethodName}; {nameof(pUnk)}: {FormatPtr(pUnk)} {argPrint}");
419414
}
420415

421-
[Conditional("DEBUG")]
422416
[Conditional("TRACE_MARSHAL")]
423417
private static void Trace(TraceAction action, [CallerMemberName]string MethodName = null, params (string Name, object Value)[] args)
424418
{
@@ -431,21 +425,18 @@ private static void Trace(TraceAction action, [CallerMemberName]string MethodNam
431425
Debug.Print($"{Enum.GetName(typeof(TraceAction), action)} {MethodName}; {argPrint}");
432426
}
433427

434-
[Conditional("DEBUG")]
435428
[Conditional("TRACE_MARSHAL")]
436429
private static void Assert(Action assert)
437430
{
438431
assert.Invoke();
439432
}
440433

441-
[Conditional("DEBUG")]
442434
[Conditional("REF_COUNT")]
443435
private static void PrintRefCount(object o, int result)
444436
{
445437
Debug.Print($"{nameof(ReleaseComObject)}:: COM Object: {o.GetType().Name} ref count {result}");
446438
}
447439

448-
[Conditional("DEBUG")]
449440
[Conditional("REF_COUNT")]
450441
private static void PrintRefCount(IntPtr pUnk, [CallerMemberName] string methodName = null, int refCount = 0)
451442
{
@@ -468,14 +459,12 @@ private static void PrintRefCount(IntPtr pUnk, [CallerMemberName] string methodN
468459
}
469460
}
470461

471-
[Conditional("DEBUG")]
472462
[Conditional("REF_COUNT")]
473463
private static void PrintAlloc(IntPtr pUnmanaged, [CallerMemberName] string methodName = null)
474464
{
475465
Debug.Print($"{methodName}:: Unmanaged pointer allocated: {FormatPtr(pUnmanaged)}");
476466
}
477467

478-
[Conditional("DEBUG")]
479468
[Conditional("REF_COUNT")]
480469
private static void PrintFree(IntPtr pUnmanaged, [CallerMemberName] string methodName = null)
481470
{

Rubberduck.VBEEditor/Events/VBENativeServices.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ private static string ToClassName(this IntPtr hwnd)
295295
return name.ToString();
296296
}
297297

298-
[Conditional("DEBUG")]
299298
[Conditional("THIRSTY_DUCK_EVT")]
300299
private static void PeekMessagePump(uint eventType, IntPtr hwnd, int idObject, int idChild)
301300
{

Rubberduck.VBEEditor/SafeComWrappers/SafeComWrapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ protected virtual void Dispose(bool disposing)
157157
}
158158
}
159159

160-
[Conditional("DEBUG")]
161160
[Conditional("LOG_COM_RELEASE")]
162161
private void LogComRelease()
163162
{

Rubberduck.VBEEditor/WindowsApi/SubclassingWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public virtual int SubClassProc(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr l
9595
return DefSubclassProc(hWnd, msg, wParam, lParam);
9696
}
9797

98-
[Conditional("DEBUG")]
9998
[Conditional("THIRSTY_DUCK")]
10099
[Conditional("THIRSTY_DUCK_WM")]
101100
private static void PeekMessagePump(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr lParam)

0 commit comments

Comments
 (0)