Repository navigation
Move the file-system and generator-registry checks out of Schema to fix CA1506 [patch] - #353
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
…ix CA1506 [patch] #332 tipped Schema's class coupling to 97 against a limit of 96, and CA1506 is an error here, so main stopped building on every target framework. Move the data-source file-existence check and the reserved-generator-name check into an internal SchemaEnvironmentValidator. They are the two checks that consult something outside the schema, and with them gone Schema no longer reaches File, the IO exceptions, SchemaGenerator or ISchemaCodeGenerator. Behaviour is unchanged. Fixes #336 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW67k6oxx5vQPHu3V4Q
matt-edmondson
pushed a commit
that referenced
this pull request
Nov 1, 2026
File.Exists returns false instead of throwing for a path it can't read, so the IOException/UnauthorizedAccessException branch never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW67k6oxx5vQPHu3V4Q
|
This was referenced Nov 1, 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.



Fixes #336
What changed
mainhasn't built since #332 merged.Schemawas coupled to 97 types against a CA1506 limit of 96, and.editorconfigmakes CA1506 an error, so every target framework failed to compile. Every PR based onmainis red for the same reason.As the issue recommends, this moves logic out of the type rather than suppressing the warning. Two validation checks move from
Schema.Validation.csinto a new internal staticSchemaEnvironmentValidator:ReportMissingDataSourceFile(wasValidateDataSourceFileExists): checks that a data source's file exists on disk.ReportReservedNames: checks that no element is named after a file the configured generator writes for itself.These are the only two checks that consult something outside the schema, the file system and the generator registry. With them gone,
Schemano longer referencesFile,IOException,UnauthorizedAccessException,SchemaGeneratororISchemaCodeGenerator. That also removes a dependency of the model on the generators, which already depend on the model.GeneratedFileNames()becomesinternalsoSchemacan pass the names in, and theCanResolvePathsguard stays inSchema. Behaviour is unchanged.Verification
dotnet build Schemafails withCA1506: 'Schema' is coupled with '97' different typeson net8.0, net9.0 and net10.0.dotnet buildof the whole solution, with analyzers on, gives 0 errors and 0 warnings.GeneratedFileNameCollisionTestscovers reserved names, andSchemaDataSourceTestscovers a missing file and an unanchored schema.Once this merges, #352 and the Dependabot PRs can go green after a rebase.
Generated by Claude Code