Skip to content

[Fix] validate attribute values before parsing; fixes #37#74

Merged
samatstariongroup merged 2 commits into
developmentfrom
GH37
Jun 21, 2026
Merged

[Fix] validate attribute values before parsing; fixes #37#74
samatstariongroup merged 2 commits into
developmentfrom
GH37

Conversation

@samatstariongroup

@samatstariongroup samatstariongroup commented Jun 21, 2026

Copy link
Copy Markdown
Member

Boolean and integer attribute parsing already route through the ParseBoolean/ParseInt32 diagnostic helpers (added with #35). This change closes the remaining gap for URI attribute values.

  • Resource.GetEObject no longer follows a cross-resource reference unguarded. It now verifies the referenced .ecore file exists (File.Exists) before creating and loading it.
  • When the reference points at a resource that cannot be found, a descriptive Diagnostic is recorded in Resource.Errors and the reference is reported as unresolved (the typed GetEObject<T> then throws a clear InvalidOperationException naming the fragment) instead of a raw FileNotFoundException.
  • Added DiagnosticsTestFixture coverage for both a reference to a missing cross-resource .ecore and a reference to an existing one, so both branches of the new guard are exercised.

Note: an earlier revision also guarded the URI construction with Uri.TryCreate, but on .NET 10 a candidate derived from a local file path always parses as a valid absolute URI, making that branch unreachable/untestable; it was removed in favour of the reachable File.Exists check.

Full suite green (184 tests); new code fully covered locally (verified with coverlet).

Fixes #37.

…ts guard and cover both branches

The Uri.TryCreate guard was unreachable dead code on .NET 10 (file-path-derived
candidates always parse as valid absolute URIs), so it could not be covered. Replace it
with the meaningful, reachable File.Exists check and add a test for the existing-resource
branch so the new code is fully covered.
@github-actions

Copy link
Copy Markdown
Contributor
Package Line Rate Branch Rate Complexity Health
ECoreNetto 86% 79% 417
ECoreNetto.Extensions 99% 93% 101
ECoreNetto.HandleBars 99% 98% 60
ECoreNetto.Reporting 83% 71% 181
ECoreNetto.Tools 94% 89% 58
Summary 89% (2165 / 2432) 81% (497 / 610) 817

@sonarqubecloud

Copy link
Copy Markdown

@samatstariongroup samatstariongroup merged commit fff8ea4 into development Jun 21, 2026
14 checks passed
@samatstariongroup samatstariongroup deleted the GH37 branch June 21, 2026 15:04
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]: Validate attribute values before parsing

1 participant