Skip to content

Commit

Permalink
Support for XSD nillable and xsi:nil="true" (#60)
Browse files Browse the repository at this point in the history
* WIP

* Completed typing and getters
WIP: needs runtime support for setters

* Fix "hides parent InnerException property" C# warning

* xsi:nil support for setting scalars
WIP: setting collections not supported yet

* XList support for nil values
WIP: codgen must be modified to take advantage of new option

* Refactor XNil apis and fix a few bugs

* Codegen nillable lists instances
Fix derived XList not supporting XNil.Value properly

* Fix overriden XList.Add nil support

* First test + Fix prevent xsi:type=anyType

* More tests and some fixes

* Added polysharp to XObjectsTests. Consolidated versions across the solution.

* Added global.json file for controlling which version of the .NET SDK to use.

* Revert "Added global.json file for controlling which version of the .NET SDK to use."

This reverts commit 9b1e83f.

* Lang version set to preview.

* Incremented version.

---------

Co-authored-by: Muhammad Miftah <mamift@gmail.com>
Co-authored-by: Muhammad Miftah <mamift@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 24, 2024
1 parent 4faf8d2 commit 3577756
Show file tree
Hide file tree
Showing 27 changed files with 1,504 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
<None Remove="TestNs2.xsd" />
<None Remove="TestNs3ToBeIncluded.xsd" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.13.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\XObjectsCore\XObjectsCore.csproj">
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion LinqToXsd.Schemas/LinqToXsd.Schemas.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="PolySharp" Version="1.13.2">
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
29 changes: 29 additions & 0 deletions LinqToXsd.Schemas/Tests/Nil/NilTest.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
targetNamespace="http://linqtoxsd.schemas.org/test/nil-test.xsd"
xmlns="http://linqtoxsd.schemas.org/test/nil-test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
>
<xs:complexType name="ValueHolder">
<xs:sequence>
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>

<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="RequiredRef" type="xs:string" nillable="true" />
<xs:element name="RequiredVal" type="xs:int" nillable="true" />
<xs:element name="RequiredEl" type="ValueHolder" nillable="true" />
<xs:element name="OptionalRef" type="xs:string" minOccurs="0" nillable="true" />
<xs:element name="OptionalVal" type="xs:int" minOccurs="0" nillable="true" />
<xs:element name="OptionalEl" type="ValueHolder" minOccurs="0" nillable="true" />
<xs:element name="ListRef" type="xs:string" minOccurs="0" maxOccurs="unbounded" nillable="true" />
<xs:element name="ListVal" type="xs:int" minOccurs="0" maxOccurs="unbounded" nillable="true" />
<xs:element name="ListEl" type="ValueHolder" minOccurs="0" maxOccurs="unbounded" nillable="true" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
15 changes: 15 additions & 0 deletions LinqToXsd.Schemas/Tests/Nil/NilTest.xsd.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns="http://www.microsoft.com/xml/schema/linq">
<CodeGeneration>
<NullableReferences>true</NullableReferences>
</CodeGeneration>
<Namespaces>
<Namespace DefaultVisibility="public" Schema="http://linqtoxsd.schemas.org/test/nil-test.xsd" Clr="LinqToXsd.Schemas.Test.NilTest" />
</Namespaces>
<Validation>
<VerifyRequired>false</VerifyRequired>
</Validation>
<Transformation>
<Deanonymize strict="false" />
</Transformation>
</Configuration>
Loading

0 comments on commit 3577756

Please sign in to comment.