Skip to content

Adding a new network header with associated unit tests #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
14b4212
Adding a new network header with associated unit tests
keith-horton Feb 25, 2025
234be40
Merge branch 'master' into user/khorton/wil_network
keith-horton Mar 7, 2025
2a34cb3
Updates after applying the new header to a couple of real projects.
keith-horton Mar 9, 2025
71c8795
clang-format
keith-horton Mar 9, 2025
09975ca
marking the RPC COM test as local-only to avoid CI pipeline failures
keith-horton Mar 16, 2025
fafcb70
Fixing deprecated-literal-operator warning in stl.h
keith-horton Mar 17, 2025
753d707
Trying a fix for the clang nontrivial-memcall error
keith-horton Mar 17, 2025
76c04a0
Fixing StoredCallContextInfo in tracelogging.h from the clang compile…
keith-horton Mar 17, 2025
d133e79
renaming the to-string functions from 'write' to 'format'
keith-horton Mar 18, 2025
b5d7674
Merge with parent.
keith-horton Mar 25, 2025
5fa1f8a
Update include/wil/network.h
keith-horton Mar 27, 2025
2798317
Update include/wil/network.h
keith-horton Mar 27, 2025
8a116dd
Update include/wil/network.h
keith-horton Mar 27, 2025
fb1dfa3
Update include/wil/network.h
keith-horton Mar 27, 2025
e58ee3c
Update include/wil/network.h
keith-horton Mar 27, 2025
fd40511
Update include/wil/network.h
keith-horton Mar 27, 2025
db18054
Update include/wil/network.h
keith-horton Mar 27, 2025
dd608c7
Addressing quality PR feedback, fixing naming.
keith-horton Mar 27, 2025
b22d738
Minor updates
keith-horton Mar 27, 2025
69deaa8
Minor updates
keith-horton Mar 27, 2025
bf386a8
Adding network and registry tests to asan tests
keith-horton Mar 27, 2025
42019fb
Addressing more feedback.
keith-horton Mar 27, 2025
c96fd94
Addressed feedback for a few interfaces.
keith-horton Mar 30, 2025
eaf2171
Addressing additional feedback.
keith-horton Mar 30, 2025
847731b
Capturing some great feedback.
keith-horton Apr 8, 2025
5edc249
Updates based off of feedback - but move construction still isn't wor…
keith-horton Apr 13, 2025
f3d7b96
Merge branch 'microsoft:master' into user/khorton/wil_network
keith-horton May 21, 2025
46b8f29
Minor updates. All tests pass.
keith-horton May 22, 2025
75ec806
Adding one more winsock extension function
keith-horton May 28, 2025
7a60e59
Adding more tests
keith-horton May 28, 2025
cbb12a0
only scripts\run-clang-format.cmd seems to have forced the formatting…
keith-horton May 29, 2025
2faffd0
Removed unnecessary / unuseful assignment operators. added back the d…
keith-horton Jun 2, 2025
9affa3d
Merge branch 'master' into user/khorton/wil_network
keith-horton Jun 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions include/wil/Tracelogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ namespace details
public:
StoredCallContextInfo() WI_NOEXCEPT
{
::ZeroMemory(this, sizeof(*this));
contextId = 0;
contextName = nullptr;
contextMessage = nullptr;
}

StoredCallContextInfo(StoredCallContextInfo&& other) WI_NOEXCEPT : StoredCallContextInfo()
Expand All @@ -281,7 +283,7 @@ namespace details
return *this;
}

StoredCallContextInfo(StoredCallContextInfo const& other) WI_NOEXCEPT : m_ownsMessage(false)
StoredCallContextInfo(StoredCallContextInfo const& other) WI_NOEXCEPT
{
contextId = other.contextId;
contextName = other.contextName;
Expand All @@ -295,7 +297,7 @@ namespace details
}
}

StoredCallContextInfo(_In_opt_ PCSTR staticContextName) WI_NOEXCEPT : m_ownsMessage(false)
StoredCallContextInfo(_In_opt_ PCSTR staticContextName) WI_NOEXCEPT
{
contextId = 0;
contextName = staticContextName;
Expand Down Expand Up @@ -364,7 +366,7 @@ namespace details
}
}

bool m_ownsMessage;
bool m_ownsMessage{false};
};

template <typename TActivity>
Expand Down
1,338 changes: 1,338 additions & 0 deletions include/wil/network.h

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion include/wil/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ class unique_struct : public struct_t

void call_init(wistd::true_type)
{
RtlZeroMemory(this, sizeof(*this));
RtlZeroMemory(static_cast<struct_t*>(this), sizeof(struct_t));
}

void call_init(wistd::false_type)
Expand Down Expand Up @@ -5085,6 +5085,27 @@ typedef shared_any<unique_socket> shared_socket;
typedef weak_any<shared_socket> weak_socket;
#endif // __WIL_WINSOCKAPI_STL

#if (defined(_WS2TCPIP_H_) && !defined(__WIL_WS2TCPIP_H_)) || defined(WIL_DOXYGEN)
/// @cond
#define __WIL_WS2TCPIP_H_
/// @endcond
typedef unique_any<ADDRINFOA*, decltype(&::freeaddrinfo), ::freeaddrinfo> unique_addrinfo_ansi;
typedef unique_any<ADDRINFOW*, decltype(&::FreeAddrInfoW), ::FreeAddrInfoW> unique_addrinfo;
// not defining a type for FreeAddrInfoEx(ADDRINFOEXA*) as that API is formally __declspec(deprecated)
typedef unique_any<ADDRINFOEXW*, decltype(&::FreeAddrInfoExW), ::FreeAddrInfoExW> unique_addrinfoex;
#endif // __WIL_WS2TCPIP_H_
#if (defined(__WIL_WS2TCPIP_H_) && !defined(__WIL_WS2TCPIP_H_STL) && defined(WIL_RESOURCE_STL)) || defined(WIL_DOXYGEN)
/// @cond
#define __WIL_WS2TCPIP_H_STL
/// @endcond
typedef shared_any<unique_addrinfo_ansi> shared_addrinfo_ansi;
typedef weak_any<unique_addrinfo_ansi> weak_addrinfo_ansi;
typedef shared_any<unique_addrinfo> shared_addrinfo;
typedef weak_any<unique_addrinfo> weak_addrinfo;
typedef shared_any<unique_addrinfoex> shared_addrinfoex;
typedef weak_any<unique_addrinfoex> weak_addrinfoex;
#endif // __WIL_WS2TCPIP_H_STL

#if (defined(_WINGDI_) && !defined(__WIL_WINGDI_) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && !defined(NOGDI) && !defined(WIL_KERNEL_MODE)) || \
defined(WIL_DOXYGEN)
/// @cond
Expand Down
8 changes: 4 additions & 4 deletions include/wil/stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ using zwstring_view = basic_zstring_view<wchar_t>;

inline namespace literals
{
constexpr zstring_view operator"" _zv(const char* str, std::size_t len) noexcept
constexpr zstring_view operator""_zv(const char* str, std::size_t len) noexcept
{
return zstring_view(str, len);
return {str, len};
}

constexpr zwstring_view operator"" _zv(const wchar_t* str, std::size_t len) noexcept
constexpr zwstring_view operator""_zv(const wchar_t* str, std::size_t len) noexcept
{
return zwstring_view(str, len);
return {str, len};
}
} // namespace literals

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ find_package(Catch2 CONFIG REQUIRED)

include_directories(${DETOURS_INCLUDE_DIRS})
add_definitions(-DNOMINMAX)
link_libraries(${DETOURS_LIBRARY} Catch2::Catch2WithMain)
link_libraries(${DETOURS_LIBRARY} Catch2::Catch2WithMain ws2_32.lib ntdll.lib)

add_subdirectory(app)
add_subdirectory(cpplatest)
Expand Down
3 changes: 2 additions & 1 deletion tests/ComTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3125,7 +3125,8 @@ TEST_CASE("COMEnumerator", "[com][enumerator]")
#include <winrt/windows.foundation.h>
#include <windows.foundation.h>

TEST_CASE("com_timeout", "[com][com_timeout]")
// This fails with 'RPC_S_CALLPENDING' on the CI machines, so disable there, but still run locally
TEST_CASE("com_timeout", "[com][com_timeout][LocalOnly]")
{
auto init = wil::CoInitializeEx_failfast();

Expand Down
Loading