Wire up missing organization Refit clients and fix ChannelUtilization route parameter (fixes #337) - #358
Merged
Conversation
The MerakiClient constructor never assigned several organization-level
Refit clients, so they were still null after construction and threw
NullReferenceException on first use:
Organizations.Summary.SwitchPower
Organizations.Appliance.Uplinks.Usage
Organizations.Wireless.Devices.Latency
Organizations.Wireless.Devices.PacketLoss
Organizations.Wireless.Devices.ChannelUtilization
IOrganizationsWirelessDevicesChannelUtilization additionally could not be
built by Refit at all. All four of its methods spelled the parameter
"orgnanizationId" while the route templates used {organizationId}, so
RestService.For<T>() threw:
ArgumentException: URL /organizations/{organizationId}/wireless/devices/
channelUtilization/byDevice has parameter organizationid, but no method
parameter matches
The parameter is now organizationId throughout. Callers using named
arguments would need to update, but the interface could not be
constructed before this fix, so nothing could have called it.
Adds MerakiClientSectionWiringTests, which needs no network and no API
key because the wiring happens entirely in the constructor.
This closes the five cases in #337 only. A reflection census of the
section tree shows 82 further Refit clients and 4 sub-sections are still
left null by the constructor; that is tracked separately in #357.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
.editorconfig sets csharp_style_unused_value_expression_statement_preference to discard_variable, which surfaces as IDE0058 in the IDE. Nine statements in the test project discarded their value implicitly. They now use the explicit discard, matching the rest of the test project. Behaviour is unchanged; this is a style-only fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 8 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
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.
Fixes #337.
What was wrong
Two separate defects, both reported in #337.
1. Organization Refit clients never assigned. The
MerakiClientconstructor did not assign these, so they were stillnullafter construction and threwNullReferenceExceptionon first use:Organizations.Summary.SwitchPowerOrganizations.Appliance.Uplinks.UsageOrganizations.Wireless.Devices.LatencyOrganizations.Wireless.Devices.PacketLossOrganizations.Wireless.Devices.ChannelUtilizationSummarywas initialized with onlyTop, and there was no initializer block at all forOrganizations.ApplianceorOrganizations.Wireless.2.
IOrganizationsWirelessDevicesChannelUtilizationcould not be built by Refit. All four of its methods spelled the parameterorgnanizationIdwhile the route templates used{organizationId}, soRestService.For<T>()threw:This one had to be fixed for the wiring to work, since wiring it up without the fix would throw at
new MerakiClient(...)for every consumer.What changed
MerakiClient.cs: added theAppliance,Summary.SwitchPowerandWirelessinitializer entries, placed in the existing alphabetical order.IOrganizationsWirelessDevicesChannelUtilization.cs: parameter renamed toorganizationIdon all four methods, with the matching<param>doc tags.MerakiClientSectionWiringTests.cs: new. Needs no network and no API key, because the wiring happens entirely in the constructor.CHANGELOG.md: entry under 1.70.42. The version heading is a guess and may need correcting at release.A second commit fixes 9 pre-existing IDE0058 violations in the test project.
.editorconfigsetscsharp_style_unused_value_expression_statement_preference = discard_variable, and these statements discarded their value implicitly. Style only, no behaviour change. Happy to drop that commit if you would rather keep it separate.Verification
dotnet build Meraki.Api.slnx -c Release: 0 warnings, 0 errors.dotnet build Meraki.Api.Test -p:EnforceCodeStyleInBuild=true: 0 warnings, 0 errors (was 9 IDE0058 errors).MerakiClientSectionWiringTestsandMerakiClientQueryTests: 14 tests, all pass.MerakiClientconstructor omits organization Refit clients used by Dashboard API;IOrganizationsWirelessDevicesChannelUtilizationfails Refit build #337 now printsFalsefor all five properties.The wider test suite was deliberately not run, since it exercises and mutates a live Meraki organization.
Scope note
This PR closes the five cases named in #337 and nothing more. A reflection census of the section tree found that 82 further Refit clients and 4 sub-section objects are still left
nullby the constructor, from the same root cause: the constructor is a hand-maintained initializer mirroring a 134-class section tree, with no test asserting it is complete.That is raised separately as #357, which also flags two more interfaces carrying the identical
orgnanizationIdtypo (IOrganizationsVpnSiteToSiteIpsecandICameraCustomAnalyticsArtifacts). They are harmless today only because nothing wires them up, and they will start throwing for everyone the moment the wiring gap is closed.🤖 Generated with Claude Code