Skip to content

Commit 550905f

Browse files
authored
Merge pull request #3358 from pyrevitlabs/fix/newloader2019
fix(loader): fall back to Python loader on Revit 2019/2020
2 parents 496e71b + fee5860 commit 550905f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

pyrevitlib/pyrevit/loader/sessionmgr.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
# Build strategy constant (Roslyn is the only supported strategy)
5050
BUILD_STRATEGY_ROSLYN = "Roslyn"
5151

52+
# Minimum Revit version that supports the new C# loader.
53+
# Revit 2019/2020 ship an older .NET Framework and system assemblies
54+
# (System.Runtime.CompilerServices.Unsafe, System.Collections.Immutable)
55+
# that are incompatible with the Roslyn version bundled in pyRevit.
56+
NEW_LOADER_MIN_REVIT_VERSION = 2021
57+
5258

5359
AssembledExtension = namedtuple("AssembledExtension", ["ext", "assm"])
5460

@@ -389,6 +395,23 @@ def load_session():
389395
# create a new session
390396
if not user_config.new_loader:
391397
mlogger.info("Creating new pyRevit session with pyRevitLoader.py...")
398+
mlogger.debug(
399+
"The legacy Python loader is deprecated and will be removed in "
400+
"future releases. Enable the new loader in pyRevit settings."
401+
)
402+
_new_session()
403+
elif HOST_APP.is_older_than(NEW_LOADER_MIN_REVIT_VERSION):
404+
mlogger.warning(
405+
"The new C# loader is not supported on Revit %s (requires Revit %s+). "
406+
"Falling back to the legacy Python loader automatically.",
407+
HOST_APP.version,
408+
NEW_LOADER_MIN_REVIT_VERSION,
409+
)
410+
mlogger.warning(
411+
"The legacy Python loader is deprecated and will be removed in "
412+
"future releases. Upgrade to Revit %s or newer to use the new loader.",
413+
NEW_LOADER_MIN_REVIT_VERSION,
414+
)
392415
_new_session()
393416
else:
394417
mlogger.info("Creating new Session with pyRevitAssemblyMaker.dll...")

0 commit comments

Comments
 (0)