Drop legacy pre-2021 Revit fallbacks (runtime + loader) - #3585
Conversation
Remove the pre-2017 version branch in GetUIApplication along with the now-unused NEW_UIAPP_FIELD_VERSION and LEGACY_UIAPP_FIELD constants, since the minimum supported Revit version no longer requires the legacy m_application field lookup.
Strip REVIT2013..REVIT2020 preprocessor checks and their fallbacks across the pyRevitLabs.PyRevit.Runtime project since those Revit versions are no longer supported, and tighten the loader theme detector's UIThemeManager gate to REVIT2021+.
|
Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔 |
There was a problem hiding this comment.
Pull request overview
This PR is a mechanical cleanup that removes dead pre-2021 Revit compatibility code, now that the minimum supported host is Revit 2021. It follows up on #3438/#3559 by targeting the C# preprocessor branches (rather than the Python HOST_APP gates handled in #3559). It removes the UIApplication reflection field fallback in the loader, strips REVIT2013..REVIT2020 #if/#else branches throughout pyRevitLabs.PyRevit.Runtime, and narrows the theme detector's non-UIThemeManager gate to REVIT2021–REVIT2023.
Changes:
- Removed the legacy
m_applicationfield fallback and its version-based selection in the loader; the loader now always usesMODERN_UIAPP_FIELD(m_uiapplication), and the unused constants were deleted fromConstants.cs. - Deleted
#if (REVIT2013..REVIT2020)/#elsepreprocessor branches (and associatedREVIT2021_OR_GREATERguards) across runtime files, keeping only the modern (2021+) code paths. - Tightened the pre-
UIThemeManagergate inRevitThemeDetector.csand the deprecated#if !(...)version lists (e.g.Value/IntegerValue,Int64/Int32) to the supportedREVIT2021/REVIT2022/REVIT2023set.
I verified the removed constants have no remaining references, no REVIT2019/REVIT2020 build targets remain (csproj targets are 2021–2027), each build defines only its exact REVIT{version} symbol so the #if !(REVIT2021 || REVIT2022 || REVIT2023) conditions preserve the intended 2021–2023 vs 2024+ behavior, and preprocessor directives and method return paths remain balanced/valid. No issues were found.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dev/pyRevitLoader/Source/PyRevitLoaderApplication.cs | Uses MODERN_UIAPP_FIELD directly and updates the error message; drops version-based field selection |
| dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/Constants.cs | Removes NEW_UIAPP_FIELD_VERSION and LEGACY_UIAPP_FIELD constants |
| dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/RevitThemeDetector.cs | Narrows the non-UIThemeManager gate to REVIT2021–REVIT2023 |
| dev/pyRevitLabs.PyRevit.Runtime/telemetry.cs | Drops the pre-2021 GetRevitBuild branch and the REVIT2021_OR_GREATER guard on _exeBuild |
| dev/pyRevitLabs.PyRevit.Runtime/ScriptConsoleUtils.cs | Removes legacy using and SelElementSet selection branch; narrows ElementId int/long gate |
| dev/pyRevitLabs.PyRevit.Runtime/ScriptCommands.cs | Removes legacy cloud/active-view branches; narrows Value/IntegerValue gates |
| dev/pyRevitLabs.PyRevit.Runtime/GrasshopperEngine.cs | Removes ActiveView fallback, keeps ActiveGraphicalView |
| dev/pyRevitLabs.PyRevit.Runtime/EventTelemetry.cs | Removes many pre-2021 #if guards/fallbacks, keeping modern telemetry paths |
| dev/pyRevitLabs.PyRevit.Runtime/EventHooks.cs | Removes pre-2021 #if guards around event hook methods |
| dev/pyRevitLabs.PyRevit.Runtime/EventHandling.cs | Removes pre-2021 guards in the interface, hook toggles, and window/dialog helpers |
| dev/pyRevitLabs.PyRevit.Runtime/ContentEngine.cs | Removes the pre-2015 NotSupported short-circuit branch |
| dev/pyRevitLabs.PyRevit.Runtime/CLREngine.cs | Removes legacy _0 sub-version define fallback |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@romangolev ready to be looked at? |
# Conflicts: # dev/pyRevitLabs.PyRevit.Runtime/ScriptConsoleUtils.cs
yep |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
|
📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139 |
Summary
UIApplicationfield fallback (NEW_UIAPP_FIELD_VERSION/LEGACY_UIAPP_FIELD) from the C# loader, now that the minimum supported host is Revit 2021.REVIT2013..REVIT2020preprocessor branches and their fallbacks acrosspyRevitLabs.PyRevit.Runtime, and tightens the loader theme detector'sUIThemeManagergate to REVIT2021+.Split out of #3559 per review feedback — these are C# preprocessor branches rather than the Python
HOST_APPgates that PR targets.Test plan