-
Notifications
You must be signed in to change notification settings - Fork 391
Adding headers to test common header files #5903
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
base: main
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow the reason for most of these changes. See comment for more detail
#ifndef __WINDOWSAPPRUNTIME_TEST_APPMODEL_H | ||
#define __WINDOWSAPPRUNTIME_TEST_APPMODEL_H | ||
|
||
#include <windows.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
Is this currently a problem or is this a stylistic change?
This is the most obvious example - why does this need to include windows.h
? That's routinely the 1st include in any precompiled header, and in any source file in projects not using precompiled headers. Also, some include <unknown.h>
rather than windows.h
(the former includes the latter, plus other things).
I don't see the value including windows.h
in any header file (except precomp.h/pch.h)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current problem is that for some of these headers, you can't include them alone without including these dependencies before in your file. Creating a new test that uses one of these headers requires knowing what they depend on, and it is not possible to just include the header that you actually want to use alone, requiring the include of windows.h
before including the desire header for example.
I think it is a good practice to have headers that work as their own (by being possible to compile a .cpp
file including only it, which is what I mean when I say a header can be compiled) and it would make it easier for others to use them within the project.
For this specific case, this header can be compile on its own because it includes windows.h
within appmodel.h
, but it is hidden under a conditional macro. So I included it here to make it safer.
Do you think there are any downsides on doing this change? We can close this PR if it is not desired.
This pull request updates several test header files to improve consistency and ensure all necessary dependencies are explicitly included. The main focus is on adding missing system and library includes, which helps prevent build issues and makes dependencies clearer for future maintenance.
Dependency inclusion improvements:
<windows.h>
,<winrt/base.h>
,<WexTestClass.h>
,<appmodel.h>
,<Verify.h>
, and<filesystem>
to multiple test headers includingTestDef.h
,WindowsAppRuntime.Test.AppModel.h
,WindowsAppRuntime.Test.Bootstrap.h
,WindowsAppRuntime.Test.FileSystem.h
,WindowsAppRuntime.Test.Package.h
,WindowsAppRuntime.Test.TAEF.cppwinrt.h
, andWindowsAppRuntime.Test.TAEF.h
. [1] [2] [3] [4] [5] [6] [7]These changes help ensuring that each header is independent and handle its own dependencies. Without these explicit dependencies, when creating a new test file, we need to know precisely the order in which to include each header for them to work, as some headers are dependent on external includes to exist. Or use one of the
.pch
files as example, but then making it harder to maintain as the dependencies are hidden and we end up including unnecessary files.This is also stated on C++ Core Guidelines.
A microsoft employee must use /azp run to validate using the pipelines below.
WARNING:
Comments made by azure-pipelines bot maybe inaccurate.
Please see pipeline link to verify that the build is being ran.
For status checks on the main branch, please use TransportPackage-Foundation-PR
(https://microsoft.visualstudio.com/ProjectReunion/_build?definitionId=81063&_a=summary)
and run the build against your PR branch with the default parameters.