Skip service domains without services in the code generator - #1447
Merged
helto4real merged 1 commit intoSep 5, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1447 +/- ##
====================================
Coverage 83% 83%
====================================
Files 201 201
Lines 4170 4170
Branches 486 486
====================================
+ Hits 3466 3470 +4
+ Misses 498 496 -2
+ Partials 206 204 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
FrankBakkerNl
approved these changes
Sep 5, 2026
Generator.GenerateTypes handed every service domain to the helpers and
services generators, but ServicesGenerator only emitted a {Domain}Services
class for domains that still had at least one service. When
ServiceMetaDataParser drops all services of a domain because they failed
to deserialize, the generated IServices, Services and
AddHomeAssistantGenerated still referenced the missing class and the
generated file no longer compiled.
Filter out domains without services once, before any generator sees
them, and drop the local filter in ServicesGenerator so the root types
and the domain classes always agree.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tYWUzTg6pKoqNKAxdc1hT
helto4real
force-pushed
the
fix/codegen-empty-service-domain
branch
from
September 5, 2026 19:49
1c1fbb5 to
67663cc
Compare
helto4real
approved these changes
Sep 5, 2026
helto4real
left a comment
Collaborator
There was a problem hiding this comment.
The shared filtering keeps the service interfaces, root types, domain classes and DI registrations consistent. All 153 HassModel tests passed locally, and the new regression test failed as expected when the production fix was removed. The reviewed HassModel code and tests are unchanged after rebasing onto main. Approved, with merge pending required CI on the rebased commit.
helto4real
enabled auto-merge (squash)
September 5, 2026 19:50
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.
Proposed change
nd-codegencould emit aHomeAssistantGenerated.csthat does not compile.Generator.GenerateTypeshanded every service domain toHelpersGeneratorandServicesGenerator.ServicesGeneratoronly emitted a{Domain}Servicesclass for domains that still had at least one service, but it built theIServicesinterface and theServicesroot class from all domains, andHelpersGeneratorregisteredAddTransient<{Domain}Services>()for all domains as well.ServiceMetaDataParserswallows per-service deserialization errors by design. When every service of a domain fails to parse, that domain reaches the generators with an empty service list. The generated file then contained anIServicesproperty, aServicesproperty and a DI registration for a{Domain}Servicestype that was never declared, so the user's project no longer built.This PR:
Generator.GenerateTypes, before the helpers, services and extension-method generators see them. All generated types now agree on the same set of domains.Where(sd => sd.Services.Any())inServicesGenerator, which was the source of the inconsistency. Given the same input, the root interface, the root class and the domain classes are now always consistent.TestDomainWithoutAnyServices_ServicesTypeNotReferencedtoServicesGeneratorTest. It generates code for a domain with zero services next to a normallightdomain, asserts the{Domain}Servicesname does not appear anywhere in the output, and compiles the generated code together with app code. It fails without the fix with three dangling references to the undeclared type.Type of change
Additional information
Checklist
If user exposed functionality or configuration are added/changed: