[Feature] Populate Resource.Errors with diagnostics during parse (#35)#70
Merged
Conversation
#35 Parse problems were invisible to callers: Resource.Errors/Warnings were exposed but never written to. Fatal input now records a structured Diagnostic in Resource.Errors before aborting the load. - Add internal Resource.AddError(message) sink (Location = resource URI). - Add protected EObject.ParseBoolean/ParseInt32 helpers that record an error Diagnostic and then throw FormatException on malformed scalars. - Route the ~19 bool.Parse/int.Parse sites (abstract, interface, ordered, unique, lowerBound, upperBound, enum-literal value, etc.) through them. - Record an error at the unknown xsi:type throw sites in EPackage (classifier) and EClass (structural feature) before throwing. Malformed/unrecognized input stays fatal and aborts the load; callers that catch the exception can now inspect structured diagnostics with a source location. Adds DiagnosticsTestFixture covering each failure case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
|
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.



@
Summary
Closes #35.
ResourceexposedErrors/Warnings(IEnumerable<Diagnostic>), but nothing ever wrote to them — parse problems were invisible to callers or silently aborted the load with a bare exception. This change populatesResource.Errorswith a structuredDiagnostic(carrying a source location) whenever the parser hits fatal input, before aborting.Per the design decision on the issue, malformed/unrecognized input remains fatal and aborts the load — this does not recover with defaults. The benefit is that a caller catching the exception can now inspect
Resource.Errorsfor a structured, located diagnostic.Changes
Resource.cs— add internalAddError(message)that appends aDiagnostic(location = resource URI) to the existing backing list.EObject.cs— add protectedParseBoolean/ParseInt32helpers that, on malformed input, record an error Diagnostic and throwFormatException.bool.Parse/int.Parsecall sites through these helpers (EClass,EDataType,EEnumLiteral,ETypedElement,EStructuralFeature,EAttribute,EReference).xsi:typethrow sites inEPackage(classifier) andEClass(structural feature) before throwingInvalidOperationException.Tests
New
DiagnosticsTestFixtureasserts that, for each failure case,Loadthrows andResource.Errorscontains the matching diagnostic: malformed boolean, malformed integer, unknown classifier type, unknown structural-feature type, plus aDiagnostic.Locationcheck.Verification
dotnet build EcoreNetto.sln— 0 warnings.dotnet test EcoreNetto.sln— green (182 tests).🤖 Generated with Claude Code
@