Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .agents/skills/polyxml-codegen-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,9 @@ Jackson 3 sorts properties alphabetically by default. Emit `@JsonPropertyOrder`
from flattened schema fields for its struct models, including inherited fields,
or valid reads can produce XSD-invalid XML on writes. The Spring fixture checks
returned XML against the source XSD independently using the JDK validator.

C# positional record properties named Equals/GetHashCode/ToString collide with
synthesized methods (UCI QueryPET's Equals field exposed CS8866). Suffix their
identifiers with Value before applying per-struct uniqueness; preserve original
XML names. The particle wire round-trip test covers these names and an explicit
EqualsValue collision in both record and mutable-class modes.
6 changes: 6 additions & 0 deletions crates/polyxml-core/src/codegen/csharp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ pub fn to_csharp_property_name(raw: &str, enclosing_type: Option<&str>) -> Strin
};

let sanitized = sanitize_keyword(&safe, "csharp");
// Positional record members cannot shadow the synthesized equality methods.
let sanitized = if matches!(sanitized.as_str(), "Equals" | "GetHashCode" | "ToString") {
format!("{sanitized}Value")
} else {
sanitized
};
if let Some(enclosing) = enclosing_type {
if sanitized == enclosing || sanitized.trim_start_matches('@') == enclosing {
return format!("{}Value", sanitized);
Expand Down
1 change: 1 addition & 0 deletions crates/polyxml-core/tests/test_csharp_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static DOTNET_LOCK: Mutex<()> = Mutex::new(());
#[test]
fn particle_wire_structure_round_trips() {
for (schema, root, documents) in [
(r#"<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="Query"><xs:complexType><xs:sequence><xs:element name="Equals" type="xs:string"/><xs:element name="EqualsValue" type="xs:string"/><xs:element name="GetHashCode" type="xs:string"/><xs:element name="ToString" type="xs:string"/></xs:sequence></xs:complexType></xs:element></xs:schema>"#, "Query", vec!["<Query><Equals>a</Equals><EqualsValue>b</EqualsValue><GetHashCode>c</GetHashCode><ToString>d</ToString></Query>"]),
(include_str!("../../../research/fixtures/nested_sequence_choice.xsd"), "Root", vec!["<Root><First>A</First><Second>B</Second></Root>", "<Root><Alternative>C</Alternative></Root>"]),
(include_str!("../../../research/fixtures/repeated_sequence.xsd"), "Root", vec!["<Root><First>A1</First><Second>B1</Second><First>A2</First><Second>B2</Second></Root>"]),
(include_str!("../../../research/fixtures/substitution_group.xsd"), "Portfolio", vec!["<Portfolio xmlns='urn:audit:substitution'><Bond>A1</Bond><Equity>B1</Equity><Bond>A2</Bond></Portfolio>"]),
Expand Down
Loading