Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3365ac6

Browse files
authored
Fix rd.xml for Serialization Reflection Only Mode. (#19556)
* Fix rd.xml for Serialization Reflection Only Mode. Fix #19067 * Removed GenericParameter Entries.
1 parent de7ae0e commit 3365ac6

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

src/System.Private.DataContractSerialization/src/Resources/System.Private.DataContractSerialization.rd.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@
1010
</Method>
1111
</Type>
1212
<Type Name="KeyValuePairAdapter`2" Dynamic="Required All" />
13+
<!-- Reflection-based serialization requires the entries below. -->
14+
<Type Name="CollectionDataContract">
15+
<Type Name="CollectionDataContractCriticalHelper">
16+
<Method Name="BuildCreateGenericDictionaryEnumerator{K, V}" Dynamic="Required" />
17+
<Method Name="BuildIncrementCollectionCountDelegate{T}" Dynamic="Required" />
18+
</Type>
19+
</Type>
20+
<Type Name="DataContractSerializer">
21+
<Property Name="Option" Dynamic="Required" />
22+
</Type>
23+
<Type Name="FastInvokerBuilder" Dynamic="Required All" />
24+
<Type Name="ReflectionReader">
25+
<Method Name="GetCollectionSetItemDelegate{T}" Dynamic="Required" />
26+
<Method Name="ObjectToKeyValuePairGetKey{K, V}" Dynamic="Required" />
27+
<Method Name="ObjectToKeyValuePairGetValue{K, V}" Dynamic="Required" />
28+
</Type>
29+
<Type Name="XmlObjectSerializerReadContext">
30+
<Method Name="TrimArraySize{T}" Dynamic="Required" />
31+
</Type>
32+
<Type Name="XmlObjectSerializerWriteContext">
33+
<Method Name="GetDefaultValue{T}" Dynamic="Required" />
34+
</Type>
1335
</Namespace>
1436
<Namespace Name="System.Runtime.Serialization.Json">
1537
<Type Name="DataContractJsonSerializer">

src/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,12 @@ internal XmlFormatGetOnlyCollectionReaderDelegate XmlFormatGetOnlyCollectionRead
438438
{
439439
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.GetOnlyCollectionMustHaveAddMethod, GetClrTypeFullName(UnderlyingType))));
440440
}
441-
Debug.Assert(AddMethod != null || Kind == CollectionKind.Array, "Add method cannot be null if the collection is being used as a get-only property");
441+
442+
if (Kind != CollectionKind.Array && AddMethod == null)
443+
{
444+
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.GetOnlyCollectionMustHaveAddMethod, GetClrTypeFullName(UnderlyingType))));
445+
}
446+
442447
XmlFormatGetOnlyCollectionReaderDelegate tempDelegate = new XmlFormatReaderGenerator().GenerateGetOnlyCollectionReader(this);
443448
Interlocked.MemoryBarrier();
444449
_helper.XmlFormatGetOnlyCollectionReaderDelegate = tempDelegate;

src/System.Runtime.Serialization.Json/tests/ReflectionOnly/Resources/System.Runtime.Serialization.Json.ReflectionOnly.Tests.rd.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/System.Runtime.Serialization.Json/tests/ReflectionOnly/System.Runtime.Serialization.Json.ReflectionOnly.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,5 @@
2121
<Compile Include="$(TestSourceFolder)..\DataContractJsonSerializer.CoreCLR.cs" />
2222
<Compile Include="$(TestSourceFolder)..\..\..\System.Runtime.Serialization.Xml\tests\SerializationTypes.CoreCLR.cs" />
2323
</ItemGroup>
24-
<ItemGroup Condition="'$(TargetGroup)' == 'uap'">
25-
<EmbeddedResource Include="$(MsBuildThisFileDirectory)Resources\$(AssemblyName).rd.xml" />
26-
</ItemGroup>
2724
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
2825
</Project>

src/System.Runtime.Serialization.Xml/tests/ReflectionOnly/Resources/System.Runtime.Serialization.Xml.ReflectionOnly.Tests.rd.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/System.Runtime.Serialization.Xml/tests/ReflectionOnly/System.Runtime.Serialization.Xml.ReflectionOnly.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,5 @@
3737
<Compile Include="$(TestSourceFolder)..\SerializationTypes.CoreCLR.cs" />
3838
<Compile Include="$(TestSourceFolder)..\DataContractSerializer.CoreCLR.cs" />
3939
</ItemGroup>
40-
<ItemGroup Condition="'$(TargetGroup)' == 'uap'">
41-
<EmbeddedResource Include="$(MsBuildThisFileDirectory)Resources\$(AssemblyName).rd.xml" />
42-
</ItemGroup>
4340
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
4441
</Project>

0 commit comments

Comments
 (0)