Fix Service Broker objects not displayed in Object Explorer#2629
Draft
Fix Service Broker objects not displayed in Object Explorer#2629
Conversation
Co-authored-by: Benjin <1609827+Benjin@users.noreply.github.com>
The Service Broker tree node was created as a FolderNode that delegated its context to the parent (Database) node. Child queriers like SqlMessageTypeQuerier expected context.Parent to be ServiceBroker, but always received Database - causing them to return empty collections. Root cause: ServiceBroker extends SqlSmoObject (not NamedSmoObject), so it couldn't be cached in the standard SmoTreeNode mechanism. Fix: Add ServiceBrokerFolderNode that overrides GetContext() to fetch the ServiceBroker SMO object from the Database and return a context with it as parent. Also add parent type mismatch logging to all service broker queriers and the SmoQueryModel.tt template. Co-authored-by: Benjin <1609827+Benjin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Bug] Fix service broker objects not being displayed
Fix Service Broker objects not displayed in Object Explorer
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Service Broker sub-items (Message Types, Contracts, Queues, Services, etc.) always showed empty in the Object Explorer because child queriers never found a
ServiceBrokerparent.Root Cause
ServiceBrokerextendsSqlSmoObject, notNamedSmoObject, so it cannot be stored via the standardSmoTreeNode.CacheInfoFromModelmechanism. The "Service Broker" node was a plainFolderNodewhoseGetContext()delegates upward — meaning child queriers received a context withParent = Databaseinstead ofParent = ServiceBroker, causing theas ServiceBrokercast to always returnnull.Changes
ServiceBrokerFolderNode.cs(new): OverridesGetContext()to fetchdb.ServiceBrokerfrom the database context and return aCopyWithParent(serviceBroker)context. Child folder nodes inherit this via theFolderNodedelegation chain:SmoTreeNodes.cs/SmoTreeNodes.tt:DatabaseChildFactory.OnExpandPopulateFoldersnow instantiatesServiceBrokerFolderNodeinstead ofFolderNodefor the Service Broker node.SmoQueryModel.cs/SmoQueryModel.tt: Addedelselogging to all Service Broker queriers that records the actual parent type when theServiceBrokercast fails, aiding future diagnosis.Code Changes Checklist
dotnet test)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
bad-server-name/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 46629 --endpoint 127.0.0.1:046629 --role client --parentprocessid 8231 --telemetryoptedin false(dns block)/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 39011 --endpoint 127.0.0.1:039011 --role client --parentprocessid 9694 --telemetryoptedin false(dns block)servername/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 46629 --endpoint 127.0.0.1:046629 --role client --parentprocessid 8231 --telemetryoptedin false(dns block)/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.runtimeconfig.json --depsfile /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/Microsoft.SqlTools.ServiceLayer.UnitTests.deps.json /home/REDACTED/work/sqltoolsservice/sqltoolsservice/test/Microsoft.SqlTools.ServiceLayer.UnitTests/bin/Debug/net8.0/testhost.dll --port 39011 --endpoint 127.0.0.1:039011 --role client --parentprocessid 9694 --telemetryoptedin false(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.