[MWB][CQ]Refactoring "Common" classes - Common.Log.cs (#35156)

* [MouseWithoutBorders] - split "Common.Log.cs" into "Logger.cs"

* [MouseWithoutBorders] - fix references to Logger

* [MouseWithoutBorders] - add MouseWithoutBorders.UnitTests

* [MouseWithoutBorders] - fixing broken tests

* [MouseWithoutBorders] - fixing spelling

* [MouseWithoutBorders] - fixing spelling

* [MouseWithoutBorders] - fixing resource filename casing

* [MouseWithoutBorders] - fixing resource filename casing

* [MouseWithoutBorders] - fixing resource filename casing

* [MouseWithoutBorders] - fixing resource filename casing

* [MouseWithoutBorders] - fixed compile error

* [MouseWithoutBorders] - fixed failing test

* [MouseWithoutBorders] - fixed failing build

* [MouseWithoutBorders] - ignore flakey test
This commit is contained in:
Michael Clayton
2024-10-18 17:32:08 +01:00
committed by GitHub
parent 37eaf10bf0
commit 5cba82f929
37 changed files with 1965 additions and 839 deletions

View File

@@ -0,0 +1,404 @@
[Program logs]
===============
= System.String[]
[Other Logs]
===============
= MouseWithoutBorders.Common
lastClipboardEventTime = 0
clipboardCopiedTime = 0
Comma = System.Char[]
--System.Char[] = System.Char[]: N/A
Star = System.Char[]
--System.Char[] = System.Char[]: N/A
NullSeparator = System.Char[]
--System.Char[] = System.Char[]: N/A
<LastIDWithClipboardData>k__BackingField = NONE
<NextClipboardViewer>k__BackingField = 0
<IsClipboardDataImage>k__BackingField = False
lastClipboardObject =
<HasSwitchedMachineSinceLastCopy>k__BackingField = False
ClipboardThreadOldLock = O
screenWidth = 0
screenHeight = 0
lastX = 0
lastY = 0
mainFormVisible = True
runOnLogonDesktop = False
runOnScrSaverDesktop = False
toggleIconsIndex = 0
EvSwitch = EventWaitHandle
lastPos = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
switchCount = 0
lastReconnectByHotKeyTime = 0
tcpPort = 0
secondOpenSocketTry = False
binaryName = MM
<PaintCount>k__BackingField = 0
<RunWithNoAdminRight>k__BackingField = False
<Is64bitOS>k__BackingField = False
socketMutexBalance = 0
<BlockingUI>k__BackingField = False
<UIThreadID>k__BackingField = 0
<InputCallbackThreadID>k__BackingField = 0
InputSimulationLock = O
lastSendNextMachine = 0
lastInputEventCount = 0
lastRealInputEventCount = 0
minSendTime = 9223372036854775807
avgSendTime = 0
maxSendTime = 0
totalSendCount = 0
totalSendTime = 0
isDragging = False
dragDropStep05ExCalledByIpc = 0
isDropping = False
dragMachine = NONE
<MouseDown>k__BackingField = False
magicNumber = 0
ran = System.Random
--_impl = System.Random+XoshiroImpl
----_s0 = ????????????
----_s1 = ????????????
----_s2 = ????????????
----_s3 = ????????????
--<Shared>k__BackingField = System.Random+ThreadSafeRandom
InitialIV = ????????????
<GeneratedKey>k__BackingField = False
<KeyCorrupted>k__BackingField = False
LegalKeyDictionary = Concurrent.ConcurrentDictionary`2[System.String,System.Byte[]]
--_tables = Concurrent.ConcurrentDictionary`2+Tables[System.String,System.Byte[]]
----_comparer = Generic.NonRandomizedStringEqualityComparer+OrdinalIgnoreCaseComparer
----_buckets = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Byte[]][]
------System.Collections.Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Byte[]][] = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Byte[]][]: N/A
----_fastModBucketsMultiplier = 498560650640798693
----_locks = O[]
------System.Object[] = O[]: N/A
----_countPerLock = 32[]
------[0] = 0
------[1] = 0
------[2] = 0
------[3] = 0
------[4] = 0
------[5] = 0
------[6] = 0
------[7] = 0
------[8] = 0
------[9] = 0
------[10] = 0
------[11] = 0
------[12] = 0
------[13] = 0
------[14] = 0
------[15] = 0
--_budget = 2
--_growLockArray = True
--_comparerIsDefaultForClasses = False
KeybdPackage = MouseWithoutBorders.DATA
--Type = 0
--Id = 0
--Src = NONE
--Des = NONE
--DateTime = 0
--Kd = MouseWithoutBorders.KEYBDDATA
--Md = MouseWithoutBorders.MOUSEDATA
--Machine1 = NONE
--Machine2 = NONE
--Machine3 = NONE
--Machine4 = NONE
--PostAction = Other
--machineNameP1 = 0
--machineNameP2 = 0
--machineNameP3 = 0
--machineNameP4 = 0
MousePackage = MouseWithoutBorders.DATA
--Type = 0
--Id = 0
--Src = NONE
--Des = NONE
--DateTime = 0
--Kd = MouseWithoutBorders.KEYBDDATA
--Md = MouseWithoutBorders.MOUSEDATA
--Machine1 = NONE
--Machine2 = NONE
--Machine3 = NONE
--Machine4 = NONE
--PostAction = Other
--machineNameP1 = 0
--machineNameP2 = 0
--machineNameP3 = 0
--machineNameP4 = 0
inputEventCount = 0
invalidPackageCount = 0
MOVE_MOUSE_RELATIVE = 100000
XY_BY_PIXEL = 300000
<RealInputEventCount>k__BackingField = 0
actualLastPos = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
myLastX = 0
myLastY = 0
signalHelperToExit = False
signalWatchDogToExit = False
WndProcCounter = 0
initDone = False
REOPEN_WHEN_WSAECONNRESET = -10054
REOPEN_WHEN_HOTKEY = -10055
PleaseReopenSocket = 0
ReopenSocketDueToReadError = False
<LastResumeSuspendTime>k__BackingField = ????????????
--_dateData = ????????????
--MinValue = 01/01/0001 00:00:00
--MaxValue = 31/12/9999 23:59:59
--UnixEpoch = 01/01/1970 00:00:00
lastReleaseAllKeysCall = 0
McMatrixLock = O
desMachineID = NONE
DesMachineName =
newDesMachineID = NONE
newDesMachineIdEx = NONE
dropMachineID = NONE
lastJump = ????????????
desktopBounds = MouseWithoutBorders.MyRectangle
--Left = 0
--Top = 0
--Right = 0
--Bottom = 0
primaryScreenBounds = MouseWithoutBorders.MyRectangle
--Left = 0
--Top = 0
--Right = 0
--Bottom = 0
SwitchLocation = MouseWithoutBorders.Class.MouseLocation
--<X>k__BackingField = 0
--<Y>k__BackingField = 0
--<Count>k__BackingField = 0
PackageSent = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
PackageReceived = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
PackageID = 0
QUEUE_SIZE = 50
RecentProcessedPackageIDs = 32[]
--[0] = 0
--[1] = 0
--[2] = 0
--[3] = 0
--[4] = 0
--[5] = 0
--[6] = 0
--[7] = 0
--[8] = 0
--[9] = 0
--[10] = 0
--[11] = 0
--[12] = 0
--[13] = 0
--[14] = 0
--[15] = 0
--[16] = 0
--[17] = 0
--[18] = 0
--[19] = 0
--[20] = 0
--[21] = 0
--[22] = 0
--[23] = 0
--[24] = 0
--[25] = 0
--[26] = 0
--[27] = 0
--[28] = 0
--[29] = 0
--[30] = 0
--[31] = 0
--[32] = 0
--[33] = 0
--[34] = 0
--[35] = 0
--[36] = 0
--[37] = 0
--[38] = 0
--[39] = 0
--[40] = 0
--[41] = 0
--[42] = 0
--[43] = 0
--[44] = 0
--[45] = 0
--[46] = 0
--[47] = 0
--[48] = 0
--[49] = 0
recentProcessedPackageIndex = 0
processedPackageCount = 0
skippedPackageCount = 0
<JustGotAKey>k__BackingField = 0
lastXY = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
shownErrMessage = False
lastStartServiceTime = ????????????
--_dateData = ????????????
--MinValue = 01/01/0001 00:00:00
--MaxValue = 31/12/9999 23:59:59
--UnixEpoch = 01/01/1970 00:00:00
SensitivePoints = Generic.List`1[Point]
--_items = Point[]
----System.Drawing.Point[] = Point[]: N/A
--_size = 0
--_version = 0
--s_emptyArray = Point[]
----System.Drawing.Point[] = Point[]: N/A
p = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
<IpcChannelCreated>k__BackingField = False
BIG_CLIPBOARD_DATA_TIMEOUT = 30000
MAX_CLIPBOARD_DATA_SIZE_CAN_BE_SENT_INSTANTLY_TCP = 1048576
MAX_CLIPBOARD_FILE_SIZE_CAN_BE_SENT = 104857600
TEXT_HEADER_SIZE = 12
DATA_SIZE = 48
TEXT_TYPE_SEP = {4CFF57F7-BEDD-43d5-AE8F-27A61E886F2F}
TOGGLE_ICONS_SIZE = 4
ICON_ONE = 0
ICON_ALL = 1
ICON_SMALL_CLIPBOARD = 2
ICON_BIG_CLIPBOARD = 3
ICON_ERROR = 4
JUST_GOT_BACK_FROM_SCREEN_SAVER = 9999
NETWORK_STREAM_BUF_SIZE = 1048576
SymAlBlockSize = 16
PW_LENGTH = 16
HELPER_FORM_TEXT = Mouse without Borders Helper
HelperProcessName = PowerToys.MouseWithoutBordersHelper
MAX_MACHINE = 4
MAX_SOCKET = 8
HEARTBEAT_TIMEOUT = 1500000
SKIP_PIXELS = 1
JUMP_PIXELS = 2
PACKAGE_SIZE = 32
PACKAGE_SIZE_EX = 64
WP_PACKAGE_SIZE = 6
KEYEVENTF_KEYDOWN = 1
KEYEVENTF_KEYUP = 2
WH_MOUSE = 7
WH_KEYBOARD = 2
WH_MOUSE_LL = 14
WH_KEYBOARD_LL = 13
WM_MOUSEMOVE = 512
WM_LBUTTONDOWN = 513
WM_RBUTTONDOWN = 516
WM_MBUTTONDOWN = 519
WM_XBUTTONDOWN = 523
WM_LBUTTONUP = 514
WM_RBUTTONUP = 517
WM_MBUTTONUP = 520
WM_XBUTTONUP = 524
WM_LBUTTONDBLCLK = 515
WM_RBUTTONDBLCLK = 518
WM_MBUTTONDBLCLK = 521
WM_MOUSEWHEEL = 522
WM_KEYDOWN = 256
WM_KEYUP = 257
WM_SYSKEYDOWN = 260
WM_SYSKEYUP = 261
[Logger Logs]
===============
AllLogsLock = O
LogCounter = Concurrent.ConcurrentDictionary`2[System.String,32]
--_tables = Concurrent.ConcurrentDictionary`2+Tables[System.String,32]
----_comparer = Generic.NonRandomizedStringEqualityComparer+OrdinalComparer
----_buckets = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,32][]
------System.Collections.Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Int32][] = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,32][]: N/A
----_fastModBucketsMultiplier = 498560650640798693
----_locks = O[]
------System.Object[] = O[]: N/A
----_countPerLock = 32[]
------[0] = 0
------[1] = 0
------[2] = 0
------[3] = 0
------[4] = 0
------[5] = 0
------[6] = 0
------[7] = 0
------[8] = 0
------[9] = 0
------[10] = 0
------[11] = 0
------[12] = 0
------[13] = 0
------[14] = 0
------[15] = 0
--_budget = 2
--_growLockArray = True
--_comparerIsDefaultForClasses = False
allLogsIndex = 0
lastHour = 0
exceptionCount = 0
lastPackageSent = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
lastPackageReceived = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
MAX_LOG = 10000
MaxLogExceptionPerHour = 1000
HeaderSENT = Be{0},Ke{1},Mo{2},He{3},Mx{4},Tx{5},Im{6},By{7},Cl{8},Dr{9},De{10},Ed{11},Ie{12},Ni{13}
HeaderRECEIVED = Be{0},Ke{1},Mo{2},He{3},Mx{4},Tx{5},Im{6},By{7},Cl{8},Dr{9},De{10},Ed{11},In{12},Ni{13},Pc{14}/{15}

View File

@@ -0,0 +1,405 @@
[Other Logs]
===============
= MouseWithoutBorders.Common
lastClipboardEventTime = 0
clipboardCopiedTime = 0
Comma = System.Char[]
--System.Char[] = System.Char[]: N/A
Star = System.Char[]
--System.Char[] = System.Char[]: N/A
NullSeparator = System.Char[]
--System.Char[] = System.Char[]: N/A
<LastIDWithClipboardData>k__BackingField = NONE
<NextClipboardViewer>k__BackingField = 0
<IsClipboardDataImage>k__BackingField = False
lastClipboardObject =
<HasSwitchedMachineSinceLastCopy>k__BackingField = False
ClipboardThreadOldLock = O
screenWidth = 0
screenHeight = 0
lastX = 0
lastY = 0
mainFormVisible = True
runOnLogonDesktop = False
runOnScrSaverDesktop = False
toggleIconsIndex = 0
EvSwitch = EventWaitHandle
lastPos = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
switchCount = 0
lastReconnectByHotKeyTime = 0
tcpPort = 0
secondOpenSocketTry = False
binaryName = MM
<PaintCount>k__BackingField = 0
<RunWithNoAdminRight>k__BackingField = False
<Is64bitOS>k__BackingField = False
socketMutexBalance = 0
<BlockingUI>k__BackingField = False
<UIThreadID>k__BackingField = 0
<InputCallbackThreadID>k__BackingField = 0
InputSimulationLock = O
lastSendNextMachine = 0
lastInputEventCount = 0
lastRealInputEventCount = 0
minSendTime = 9223372036854775807
avgSendTime = 0
maxSendTime = 0
totalSendCount = 0
totalSendTime = 0
isDragging = False
dragDropStep05ExCalledByIpc = 0
isDropping = False
dragMachine = NONE
<MouseDown>k__BackingField = False
magicNumber = 0
ran = System.Random
--_impl = System.Random+XoshiroImpl
----_s0 = 7284351989338469498
----_s1 = 15479097190878625043
----_s2 = 10963166711904013490
----_s3 = 8600427501468926680
--<Shared>k__BackingField = System.Random+ThreadSafeRandom
InitialIV = 99999999999999999999
<GeneratedKey>k__BackingField = False
<KeyCorrupted>k__BackingField = False
LegalKeyDictionary = Concurrent.ConcurrentDictionary`2[System.String,System.Byte[]]
--_tables = Concurrent.ConcurrentDictionary`2+Tables[System.String,System.Byte[]]
----_comparer = Generic.NonRandomizedStringEqualityComparer+OrdinalIgnoreCaseComparer
----_buckets = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Byte[]][]
------System.Collections.Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Byte[]][] = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Byte[]][]: N/A
----_fastModBucketsMultiplier = 498560650640798693
----_locks = O[]
------System.Object[] = O[]: N/A
----_countPerLock = 32[]
------[0] = 0
------[1] = 0
------[2] = 0
------[3] = 0
------[4] = 0
------[5] = 0
------[6] = 0
------[7] = 0
------[8] = 0
------[9] = 0
------[10] = 0
------[11] = 0
------[12] = 0
------[13] = 0
------[14] = 0
------[15] = 0
--_budget = 2
--_growLockArray = True
--_comparerIsDefaultForClasses = False
KeybdPackage = MouseWithoutBorders.DATA
--Type = 0
--Id = 0
--Src = NONE
--Des = NONE
--DateTime = 0
--Kd = MouseWithoutBorders.KEYBDDATA
--Md = MouseWithoutBorders.MOUSEDATA
--Machine1 = NONE
--Machine2 = NONE
--Machine3 = NONE
--Machine4 = NONE
--PostAction = Other
--machineNameP1 = 0
--machineNameP2 = 0
--machineNameP3 = 0
--machineNameP4 = 0
MousePackage = MouseWithoutBorders.DATA
--Type = 0
--Id = 0
--Src = NONE
--Des = NONE
--DateTime = 0
--Kd = MouseWithoutBorders.KEYBDDATA
--Md = MouseWithoutBorders.MOUSEDATA
--Machine1 = NONE
--Machine2 = NONE
--Machine3 = NONE
--Machine4 = NONE
--PostAction = Other
--machineNameP1 = 0
--machineNameP2 = 0
--machineNameP3 = 0
--machineNameP4 = 0
inputEventCount = 0
invalidPackageCount = 0
MOVE_MOUSE_RELATIVE = 100000
XY_BY_PIXEL = 300000
<RealInputEventCount>k__BackingField = 0
actualLastPos = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
myLastX = 0
myLastY = 0
signalHelperToExit = False
signalWatchDogToExit = False
WndProcCounter = 0
initDone = False
REOPEN_WHEN_WSAECONNRESET = -10054
REOPEN_WHEN_HOTKEY = -10055
PleaseReopenSocket = 0
ReopenSocketDueToReadError = False
<LastResumeSuspendTime>k__BackingField = 26/09/2024 20:35:51
--_dateData = 5250315815941007823
--MinValue = 01/01/0001 00:00:00
--MaxValue = 31/12/9999 23:59:59
--UnixEpoch = 01/01/1970 00:00:00
lastReleaseAllKeysCall = 0
AllLogsLock = O
LogCounter = Concurrent.ConcurrentDictionary`2[System.String,32]
--_tables = Concurrent.ConcurrentDictionary`2+Tables[System.String,32]
----_comparer = Generic.NonRandomizedStringEqualityComparer+OrdinalComparer
----_buckets = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,32][]
------System.Collections.Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,System.Int32][] = Concurrent.ConcurrentDictionary`2+VolatileNode[System.String,32][]: N/A
----_fastModBucketsMultiplier = 498560650640798693
----_locks = O[]
------System.Object[] = O[]: N/A
----_countPerLock = 32[]
------[0] = 0
------[1] = 0
------[2] = 0
------[3] = 0
------[4] = 0
------[5] = 0
------[6] = 0
------[7] = 0
------[8] = 0
------[9] = 0
------[10] = 0
------[11] = 0
------[12] = 0
------[13] = 0
------[14] = 0
------[15] = 0
--_budget = 2
--_growLockArray = True
--_comparerIsDefaultForClasses = False
RepeatedLogIndexSelection = 32[]
--[0] = 1
--[1] = 3
--[2] = 10
--[3] = 50
--[4] = 100
allLogsIndex = 0
lastHour = 0
exceptionCount = 0
p1 = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
p2 = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
McMatrixLock = O
desMachineID = NONE
DesMachineName =
newDesMachineID = NONE
newDesMachineIdEx = NONE
dropMachineID = NONE
lastJump = 63862983351362
desktopBounds = MouseWithoutBorders.MyRectangle
--Left = 0
--Top = 0
--Right = 0
--Bottom = 0
primaryScreenBounds = MouseWithoutBorders.MyRectangle
--Left = 0
--Top = 0
--Right = 0
--Bottom = 0
SwitchLocation = MouseWithoutBorders.Class.MouseLocation
--<X>k__BackingField = 0
--<Y>k__BackingField = 0
--<Count>k__BackingField = 0
PackageSent = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
PackageReceived = MouseWithoutBorders.PackageMonitor
--Keyboard = 0
--Mouse = 0
--Heartbeat = 0
--ByeBye = 0
--Hello = 0
--Matrix = 0
--ClipboardText = 0
--ClipboardImage = 0
--Clipboard = 0
--ClipboardDragDrop = 0
--ClipboardDragDropEnd = 0
--ClipboardAsk = 0
--ExplorerDragDrop = 0
--Nil = 0
PackageID = 0
QUEUE_SIZE = 50
RecentProcessedPackageIDs = 32[]
--[0] = 0
--[1] = 0
--[2] = 0
--[3] = 0
--[4] = 0
--[5] = 0
--[6] = 0
--[7] = 0
--[8] = 0
--[9] = 0
--[10] = 0
--[11] = 0
--[12] = 0
--[13] = 0
--[14] = 0
--[15] = 0
--[16] = 0
--[17] = 0
--[18] = 0
--[19] = 0
--[20] = 0
--[21] = 0
--[22] = 0
--[23] = 0
--[24] = 0
--[25] = 0
--[26] = 0
--[27] = 0
--[28] = 0
--[29] = 0
--[30] = 0
--[31] = 0
--[32] = 0
--[33] = 0
--[34] = 0
--[35] = 0
--[36] = 0
--[37] = 0
--[38] = 0
--[39] = 0
--[40] = 0
--[41] = 0
--[42] = 0
--[43] = 0
--[44] = 0
--[45] = 0
--[46] = 0
--[47] = 0
--[48] = 0
--[49] = 0
recentProcessedPackageIndex = 0
processedPackageCount = 0
skippedPackageCount = 0
<JustGotAKey>k__BackingField = 0
lastXY = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
shownErrMessage = False
lastStartServiceTime = 26/09/2024 20:35:51
--_dateData = 5250315815941010854
--MinValue = 01/01/0001 00:00:00
--MaxValue = 31/12/9999 23:59:59
--UnixEpoch = 01/01/1970 00:00:00
SensitivePoints = Generic.List`1[Point]
--_items = Point[]
----System.Drawing.Point[] = Point[]: N/A
--_size = 0
--_version = 0
--s_emptyArray = Point[]
----System.Drawing.Point[] = Point[]: N/A
p = {X=0,Y=0}
--x = 0
--y = 0
--Empty = {X=0,Y=0}
<IpcChannelCreated>k__BackingField = False
BIG_CLIPBOARD_DATA_TIMEOUT = 30000
MAX_CLIPBOARD_DATA_SIZE_CAN_BE_SENT_INSTANTLY_TCP = 1048576
MAX_CLIPBOARD_FILE_SIZE_CAN_BE_SENT = 104857600
TEXT_HEADER_SIZE = 12
DATA_SIZE = 48
TEXT_TYPE_SEP = {4CFF57F7-BEDD-43d5-AE8F-27A61E886F2F}
TOGGLE_ICONS_SIZE = 4
ICON_ONE = 0
ICON_ALL = 1
ICON_SMALL_CLIPBOARD = 2
ICON_BIG_CLIPBOARD = 3
ICON_ERROR = 4
JUST_GOT_BACK_FROM_SCREEN_SAVER = 9999
NETWORK_STREAM_BUF_SIZE = 1048576
SymAlBlockSize = 16
PW_LENGTH = 16
HELPER_FORM_TEXT = Mouse without Borders Helper
HelperProcessName = PowerToys.MouseWithoutBordersHelper
MAX_LOG = 10000
MaxLogExceptionPerHour = 1000
HeaderSENT = Be{0},Ke{1},Mo{2},He{3},Mx{4},Tx{5},Im{6},By{7},Cl{8},Dr{9},De{10},Ed{11},Ie{12},Ni{13}
HeaderRECEIVED = Be{0},Ke{1},Mo{2},He{3},Mx{4},Tx{5},Im{6},By{7},Cl{8},Dr{9},De{10},Ed{11},In{12},Ni{13},Pc{14}/{15}
MAX_MACHINE = 4
MAX_SOCKET = 8
HEARTBEAT_TIMEOUT = 1500000
SKIP_PIXELS = 1
JUMP_PIXELS = 2
PACKAGE_SIZE = 32
PACKAGE_SIZE_EX = 64
WP_PACKAGE_SIZE = 6
KEYEVENTF_KEYDOWN = 1
KEYEVENTF_KEYUP = 2
WH_MOUSE = 7
WH_KEYBOARD = 2
WH_MOUSE_LL = 14
WH_KEYBOARD_LL = 13
WM_MOUSEMOVE = 512
WM_LBUTTONDOWN = 513
WM_RBUTTONDOWN = 516
WM_MBUTTONDOWN = 519
WM_XBUTTONDOWN = 523
WM_LBUTTONUP = 514
WM_RBUTTONUP = 517
WM_MBUTTONUP = 520
WM_XBUTTONUP = 524
WM_LBUTTONDBLCLK = 515
WM_RBUTTONDBLCLK = 518
WM_MBUTTONDBLCLK = 521
WM_MOUSEWHEEL = 522
WM_KEYDOWN = 256
WM_KEYUP = 257
WM_SYSKEYDOWN = 260
WM_SYSKEYUP = 261

View File

@@ -0,0 +1,161 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Concurrent;
using System.Globalization;
using System.Reflection;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseWithoutBorders.Core;
namespace MouseWithoutBorders.UnitTests.Core;
public static class LoggerTests
{
[TestClass]
public sealed class PrivateDumpTests
{
/*
[TestMethod]
public void PrivateDumpShouldGenerateExpectedOutput()
{
// this was used to create the contents of "Logger.PrivateDump.original.txt"
// when the "Core.Logger" class was "Common" in "Common.Log.cs"
// PrivateDump throws an ArgumentNullException if this is null
Common.BinaryName = "MyBinary.dll";
// magic number from Settings.cs
var dumpObjectsLevel = 6;
// copied from DumpObjects in Common.Log.cs
var sb = new StringBuilder(1000000);
var result = Common.PrivateDump(sb, new Common(), "[Other Logs]\r\n===============\r\n", 0, dumpObjectsLevel, false);
var output = sb.ToString();
}
*/
[TestMethod]
[Ignore(
"This test relies on internal details of the dotnet platform and is sensitive to " +
"the specific version of dotnet being used. As a result it's likely to fail if the " +
"\"expected\" result was generated with a different version to the version used to " +
"run the test, so we're going to ignore it in the CI build process.")]
public void PrivateDumpShouldGenerateExpectedOutput()
{
static string NormalizeLog(string log)
{
var lines = log.Split("\r\n");
// some parts of the PrivateDump output are impossible to reproduce -
// e.g. random numbers, system timestamps, thread ids, etc, so we'll mask them
var maskPrefixes = new string[]
{
"----_s0 = ",
"----_s1 = ",
"----_s2 = ",
"----_s3 = ",
"<LastResumeSuspendTime>k__BackingField = ",
"--_dateData = ",
"lastJump = ",
"lastStartServiceTime = ",
"InitialIV = ",
};
for (var i = 0; i < lines.Length; i++)
{
foreach (var maskPrefix in maskPrefixes)
{
if (lines[i].StartsWith(maskPrefix, StringComparison.InvariantCulture))
{
// replace the trailing text with "?" characters
lines[i] = string.Concat(
lines[i].AsSpan(0, maskPrefix.Length),
new string('?', 12));
}
}
}
// hide some of the internals of concurrent dictionary lock tables
// as the size can vary across machines
var removeLines = new string[]
{
"------[8] = 0",
"------[9] = 0",
"------[10] = 0",
"------[11] = 0",
"------[12] = 0",
"------[13] = 0",
"------[14] = 0",
"------[15] = 0",
};
lines = lines.Where(line => !removeLines.Contains(line)).ToArray();
return string.Join("\r\n", lines);
}
// PrivateDump throws an ArgumentNullException if this is null
Common.BinaryName = "MyBinary.dll";
// default magic number from Settings.cs
var settingsDumpObjectsLevel = 6;
// get the expected test result from an embedded resource
var assembly = Assembly.GetExecutingAssembly();
var resourceName = $"{typeof(LoggerTests).Namespace}.Logger.PrivateDump.expected.txt";
using var stream = assembly.GetManifestResourceStream(resourceName)
?? throw new InvalidOperationException();
using var streamReader = new StreamReader(stream);
var expected = streamReader.ReadToEnd();
// copied from DumpObjects in Common.Log.cs
var sb = new StringBuilder(1000000);
_ = Logger.PrivateDump(sb, Logger.AllLogs, "[Program logs]\r\n===============\r\n", 0, settingsDumpObjectsLevel, false);
_ = Logger.PrivateDump(sb, new Common(), "[Other Logs]\r\n===============\r\n", 0, settingsDumpObjectsLevel, false);
sb.AppendLine("[Logger Logs]\r\n===============");
Logger.DumpType(sb, typeof(Logger), 0, settingsDumpObjectsLevel);
var actual = sb.ToString();
expected = NormalizeLog(expected);
actual = NormalizeLog(actual);
// Azure DevOps truncates debug output which makes it hard to see where
// the expected and actual differ, so we need to write a custom error message
// so we can just focus on the differences between expected and actual
var expectedLines = expected.Split("\r\n");
var actualLines = actual.Split("\r\n");
for (var i = 0; i < Math.Min(expectedLines.Length, actualLines.Length); i++)
{
if (actualLines[i] != expectedLines[i])
{
var message = new StringBuilder();
message.AppendLine(CultureInfo.InvariantCulture, $"{nameof(actual)} and {nameof(expected)} differ at line {i}:");
message.AppendLine();
message.AppendLine($"{nameof(actual)}:");
for (var j = i; j < Math.Min(i + 5, actualLines.Length); j++)
{
message.AppendLine(CultureInfo.InvariantCulture, $"[{j}]: {actualLines[j]}:");
}
message.AppendLine();
message.AppendLine($"{nameof(expected)}:");
for (var j = i; j < Math.Min(i + 5, expectedLines.Length); j++)
{
message.AppendLine(CultureInfo.InvariantCulture, $"[{j}]: {expectedLines[j]}:");
}
var x = new ConcurrentDictionary<string, string>(-1, 16);
Assert.Fail(message.ToString());
}
}
// finally, throw an exception if the two don't match
// just in case the above doesn't spot a difference
// (e.g. different number of lines in the output)
Assert.AreEqual(expected, actual);
}
}
}

View File

@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Look at Directory.Build.props in root for common stuff as well -->
<Import Project="..\..\..\Common.Dotnet.CsWinRT.props" />
<Import Project="..\..\..\Common.SelfContained.props" />
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<None Remove="Core\Logger.PrivateDump.expected.txt" />
<None Remove="Core\Logger.PrivateDump.original.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Core\Logger.PrivateDump.expected.txt" />
<EmbeddedResource Include="Core\Logger.PrivateDump.original.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\App\MouseWithoutBorders.csproj" />
</ItemGroup>
</Project>