From ce29458889e47db159b14cc5b01dc7259da434db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Wed, 25 Mar 2020 15:41:56 +0100 Subject: [PATCH 1/4] Fix failing tests for GetComputerNameEx function --- .../SysInfoApi.Test/GetComputerNameEx.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs b/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs index 50c49385..d28b3651 100644 --- a/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs +++ b/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; @@ -92,7 +92,7 @@ public static void Can_call_ansi_marshaling_extern_function(COMPUTER_NAME_FORMAT bool successful = GetComputerNameExA(nameType, pathBuilder, out int length); if (!successful) throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error()); - var path = pathBuilder.ToString(0, length); + var path = pathBuilder?.ToString(0, length); Assert.NotNull(path); } @@ -104,7 +104,7 @@ public static void Can_call_unicode_marshaling_extern_function(COMPUTER_NAME_FOR bool successful = GetComputerNameExW(nameType, pathBuilder, out int length); if (!successful) throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error()); - var path = pathBuilder.ToString(0, length); + var path = pathBuilder?.ToString(0, length); Assert.NotNull(path); } @@ -116,7 +116,7 @@ public static void Can_call_auto_marshaling_extern_function(COMPUTER_NAME_FORMAT bool successful = GetComputerNameEx(nameType, pathBuilder, out int length); if (!successful) throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error()); - var path = pathBuilder.ToString(0, length); + var path = pathBuilder?.ToString(0, length); Assert.NotNull(path); } From 70136a5c884d2a06f21db74b684a795efbd1c056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Wed, 25 Mar 2020 16:05:21 +0100 Subject: [PATCH 2/4] Update VS Code support files --- .vscode/c_cpp_properties.json | 36 ++++++++++++------------ .vscode/extensions.json | 25 ++++++++--------- .vscode/launch.json | 52 +++++++++++++++++------------------ .vscode/tasks.json | 42 ++++++++++++++-------------- 4 files changed, 77 insertions(+), 78 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index e5437dc1..73e9427b 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,20 +1,20 @@ { - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "windowsSdkVersion": "10.0.17134.0", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "msvc-x64" - } - ], - "version": 4 + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.17134.0", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ffe28766..5bf53600 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,15 +1,14 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. - // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - - // List of extensions which should be recommended for users of this workspace. - "recommendations": [ - "ms-vscode.csharp", - "tintoy.msbuild-project-tools", - "ms-vscode.cpptools" - ], - // List of extensions recommended by VS Code that should not be recommended for users of this workspace. - "unwantedRecommendations": [ - - ] + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "editorconfig.editorconfig", + "codezombiech.gitignore", + "ms-dotnettools.csharp", + "tintoy.msbuild-project-tools", + "ms-vscode.cpptools", + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 30585a5a..97bdfdbc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,28 +1,28 @@ { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/THNETII.WinApiNative.Test.dll", - "args": [], - "cwd": "${workspaceFolder}/test/THNETII.WinApiNative.Test", - // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window - "console": "internalConsole", - "stopAtEntry": false, - "internalConsoleOptions": "openOnSessionStart" - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ,] + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/THNETII.WinApiNative.Test.dll", + "args": [], + "cwd": "${workspaceFolder}/test/THNETII.WinApiNative.Test", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + }, + ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index cbad22d4..59862043 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,23 +1,23 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "test", - "command": "dotnet", - "type": "process", - "args": [ - "test" - ], - "problemMatcher": "$msCompile" - } - ] + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "test", + "command": "dotnet", + "type": "process", + "args": [ + "test" + ], + "problemMatcher": "$msCompile" + } + ] } From bdee730b5a3bd4d137f01961137b946aded18fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Wed, 25 Mar 2020 16:16:18 +0100 Subject: [PATCH 3/4] Disabled tests for GetComputerNameExW function --- .../SysInfoApi.Test/GetComputerNameEx.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs b/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs index d28b3651..123a91ff 100644 --- a/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs +++ b/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs @@ -92,11 +92,11 @@ public static void Can_call_ansi_marshaling_extern_function(COMPUTER_NAME_FORMAT bool successful = GetComputerNameExA(nameType, pathBuilder, out int length); if (!successful) throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error()); - var path = pathBuilder?.ToString(0, length); + var path = pathBuilder.ToString(0, length); Assert.NotNull(path); } - [TheoryWindowsOS] + [TheoryWindowsOS(Skip = "Disabled and blocked on https://github.com/thnetii/windows-api/pull/105")] [MemberData(nameof(Get_COMPUTER_NAME_FORMAT))] public static void Can_call_unicode_marshaling_extern_function(COMPUTER_NAME_FORMAT nameType) { @@ -104,11 +104,11 @@ public static void Can_call_unicode_marshaling_extern_function(COMPUTER_NAME_FOR bool successful = GetComputerNameExW(nameType, pathBuilder, out int length); if (!successful) throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error()); - var path = pathBuilder?.ToString(0, length); + var path = pathBuilder.ToString(0, length); Assert.NotNull(path); } - [TheoryWindowsOS] + [TheoryWindowsOS(Skip = "Disabled and blocked on https://github.com/thnetii/windows-api/pull/105")] [MemberData(nameof(Get_COMPUTER_NAME_FORMAT))] public static void Can_call_auto_marshaling_extern_function(COMPUTER_NAME_FORMAT nameType) { @@ -116,7 +116,7 @@ public static void Can_call_auto_marshaling_extern_function(COMPUTER_NAME_FORMAT bool successful = GetComputerNameEx(nameType, pathBuilder, out int length); if (!successful) throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error()); - var path = pathBuilder?.ToString(0, length); + var path = pathBuilder.ToString(0, length); Assert.NotNull(path); } From 0d22c4920e593b1d359f848235abc958770481bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Wed, 25 Mar 2020 16:22:08 +0100 Subject: [PATCH 4/4] Revert "Disabled tests for GetComputerNameExW function" This reverts commit bdee730b5a3bd4d137f01961137b946aded18fa4. --- .../SysInfoApi.Test/GetComputerNameEx.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs b/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs index 123a91ff..854f3806 100644 --- a/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs +++ b/test/THNETII.WinApi.Native.Test/SysInfoApi.Test/GetComputerNameEx.cs @@ -96,7 +96,7 @@ public static void Can_call_ansi_marshaling_extern_function(COMPUTER_NAME_FORMAT Assert.NotNull(path); } - [TheoryWindowsOS(Skip = "Disabled and blocked on https://github.com/thnetii/windows-api/pull/105")] + [TheoryWindowsOS] [MemberData(nameof(Get_COMPUTER_NAME_FORMAT))] public static void Can_call_unicode_marshaling_extern_function(COMPUTER_NAME_FORMAT nameType) { @@ -108,7 +108,7 @@ public static void Can_call_unicode_marshaling_extern_function(COMPUTER_NAME_FOR Assert.NotNull(path); } - [TheoryWindowsOS(Skip = "Disabled and blocked on https://github.com/thnetii/windows-api/pull/105")] + [TheoryWindowsOS] [MemberData(nameof(Get_COMPUTER_NAME_FORMAT))] public static void Can_call_auto_marshaling_extern_function(COMPUTER_NAME_FORMAT nameType) {