fix(csharp): only generate XML serialization helpers when a model has XML usage#11341
Merged
jorgerangel-msft merged 4 commits intoJul 22, 2026
Merged
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
… XML usage Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix writeobjectvalue extension method generation when no xml models exist
fix(csharp): only generate XML serialization helpers when a model has XML usage
Jul 21, 2026
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
…detection Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
jorgerangel-msft
marked this pull request as ready for review
July 21, 2026 22:15
jorgerangel-msft
requested review from
JoshLove-msft,
joseharriaga,
jsquire and
m-nash
as code owners
July 21, 2026 22:15
jorgerangel-msft
approved these changes
Jul 21, 2026
jorgerangel-msft
enabled auto-merge
July 21, 2026 22:15
JoshLove-msft
approved these changes
Jul 22, 2026
jorgerangel-msft
deleted the
copilot/fix-writeobjectvalue-extension-method
branch
July 22, 2026 17:39
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.
The XML
WriteObjectValue<T>extension method emits acase IPersistableModel<T>that callsModelReaderWriter.Write(..., <Namespace>Context.Default). When the generatedModelReaderWriterContextregisters no buildable types, the source generator fails to produce.Default, breaking compilation (observed in Azure.Storage.Blobs.Batch).Root cause:
InputLibrary.GetHasXmlModelSerialization()treated an enum with XML usage as XML serialization support. Enums do not implementIPersistableModeland are never registered with the context, so an XML-usage enum alone enabled the XML helpers while leaving the context empty.Changes
InputLibrary.GetHasXmlModelSerialization: only consider models (which implementIPersistableModel); removed the enum branch. This gates all XML serialization helpers — includingWriteObjectValueand theBinaryContentHelperXML overload — on the presence of at least one XML model. Legitimate XML enums are already covered, since such enums only exist as properties of an XML model.ValidateXmlMethodsAreNotGeneratedWhenOnlyEnumHasXmlUsage, asserting noXmlWriter/XElementhelpers are emitted when only an enum carries XML usage.