Skip to content

Drop legacy pre-2021 Revit fallbacks (runtime + loader) - #3585

Merged
jmcouffin merged 4 commits into
developfrom
refactor/drop-legacy-revit-version-checks
Aug 27, 2026
Merged

jmcouffin merged 4 commits into
developfrom
refactor/drop-legacy-revit-version-checks

Conversation

@romangolev

Copy link
Copy Markdown
Member

Summary

  • Removes the pre-2017 UIApplication field fallback (NEW_UIAPP_FIELD_VERSION/LEGACY_UIAPP_FIELD) from the C# loader, now that the minimum supported host is Revit 2021.
  • Strips REVIT2013..REVIT2020 preprocessor branches and their fallbacks across pyRevitLabs.PyRevit.Runtime, and tightens the loader theme detector's UIThemeManager gate to REVIT2021+.

Split out of #3559 per review feedback — these are C# preprocessor branches rather than the Python HOST_APP gates that PR targets.

Test plan

  • Build and attach a dev clone against a Revit 2021+ host, confirm session loads and dark-mode theme detection still works.

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+.
@devloai

devloai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

@romangolev romangolev self-assigned this Aug 25, 2026
@jmcouffin
jmcouffin requested a balanced review from Copilot August 25, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_application field fallback and its version-based selection in the loader; the loader now always uses MODERN_UIAPP_FIELD (m_uiapplication), and the unused constants were deleted from Constants.cs.
  • Deleted #if (REVIT2013..REVIT2020) / #else preprocessor branches (and associated REVIT2021_OR_GREATER guards) across runtime files, keeping only the modern (2021+) code paths.
  • Tightened the pre-UIThemeManager gate in RevitThemeDetector.cs and the deprecated #if !(...) version lists (e.g. Value/IntegerValue, Int64/Int32) to the supported REVIT2021/REVIT2022/REVIT2023 set.

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.

@jmcouffin

Copy link
Copy Markdown
Contributor

@romangolev ready to be looked at?

@romangolev
romangolev marked this pull request as ready for review August 26, 2026 22:41
@romangolev
romangolev requested a review from jmcouffin August 26, 2026 22:41
@romangolev

Copy link
Copy Markdown
Member Author

@romangolev ready to be looked at?

yep

@jmcouffin jmcouffin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@jmcouffin
jmcouffin merged commit 961fef2 into develop Aug 27, 2026
@jmcouffin jmcouffin added the Backward Compatibility Backward Compatibility Issue with Older Revit Versions label Aug 27, 2026
@romangolev
romangolev deleted the refactor/drop-legacy-revit-version-checks branch August 27, 2026 15:46
@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backward Compatibility Backward Compatibility Issue with Older Revit Versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants