Open am11 opened 4 years ago
Earlier discussion here https://github.com/dotnet/runtime/issues/7280 https://github.com/dotnet/runtime/issues/7213
There is a tool that I used that can safely remove code within particular defines (or remove define and retain code). If you plan to do this I will find a link to it.
Thanks, such a tool will certainly help. I think main work is to make decision what actions to take. If a constant is not (explicitly or implicitly) defined anywhere, should we just delete the code (in a spirit that git has the history in case we ever need to revive)? Certain places may still require manual intervention (especially those which deal with consolidating windows and unix targets).
If a constant is not (explicitly or implicitly) defined anywhere, should we just delete the code
I believe so we should do this basically to clean dead code and if we need we can always bring stuff back. @danmosemsft can you share a bit more here of the effort you went through last time you did this? Specifically, it would be good to know if there was a lot of manual intervention required as @am11 calls out above.
@am11 is it easy for you to update the data from the top post? I would like to clean the platform and framework defines up.
@ViktorHofer, I can find in the scope of src/libraries
only as done in the top post, let me know if it is needed after this.
Here is the sorted+deduplicated list from full repo to get a better view of variety of naming patterns used for preprocessor constants.
Note that the first four items of "defined constants list" are using equal sign and commas. I didn't curate the list to highlight the potential issue.
We can perform (indexed) search on repo for each item individually like this:
git grep 'DefineConstant.*NAME' :/
(where NAME is an item from "defined constants list")git grep '#.*if.*NAME' ':/*.cs' ':/*.vb' ':/*.fs'
(where NAME is an item from "used constants list")
Under
src/libraries
, these are the lists of unique constants:defined in project files (71)
* ALLOW_PARTIALLY_TRUSTED_CALLERS * ActivatorUtilities_In_DependencyInjection * BUILDING_INBOX_LIBRARY * CAS_OBSOLETIONS * CODEDOM * DEBUG * DRAWING_NAMESPACE * ENABLECOMBINDER * ENABLE_HTTP_HANDLER * ES_BUILD_STANDALONE * EVENTSOURCE_ACTIVITY_SUPPORT * EVENTSOURCE_ENUMERATE_SUPPORT * FEATURE_COMPILE * FEATURE_COMPILED_XSL * FEATURE_DLG_INVOKE * FEATURE_DSA_HASHDATA * FEATURE_ECDH_DERIVEFROM * FEATURE_ECPARAMETERS * FEATURE_FAST_CREATE * FEATURE_INTERPRET * FEATURE_MANAGED_ETW * FEATURE_REGISTRY * FEATURE_SERIALIZATION * FEATURE_SYSTEM_EVENTS * FEATURE_TRACING * FEATURE_UTF8STRING * FEATURE_WINDOWS_SYSTEM_COLORS * FEATURE_XML_XPATH_ID * FLAVOR_WHIDBEY * FUNCTIONAL_TESTS * HAVE_THUMBPRINT_OVERLOADS * HTTP3 * HTTP_DLL * IL_EMIT * INTERNAL_ASYMMETRIC_IMPLEMENTATIONS * INTERNAL_NULLABLE_ATTRIBUTES * LATEBINDING * MAKE_ABW_PUBLIC * MS_IO_REDIST * NETSTANDARD * NOSPAN * NO_EVENTCOMMANDEXECUTED_SUPPORT * NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT * PAPI_AD * PAPI_REGSAM * PRODUCT * REGISTRY_ASSEMBLY * RESOURCES_EXTENSIONS * ReflectionOnly * SAVE_ASSEMBLIES * SERIAL_PORTS * SYSNETHTTP_NO_OPENSSL * SYSNETSECURITY_NO_OPENSSL * SYSTEM_NET_PRIMITIVES_DLL * SYSTEM_NET_SOCKETS_DLL * TARGETS_BROWSER * TARGET_WINDOWS * TESTING_CNG_IMPLEMENTATION * TRACE * TargetsWindows * USE_CTX_CACHE * USE_INTERNAL_ACCESSIBILITY * USE_INTERNAL_CONCURRENT_COLLECTIONS * USE_INTERNAL_THREADING * USE_MDT_EVENTSOURCE * Unix * W3C_DEFAULT_ID_FORMAT * WINHTTPHANDLER_DLL * WINHTTPHANDLER_TEST * XMLSERIALIZERGENERATORTESTS * netcoreapp
used in C# / VB code (196)
* ALLOW_PARTIALLY_TRUSTED_CALLERS * ARCH_arm * ASSERT_VERBOSE * ActivatorUtilities_In_DependencyInjection * BIGENDIAN * BINDING_LOG * BUILDING_INBOX_LIBRARY * CAP_PointerType * CAP_TypeOfPointer * CAS_OBSOLETIONS * CBOR_PROPERTY_TESTS * CHECK_ACCURATE_ENSURE * CHECK_ATTRIBUTE_ORDER * CODEDOM * CORECLR * CORERT * DCR27419 * DEBUG * DEBUGRESOURCES * DEBUG_CLIPPING * DEBUG_FORCE_ZIP64 * DEBUG_HANDLE * DISABLE_MATCH_OPTIMIZATION * DISABLE_SWITCH * DontUse * EERANGE * ENABLECOMBINDER * ENABLEDATABINDING * ENABLEDYNAMICPROGRAMMING * ENABLE_HTTP_HANDLER * ENTITY_ENCODE_HIGH_ASCII_CHARS * ES_BUILD_AGAINST_DOTNET_V35 * ES_BUILD_PCL * ES_BUILD_STANDALONE * ES_SESSION_INFO * EVENTSOURCE_ACTIVITY_SUPPORT * EVENTSOURCE_ENUMERATE_SUPPORT * EVENTSOURCE_GENERICS * EVENT_SOURCE_LEGACY_NAMESPACE_SUPPORT * EXPANDRANGE * FALSE * FASTLOOP * FEATURE_ADVANCED_MANAGED_ETW_CHANNELS * FEATURE_COMPILE * FEATURE_COMPILED_XSL * FEATURE_COMPILE_TO_METHODBUILDER * FEATURE_COMPONENT_COLLECTION * FEATURE_DEFAULT_INTERFACES * FEATURE_DLG_INVOKE * FEATURE_DSA_HASHDATA * FEATURE_DYNAMIC_DELEGATE * FEATURE_ECDH_DERIVEFROM * FEATURE_ECPARAMETERS * FEATURE_EVENTSOURCE_XPLAT * FEATURE_FAST_CREATE * FEATURE_INTERNAL_REFLECTIONCONTEXT * FEATURE_INTERPRET * FEATURE_MAKE_RUN_METHODS * FEATURE_MANAGED_ETW * FEATURE_MANAGED_ETW_CHANNELS * FEATURE_PDB_GENERATOR * FEATURE_PERFTRACING * FEATURE_REGISTRY * FEATURE_SERIALIZATION * FEATURE_SKIP_INTERFACE * FEATURE_SYSTEM_EVENTS * FEATURE_THREAD_ABORT * FEATURE_TRACING * FEATURE_UTF8STRING * FEATURE_WINDOWS_SYSTEM_COLORS * FEATURE_XML_XPATH_ID * FINALIZATION_WATCH * FINDUPA_PARTICLE * FUNCTIONAL_TESTS * GDI_FINALIZATION_WATCH * GENERICITY_LOG * GETTYPEFROMHANDLEUNSAFE * HAS_CUSTOM_BLOCKS * HAVE_STORE_ISOPEN * HAVE_THUMBPRINT_OVERLOADS * HIDE_XSL * HTTP3 * IL_EMIT * INTERNAL_ASYMMETRIC_IMPLEMENTATIONS * INTERNAL_NULLABLE_ATTRIBUTES * KESTREL * LATEBINDING * M3 * MAKE_ABW_PUBLIC * MONO * MS * MS_IO_REDIST * MTNAMETABLE * NAVREADER_SUPPORTSLINEINFO * NET45 * NET451 * NET452 * NET46 * NET461 * NET462 * NET47 * NET471 * NET472 * NETCOREAPP * NETCOREAPP2_0 * NETCOREAPP2_1 * NETCOREAPP3_0 * NETFRAMEWORK * NETSTANDARD * NETSTANDARD1_0 * NETSTANDARD1_1 * NETSTANDARD1_3 * NETSTANDARD1_6 * NETSTANDARD2_0 * NETSTANDARD2_1 * NEVER * NO * NOPARSE * NO_ASYNC_LOCAL * NO_DSA_AVAILABLE * NO_EPHEMERALKEYSET_AVAILABLE * NO_EVENTSOURCE_COMPLEX_TYPE_SUPPORT * NO_FEATURE_STATIC_DELEGATE * NotUsed * OLDWRITER * OPTIMIZED_MEASUREMENTDC * OUT * PAPI_AD * PAPI_REGSAM * PBTCOMPILER * PERF * PHONE * PRIYAL * PRODUCT * PrintDebug * QIL_TRACE_NODE_CREATION * REGISTRY_ASSEMBLY * RELEASE * RESOURCES_EXTENSIONS * ReflectionOnly * SAVE_ASSEMBLIES * SERIAL_PORTS * SOCKETASYNCCONTEXT_TRACE * SPLAY_MTNAMETABLE * STATS * SUPPORT_SURROGATE * SUPPORT_WK_USER_OBJS * SYSNETSECURITY_NO_OPENSSL * SYSTEM_HASHCODE_TESTVECTORS * SYSTEM_NET_PRIMITIVES_DLL * SYSTEM_NET_SOCKETS_DLL * SYSTEM_PRIVATE_CORELIB * SchemaTypeImport * StopMaskOptimisation * StressTest * TARGETS_BROWSER * TARGET_32BIT * TARGET_64BIT * TARGET_AMD64 * TARGET_ARM * TARGET_ARM64 * TARGET_BROWSER * TARGET_IOS * TARGET_OSX * TARGET_TVOS * TARGET_UNIX * TARGET_WINDOWS * TEMP_HACK_FOR_SCHEMA_INFO * TESTHOOK * TESTING_CNG_IMPLEMENTATION * TEST_WINRT * TRACK_HDC * TRUST_COMPILE_STATE * TargetsWindows * USE_CTX_CACHE * USE_INTERNAL_ACCESSIBILITY * USE_INTERNAL_CONCURRENT_COLLECTIONS * USE_INTERNAL_THREADING * USE_MDT_EVENTSOURCE * USE_REFEMIT * Unix * VerifyIndex * VerifyPath * VerifySort * W3C_DEFAULT_ID_FORMAT * WIN32 * WINHTTPHANDLER_DLL * WINHTTPHANDLER_TEST * XMLCHARTYPE_GEN_RESOURCE * XMLSERIALIZERGENERATORTESTS * XSLT2 * _LOGGING * c1 * false * not_used * true
There is a room to cleanup or fix the dead code. Some of these constants are not defined since the initial port. Some are defined but unused. Some of them can be merged as they differ by casing or spelling (
TargetsWindows
vs.TARGET_WINDOWS
). Some usages can probably be replaced by others, like#if VerifyXX
to#if DEBUG
.