Fix/adc v2027 net8 fallback - Autodesk desktop connector#3266
Fix/adc v2027 net8 fallback - Autodesk desktop connector#3266
Conversation
Refine GitHub Actions workflow to improve reference commit logic for pull requests. Updated condition to handle merged pull requests more effectively.
Release 6.3 + touch up
Release touch up 6.3
pre release: fix main.yml
ADC v2027 (v7.8.1.11) removed the .NET 8-compatible API DLL from
FOS/AddInProcess/Civil3DOE. Both remaining API CLSsurfaces (legacy API.dll
and new API.Public.dll) were compiled against .NET Framework's unified
System.ServiceModel, making them unusable on Revit 2025/2026 (.NET 8).
Fix: three-tier fallback in adc.py
- Tier 1: Public API (future-proof for when Autodesk fixes the DLL)
- Tier 2: Legacy API (ADC v15-v17, exclusive elif to prevent AppDomain poison)
- Tier 3: Filesystem fallback (process detection + workspace dir walking)
Also restructures Keynote Manager diagnostic into safe/deep tiers to
prevent WCF AppDomain poisoning during troubleshooting.
Tested on: ADC v17.x + Revit 2024, ADC v17.x + Revit 2026,
ADC v2027 + Revit 2024, ADC v2027 + Revit 2026.
Closes #XXXX
There was a problem hiding this comment.
PR Summary:
- Fixes ADC v2027 compatibility regression on Revit 2025/2026 (.NET 8) where both legacy and public API DLLs have broken WCF dependencies
- Adds a three-tier fallback: Public API → Legacy API → Filesystem (process detection + workspace directory walking)
- Restructures Keynote Manager ADC diagnostics into safe (always-on) and deep (env-gated) tiers to avoid AppDomain poisoning
- Gracefully degrades lock/sync operations when only the Public API is available
Review Summary:
This is a well-motivated fix for a real Autodesk regression, and the AppDomain-poisoning concern is correctly identified and handled. The three-tier architecture is sound. A few bugs were found:
High priority: The AssemblyResolve handler registered in _preload_wcf_for_public_api is never unregistered and its partial-match fallback (req in cn or cn in req) could silently redirect unrelated assemblies for the entire Revit session. Additionally, is_available()'s filesystem fallback can return True when get_local_path() will subsequently return None (mismatched org/drive), giving users a confusing secondary error.
Medium priority: _pub_drive_path_to_local uses str.replace() (replaces all occurrences) instead of a prefix-strip. The 10-character fuzzy project folder match in _resolve_path_from_filesystem risks false-positive matches. A dead-code guard condition in _determine_kfile (line 1278) always evaluates _kfile_handler != 'unknown' as False. The _try_wcf_shim function mutates adc.API without updating adc._api_mode, leaving module state inconsistent.
Low priority: NuGet version directories are sorted lexicographically rather than semantically (affects minor versions ≥ 10). Black formatting was explicitly skipped per the PR checklist but is a repository requirement.
Suggestions
- Run
pipenv run blackon both changed files to satisfy the mandatory Black formatting requirement before merging. Apply - Add a dedicated
get_local_pathoverload tois_available()so the filesystem fallback can pre-validate the cloud path's org segment and avoid a misleading secondary error when path resolution fails. Apply
⚡ Apply all quick fixes (7 quick fixes)
extensions/pyRevitTools.extension/pyRevit.tab/Drawing Set.panel/Keynotes.pushbutton/script.py
Outdated
Show resolved
Hide resolved
extensions/pyRevitTools.extension/pyRevit.tab/Drawing Set.panel/Keynotes.pushbutton/script.py
Outdated
Show resolved
Hide resolved
- Apply Black formatter to both changed files - Fix .None enum access for Black parser compatibility (getattr pattern) - Remove partial-match from AssemblyResolve handler (exact keys only) - Use prefix-strip instead of str.replace in path resolution - Replace 10-char fuzzy match with full startswith comparison - Validate workspace roots contain org dirs in filesystem fallback - Remove dead-code guard in _determine_kfile - Remove adc.API mutation from diagnostic _try_wcf_shim - Add semantic version sorting for NuGet directory scanning
There was a problem hiding this comment.
✅ All previous review issues addressed
Excellent work on commit 55a92451. Every issue from the previous review has been cleanly resolved:
| # | Issue | Status |
|---|---|---|
| 1 | AssemblyResolve partial-match fallback (unrelated assembly redirection risk) |
✅ Removed — exact key lookup only in adc.py |
| 2 | str.replace() in _pub_drive_path_to_local (all-occurrences risk) |
✅ Fixed — path[len(drive_schema):] prefix-strip |
| 3 | 10-char fuzzy project folder match (wrong-project false positives) | ✅ Fixed — full bidirectional startswith |
| 4 | is_available() filesystem fallback returning True for empty workspace roots |
✅ Fixed — now validates org subdirs exist |
| 5 | Dead-code _kfile_handler != 'unknown' guard |
✅ Removed — _determine_kfile fully restructured |
| 6 | adc.API = api_module module state mutation in diagnostic |
✅ Removed — _try_wcf_shim is observe-only |
| 7 | Lexicographic NuGet version sort (fails for minor ≥ 10) | ✅ Fixed — _ver_key() semantic sort |
| 8 | Black formatting not applied | ✅ Applied throughout both files |
One minor note (non-blocking): _try_wcf_shim in script.py (lines 545–547) still has the partial-match AssemblyResolve fallback — but this is intentionally in the deep diagnostic (poison-aware) path and is clearly scoped/commented as such. Acceptable design choice.
The three-tier fallback architecture is well-structured, the AppDomain-poisoning concern is properly guarded, and the diagnostic system is a nice addition for user-facing debugging. LGTM 👍
|
Tested by user in #3089 🏁 |
|
@tay0thman can you remove all the now unnecessary logging please. I'll review and merge after that |
|
@jmcouffin Removed all Logging and pushed commit ef91266 |
|
📦 New work-in-progress (wip) builds are available for 6.3.0.26097+2031-wip |
|
📦 New work-in-progress (wip) builds are available for 6.3.0.26097+2314-wip |
fix(adc): ADC v2027 compatibility — filesystem fallback for Revit 2025/2026 (.NET 8)
Description
ADC v2027 (v7.8.1.11) broke
pyrevit.interop.adcon Revit 2025/2026 (.NET 8). The Keynote Manager shows "Autodesk Desktop Connector is not available" even though ADC is installed, running, and files are synced locally.Root cause: ADC v2027 removed the .NET 8-compatible API DLL from
FOS\AddInProcess\Civil3DOE. Both remaining API surfaces — the legacyAutodesk.DesktopConnector.API.dlland the newAutodesk.DesktopConnector.API.Public.dll— were compiled against .NET Framework'sSystem.ServiceModel(WCF), which does not exist on .NET 8. This is an Autodesk regression with no assembly-level workaround.Fix: Adds a three-tier fallback architecture to
adc.py:DesktopConnectorApiClient(v2027+)DesktopConnectorService(v15–v17)The filesystem fallback detects the ADC tray process, parses the cloud path schema (
Autodesk Forma://org/project/...), and resolves it to the local file under%USERPROFILE%\DC\ACCDocs\. Lock/unlock/sync degrade to no-ops — ADC handles sync transparently at the OS level.Also restructures the Keynote Manager's ADC diagnostic into two tiers: a safe diagnostic (tests Public API only, no AppDomain poisoning) that runs for all users, and a deep diagnostic (probes legacy DLLs + WCF) gated behind
PYREVIT_ADC_DIAG=1environment variable.Critical design decision: When
API.Public.dllexists (v2027), the legacy load is never attempted (exclusiveelif).DesktopConnectorService()triggers WCF resolution whose failure is cached in the .NET AppDomain, poisoning all subsequent assembly loads — including unrelated code.Files changed
pyrevitlib/pyrevit/interop/adc.py— Three-tier load sequence, WCF preloading, filesystem fallback with workspace directory scanning, graceful degradation for lock/sync operationsextensions/.../Keynotes.pushbutton/script.py— Two-tier diagnostic system (_adc_diagnose_safe/_adc_diagnose_deep), restructured_determine_kfile()to callis_available()on clean AppDomain before any diagnostic runsCompatibility matrix
Checklist
pipenv run black {source_file_or_directory}Related Issues
Additional Notes
Testing performed
All four combinations verified on physical hardware:
Autodesk regression
This should also be reported to Autodesk: ADC v2027 ships zero functional .NET 8 API surfaces. The
FOS\AddInProcess\Civil3DOEDLL was removed and the replacementAPI.Public.dllhas a transitive WCF dependency that prevents instantiation on .NET 8. All Revit 2025/2026 add-ins that depend on the ADC API are affected.Diagnostic workflow for users reporting issues
Users experiencing ADC issues can set the environment variable
PYREVIT_ADC_DIAG=1before launching Revit. This enables the deep diagnostic tier which probes legacy DLLs, WCF assemblies, and prints a detailed report to the pyRevit output window. Without the env var, only the safe (non-poisoning) diagnostic runs.Thank you for contributing to pyRevit! 🎉