Skip to content
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

For new surface area, classes marked as final should not have virtual methods. #5331

Merged
merged 8 commits into from
Feb 10, 2024
1 change: 1 addition & 0 deletions sdk/identity/azure-identity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ az_rtti_setup(
if(BUILD_TESTING)
# define a symbol that enables some test hooks in code
add_compile_definitions(TESTING_BUILD)
add_compile_definitions(_azure_TESTING_BUILD)
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved

# tests
if (NOT AZ_ALL_LIBRARIES OR FETCH_SOURCE_DEPS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "azure/identity/detail/token_cache.hpp"
#include "azure/identity/dll_import_export.hpp"

#include <azure/core/credentials/credentials.hpp>
#include <azure/core/credentials/token_credential_options.hpp>
Expand All @@ -18,6 +19,12 @@
#include <string>
#include <vector>

#if defined(_azure_TESTING_BUILD)
namespace Azure { namespace Identity { namespace Test {
class AzureCliTestCredential;
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
}}} // namespace Azure::Identity::Test
#endif

namespace Azure { namespace Identity {
/**
* @brief Options for configuring the #Azure::Identity::AzureCliCredential.
Expand Down Expand Up @@ -50,10 +57,15 @@ namespace Azure { namespace Identity {
* token.
*/
class AzureCliCredential
#if !defined(TESTING_BUILD)
#if !defined(_azure_TESTING_BUILD)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use _azure_FINAL_FOR_TESTS here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because doxygen has a bug since it fails to generate the docs for types that use macros that have the final keyword in them. Our PrePublishBuild GenerateReleaseArtifacts steps fails with a doxygen warning treated as error :(

So, if we use a macro, the classes that use it, don't show up in the generated docs.

doxygen/doxygen#10641

final
#endif
: public Core::Credentials::TokenCredential {

#if defined(_azure_TESTING_BUILD)
friend class Azure::Identity::Test::AzureCliTestCredential;
#endif

protected:
/** @brief The cache for the access token. */
_detail::TokenCache m_tokenCache;
Expand Down Expand Up @@ -106,13 +118,12 @@ namespace Azure { namespace Identity {
Core::Credentials::TokenRequestContext const& tokenRequestContext,
Core::Context const& context) const override;

#if !defined(TESTING_BUILD)
private:
#else
protected:
#endif
virtual std::string GetAzCommand(std::string const& scopes, std::string const& tenantId) const;
virtual int GetLocalTimeToUtcDiffSeconds() const;
_azure_VIRTUAL_FOR_TESTS std::string GetAzCommand(
std::string const& scopes,
std::string const& tenantId) const;

_azure_VIRTUAL_FOR_TESTS int GetLocalTimeToUtcDiffSeconds() const;
};

}} // namespace Azure::Identity
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@

#undef AZ_IDENTITY_BUILT_AS_DLL

#if defined(_azure_TESTING_BUILD)
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
#if !defined(_azure_VIRTUAL_FOR_TESTS)
#define _azure_VIRTUAL_FOR_TESTS virtual
#endif
#else
#if !defined(_azure_VIRTUAL_FOR_TESTS)
#define _azure_VIRTUAL_FOR_TESTS
#endif
#endif

/**
* @brief Azure SDK abstractions.
*
Expand Down
Loading