Skip to content

fix: resolve C# loader regressions (#3108, #3107, #3140, version-info) #3188

Merged
jmcouffin merged 5 commits intodevelopfrom
fix/csharp-loader-regressions
Mar 27, 2026
Merged

fix: resolve C# loader regressions (#3108, #3107, #3140, version-info) #3188
jmcouffin merged 5 commits intodevelopfrom
fix/csharp-loader-regressions

Conversation

@tay0thman
Copy link
Copy Markdown
Contributor

resolve C# loader regressions

Description

  • [Bug]: Startup scripts fail in 6.1 #3108: Restore multi-pass loop in SessionManagerService.LoadSession() so all assemblies load before any startup script runs. Fixes cross-extension imports in startup scripts.

  • [Bug]: Extension folder can't start with a number #3107: Prefix underscore when SanitizeClassName() produces a name starting with a digit (invalid C# identifier). Applied in ExtensionParser, CommandTypeGenerator, ButtonBuilderBase, StackBuilder.

  • [Bug]:ERROR [pyrevit.loader.sessionmgr] #3140: Add HashSet dedup guard in CommandTypeGenerator.GenerateExtensionCode() to skip duplicate class names instead of emitting CS0101 Roslyn errors.

  • Version info: Pass revitYear through ExtensionManagerService to ExtensionParser.ParseInstalledExtensions() so min/max version filtering works correctly. Previously defaulted to 0 (unknown).


Checklist

Before submitting your pull request, ensure the following requirements are met:

  • [OK ] Changes are tested and verified to work as expected.

Related Issues

If applicable, link the issues resolved by this pull request:


Additional Notes

Tested on Revit 2026 (netcore) and 2024(netfx)


Thank you for contributing to pyRevit! 🎉

@devloai
Copy link
Copy Markdown
Contributor

devloai bot commented Mar 22, 2026

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.

@tay0thman tay0thman force-pushed the fix/csharp-loader-regressions branch from 0e8830b to 60982e0 Compare March 22, 2026 11:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 addresses several regressions in the C# loader path of pyRevit’s Revit add-in, aiming to restore legacy loader behavior for startup ordering, identifier generation, duplicate type handling, and Revit version filtering.

Changes:

  • Reintroduces multi-pass session loading so all extension assemblies load before any startup scripts execute.
  • Hardens identifier/class-name sanitization (including leading-digit handling) across parser, generators, and UI builders.
  • Adds Revit-year propagation into extension parsing for min/max version gating, and introduces a duplicate class-name guard in Roslyn code generation.

Reviewed changes

Copilot reviewed 10 out of 26 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dev/pyRevitLoader/pyRevitExtensionParserTester/ParsedBundleTests.cs Updates test sanitizer to match production leading-digit behavior.
dev/pyRevitLoader/pyRevitExtensionParserTester/ComponentValidationTests.cs Tightens UniqueId validity rules in tests (disallow leading digits).
dev/pyRevitLoader/pyRevitExtensionParser/ParsedExtension.cs Adds RocketModeCompatible flag on parsed extensions.
dev/pyRevitLoader/pyRevitExtensionParser/ExtensionParser.cs Adds Revit version compatibility checks and passes revitYear through parsing; updates UniqueId sanitization logic.
dev/pyRevitLoader/pyRevitAssemblyBuilder/UIManager/SessionManagerService.cs Restores multi-pass load order: build/load assemblies → run startup scripts → build UI.
dev/pyRevitLoader/pyRevitAssemblyBuilder/UIManager/Buttons/ButtonBuilderBase.cs Ensures generated command class identifiers never start with a digit.
dev/pyRevitLoader/pyRevitAssemblyBuilder/UIManager/Builders/StackBuilder.cs Aligns stack builder class-name sanitization with leading-digit fix.
dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/ServiceFactory.cs Parses/passes Revit year into ExtensionManagerService for version filtering.
dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/ExtensionManagerService.cs Uses revitYear when parsing installed extensions (cached).
dev/pyRevitLoader/pyRevitAssemblyBuilder/AssemblyMaker/CommandTypeGenerator.cs Adds duplicate class-name guard; updates engine-config generation behavior and identifier sanitization.

Addresses Copilot review: avoid misleading 'skipped' log messages
and log spam when Revit version is unknown (revitYear <= 0).
@tay0thman
Copy link
Copy Markdown
Contributor Author

@devloai If you are available , review my responses to copilot AI

@devloai
Copy link
Copy Markdown
Contributor

devloai bot commented Mar 23, 2026

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 26 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

dev/pyRevitLoader/pyRevitExtensionParser/ParsedExtension.cs:23

  • ParsedExtension now declares RocketModeCompatible twice (one auto-property at line 19 and another at lines 21-27 with default initializer). This will not compile due to duplicate member names. Remove one of the properties (and keep the XML doc + default initializer on the remaining one if needed).
        public bool RocketModeCompatible { get; set; }

        /// <summary>
        /// Gets or sets whether this extension is compatible with rocket mode.
        /// When rocket mode is enabled and the extension is compatible, the engine

…ptions

- Remove duplicate RocketModeCompatible declaration (already in develop)
- Log ex.ToString() instead of ex.Message in SessionManagerService catch blocks
@tay0thman
Copy link
Copy Markdown
Contributor Author

@jmcouffin can you request another round of review by copilot? I think I covered all of its comments but just to make sure, I tested the DLLs locally and looks good here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 25 changed files in this pull request and generated 2 comments.

@jmcouffin jmcouffin self-assigned this Mar 24, 2026
@jmcouffin
Copy link
Copy Markdown
Contributor

@romangolev can you take a look?

@romangolev
Copy link
Copy Markdown
Member

@tay0thman @jmcouffin works well in Revit 2025 ^_^

@jmcouffin jmcouffin merged commit 69775c5 into develop Mar 27, 2026
@jmcouffin
Copy link
Copy Markdown
Contributor

@tay0thman blessing from Roman!
Bravo!

@jmcouffin jmcouffin deleted the fix/csharp-loader-regressions branch March 27, 2026 20:01
@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26086+2004-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26088+1318-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26089+1231-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+0549-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1533-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1536-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1556-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New public release are available for 6.2.0.26090+1754

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Startup scripts fail in 6.1

4 participants