Skip to content

Conversation

imcarolwang
Copy link
Contributor

When parsing an unfinished prefixed element ("<s:"), ReadObject previously surfaced ArgumentException (param "name"). Now it wraps the error in SerializationException per serializer contract.

Add regression test:

  • DataContractSerializer.cs: DCS_ReadObject_MalformedPrefix_EmptyLocalName_ThrowsSerializationException

Fixes #1409.

@Copilot Copilot AI review requested due to automatic review settings August 11, 2025 09:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves error handling in the XML serialization library by ensuring that malformed XML with invalid prefixes throws the expected SerializationException rather than leaking an ArgumentException. The fix addresses cases where malformed prefixed elements (like <s:) cause the XML parser to encounter empty local names.

  • Wraps ArgumentException with SerializationException to maintain consistent error handling contract
  • Adds exception handling in two methods: InternalIsStartObject and IsStartObjectHandleExceptions
  • Includes regression test to verify the fix works correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
XmlObjectSerializer.cs Adds exception handling to wrap ArgumentException in SerializationException for two XML parsing methods
DataContractSerializer.cs Adds regression test with malformed XML input and helper test types
Comments suppressed due to low confidence (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XmlTextReader.Read throws ArgumentNullException
2 participants